Skip to content

Commit

Permalink
Migrate ruff configuration for Ruff 0.2.0 (#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Feb 4, 2024
1 parent 2ed873f commit 60b41b0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/ruff.toml
Original file line number Diff line number Diff line change
@@ -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
]
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions src/tailscale/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand All @@ -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"]}
Expand Down
4 changes: 4 additions & 0 deletions src/tailscale/tailscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand All @@ -124,6 +126,7 @@ async def __aenter__(self) -> Self:
Returns
-------
The Tailscale object.
"""
return self

Expand All @@ -133,5 +136,6 @@ async def __aexit__(self, *_exc_info: object) -> None:
Args:
----
_exc_info: Exec type.
"""
await self.close()
4 changes: 2 additions & 2 deletions tests/ruff.toml
Original file line number Diff line number Diff line change
@@ -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...
Expand Down

0 comments on commit 60b41b0

Please sign in to comment.