Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: >
Expand Down
16 changes: 0 additions & 16 deletions .isort.cfg

This file was deleted.

12 changes: 5 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Python packaging file for setup tools.
"""

# isort: THIRDPARTY
import setuptools

setuptools.setup()
24 changes: 2 additions & 22 deletions src/dbus_python_client_gen/_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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.

Expand Down
13 changes: 4 additions & 9 deletions src/dbus_python_client_gen/_invokers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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]:
"""
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
6 changes: 1 addition & 5 deletions tests/test_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down