diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 12237e0..a1553d3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,18 +16,16 @@ jobs: strategy: matrix: include: - - dependencies: black python3-isort + - dependencies: ruff task: make -f Makefile fmt-travis - dependencies: yamllint task: make -f Makefile yamllint - dependencies: > libatomic - pylint python3-into-dbus-python python3-setuptools - task: > - PATH=${PATH}:/github/home/.local/bin - PYTHONPATH=./src make -f Makefile lint + ruff + task: PATH=${PATH}:/github/home/.local/bin make -f Makefile lint - dependencies: python3-into-dbus-python python3-setuptools task: PYTHONPATH=./src make -f Makefile test - dependencies: > diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index 3746afb..0000000 --- a/.isort.cfg +++ /dev/null @@ -1,16 +0,0 @@ -[settings] -profile = black - -sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCAL,LOCALFOLDER - -import_heading_future=isort: FUTURE -import_heading_stdlib=isort: STDLIB -import_heading_thirdparty=isort: THIRDPARTY -import_heading_firstparty=isort: FIRSTPARTY -import_heading_local=isort: LOCAL - -# All items above should be the same for every -# Stratis project. The items below vary with -# each project. -known_first_party=into_dbus_python -known_local=dbus_python_client_gen diff --git a/Makefile b/Makefile index 893313d..2fa2dbd 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,16 @@ .PHONY: fmt fmt: - isort setup.py src tests - black . + ruff check --fix --select I + ruff format .PHONY: fmt-travis fmt-travis: - isort --diff --check-only setup.py src tests - black . --check + ruff check --select I + ruff format --check .PHONY: lint lint: - pylint setup.py - pylint src/dbus_python_client_gen - pylint tests --ignore=_introspect.py + ruff check pyright .PHONY: test diff --git a/pyproject.toml b/pyproject.toml index fed528d..75d90c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,17 @@ [build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta" + +[tool.ruff] +target-version = "py312" +line-length = 88 + +[tool.ruff.lint] +select = ["PL"] + +[tool.ruff.lint.isort] +known-first-party = ["into-dbus-python"] +split-on-trailing-comma = false + +[tool.ruff.format] +skip-magic-trailing-comma = true diff --git a/setup.py b/setup.py index 8183dfe..17fb511 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,6 @@ Python packaging file for setup tools. """ -# isort: THIRDPARTY import setuptools setuptools.setup() diff --git a/src/dbus_python_client_gen/_errors.py b/src/dbus_python_client_gen/_errors.py index 54c8b50..8b4ee3e 100644 --- a/src/dbus_python_client_gen/_errors.py +++ b/src/dbus_python_client_gen/_errors.py @@ -5,16 +5,9 @@ Exception hierarchy for this package. """ -# isort: STDLIB from abc import ABC -# Put this pylint directive at module level. There's a slight bug in pylint -# that causes the directive to be ignored if there is no body to a class -# (because the pass statement is omitted). On the other hand, pylint now -# warns if it finds an unnecessary pass statement. This is the easiest course. - -# pylint: disable=too-few-public-methods class DPClientInvocationContext(ABC): """ Identifies the context in which an invocation error occurred. @@ -130,13 +123,7 @@ class DPClientMarshallingError(DPClientInvalidArgError): Exception raised when the arguments could not be marshalled properly. """ - def __init__( - self, - message, - interface_name, - signature, - arguments, - ): + def __init__(self, message, interface_name, signature, arguments): """ Initialize a DPClientMarshallingError with the arguments that failed. All DPClientMarshallingErrors are guaranteed to have a non-empty list @@ -157,14 +144,7 @@ class DPClientKeywordError(DPClientInvalidArgError): Exception raised when keywords used do not match keywords expected. """ - def __init__( - self, - message, - interface_name, - method_name, - expected, - actual, - ): # pylint: disable=too-many-arguments, too-many-positional-arguments + def __init__(self, message, interface_name, method_name, expected, actual): """ Initialize a DPClientKeywordError with the mismatched arguments. diff --git a/src/dbus_python_client_gen/_invokers.py b/src/dbus_python_client_gen/_invokers.py index 54c3f44..796962e 100644 --- a/src/dbus_python_client_gen/_invokers.py +++ b/src/dbus_python_client_gen/_invokers.py @@ -4,16 +4,13 @@ """ Code for generating classes suitable for invoking dbus-python methods. """ -# isort: STDLIB + import types import xml.etree.ElementTree as ET # nosec B405 from typing import Any, Callable, Mapping, MutableMapping, Sequence, Type -# isort: THIRDPARTY import dbus from dbus.proxies import ProxyObject - -# isort: FIRSTPARTY from into_dbus_python import IntoDPError, xformer, xformers from ._errors import ( @@ -27,7 +24,7 @@ ) -def prop_builder( +def prop_builder( # noqa: PLR0915 interface_name: str, properties: Sequence[ET.Element], default_timeout: int ) -> Callable[[MutableMapping[str, Type]], None]: """ @@ -217,8 +214,7 @@ class has up to two static methods, a Get method if the property is name = prop.attrib["name"] except KeyError as err: # pragma: no cover fmt_str = ( - "No name attribute found for property belonging to " - 'interface "%s"' + 'No name attribute found for property belonging to interface "%s"' ) raise DPClientGenerationError(fmt_str % interface_name) from err @@ -272,8 +268,7 @@ def method_builder( """ def build_method( - name: str, - inargs: Sequence[ET.Element], + name: str, inargs: Sequence[ET.Element] ) -> Callable[[ProxyObject, Mapping[str, Any]], Any]: """ Build a method for this class. diff --git a/tests/test_generated.py b/tests/test_generated.py index ab220e8..0cb16d0 100644 --- a/tests/test_generated.py +++ b/tests/test_generated.py @@ -2,20 +2,16 @@ Test generation of class for invoking dbus methods. """ -# isort: STDLIB import unittest import xml.etree.ElementTree as ET -# isort: FIRSTPARTY -from tests._introspect import SPECS - -# isort: LOCAL from dbus_python_client_gen import ( DPClientGenerationError, DPClientKeywordError, DPClientMarshallingError, make_class, ) +from tests._introspect import SPECS try: interfaces = list(SPECS)