From 60b41b0b20931fde95bdfdc1eeffa6e462424972 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 4 Feb 2024 16:43:23 +0100 Subject: [PATCH] Migrate ruff configuration for Ruff 0.2.0 (#544) --- examples/ruff.toml | 2 +- pyproject.toml | 8 ++++---- src/tailscale/models.py | 2 ++ src/tailscale/tailscale.py | 4 ++++ tests/ruff.toml | 4 ++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/examples/ruff.toml b/examples/ruff.toml index 2eb42d9..8caec9e 100644 --- a/examples/ruff.toml +++ b/examples/ruff.toml @@ -1,6 +1,6 @@ # This extend our general Ruff rules specifically for the examples extend = "../pyproject.toml" -extend-ignore = [ +lint.extend-ignore = [ "T201", # Allow the use of print() in examples ] diff --git a/pyproject.toml b/pyproject.toml index ef2eaa4..e199945 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -131,7 +131,7 @@ max-line-length=88 addopts = "--cov" asyncio_mode = "auto" -[tool.ruff] +[tool.ruff.lint] ignore = [ "ANN101", # Self... explanatory "ANN102", # cls... just as annoying as ANN101 @@ -147,17 +147,17 @@ ignore = [ ] select = ["ALL"] -[tool.ruff.flake8-pytest-style] +[tool.ruff.lint.flake8-pytest-style] fixture-parentheses = false mark-parentheses = false -[tool.ruff.isort] +[tool.ruff.lint.isort] known-first-party = ["tailscale"] [tool.ruff.lint.flake8-type-checking] runtime-evaluated-base-classes = ["mashumaro.mixins.orjson.DataClassORJSONMixin"] -[tool.ruff.mccabe] +[tool.ruff.lint.mccabe] max-complexity = 25 [build-system] diff --git a/src/tailscale/models.py b/src/tailscale/models.py index a439104..4a5b378 100644 --- a/src/tailscale/models.py +++ b/src/tailscale/models.py @@ -81,6 +81,7 @@ def __pre_deserialize__(cls, d: dict[Any, Any]) -> dict[Any, Any]: Returns: ------- The adjusted values of the model. + """ # Convert an empty string to None. if not d.get("created"): @@ -105,6 +106,7 @@ def __pre_deserialize__(cls, d: dict[Any, Any]) -> dict[Any, Any]: Returns: ------- The adjusted values of the model. + """ # Convert list into dict, keyed by device id. d["devices"] = {device["id"]: device for device in d["devices"]} diff --git a/src/tailscale/tailscale.py b/src/tailscale/tailscale.py index 561855e..60aec61 100644 --- a/src/tailscale/tailscale.py +++ b/src/tailscale/tailscale.py @@ -62,6 +62,7 @@ async def _request( the Tailscale API. TailscaleError: Received an unexpected response from the Tailscale API. + """ version = metadata.version(__package__) url = URL("https://api.tailscale.com/api/v2/").join(URL(uri)) @@ -109,6 +110,7 @@ async def devices(self) -> dict[str, Device]: Returns ------- Returns a dictionary of Tailscale devices. + """ data = await self._request(f"tailnet/{self.tailnet}/devices?fields=all") return Devices.from_json(data).devices @@ -124,6 +126,7 @@ async def __aenter__(self) -> Self: Returns ------- The Tailscale object. + """ return self @@ -133,5 +136,6 @@ async def __aexit__(self, *_exc_info: object) -> None: Args: ---- _exc_info: Exec type. + """ await self.close() diff --git a/tests/ruff.toml b/tests/ruff.toml index b346c56..1005d3e 100644 --- a/tests/ruff.toml +++ b/tests/ruff.toml @@ -1,11 +1,11 @@ # This extend our general Ruff rules specifically for tests extend = "../pyproject.toml" -extend-select = [ +lint.extend-select = [ "PT", # Use @pytest.fixture without parentheses ] -extend-ignore = [ +lint.extend-ignore = [ "S101", # Use of assert detected. As these are tests... "SLF001", # Tests will access private/protected members... "TCH002", # pytest doesn't like this one...