Skip to content

Commit 0403a17

Browse files
Update Ruff and fix new lint errors
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/charliermarsh/ruff-pre-commit: v0.0.139 → v0.0.158](astral-sh/ruff-pre-commit@v0.0.139...v0.0.158) * Update Ruff and fix new lint errors Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jonathan Plasse <[email protected]>
1 parent e6f834b commit 0403a17

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/charliermarsh/ruff-pre-commit
3-
rev: v0.0.139
3+
rev: v0.0.158
44
hooks:
55
- id: ruff
66
args:
@@ -50,4 +50,4 @@ repos:
5050
rev: v1.9.0
5151
hooks:
5252
- id: python-check-blanket-type-ignore
53-
- id: python-no-eval
53+
- id: python-check-blanket-noqa

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ pre-commit install
3939

4040
If you are using VSCode, here are the settings to activate on save,
4141

42-
- `black` and `isort` to format.
42+
- `black` to format.
4343
- `mypy` to lint.
44-
- Install [charliermarsh.ruff](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) extension to lint (`ruff` is a fast equivalent to `flake8`)
44+
- Install [charliermarsh.ruff](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) extension to lint, sort imports, and auto-fix lint errors (`ruff` is a fast equivalent to `flake8`)
4545

4646
```json
4747
{

asyncio_mqtt/error.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ def __init__(self, rc: int | mqtt.ReasonCodes | None, *args: Any):
2020
def __str__(self) -> str:
2121
if isinstance(self.rc, mqtt.ReasonCodes):
2222
return f"[code:{self.rc.value}] {str(self.rc)}"
23-
elif isinstance(self.rc, int):
23+
if isinstance(self.rc, int):
2424
return f"[code:{self.rc}] {mqtt.error_string(self.rc)}"
25-
else:
26-
return f"[code:{self.rc}] {super().__str__()}"
25+
return f"[code:{self.rc}] {super().__str__()}"
2726

2827

2928
class MqttConnectError(MqttCodeError):
@@ -36,6 +35,7 @@ def __init__(self, rc: int | mqtt.ReasonCodes):
3635
except KeyError:
3736
pass
3837
super().__init__(rc, msg)
38+
return None
3939

4040

4141
_CONNECT_RC_STRINGS: dict[int, str] = {

pyproject.toml

+11-8
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ dynamic = ["version"]
4141
"Issue tracker" = "https://github.com/sbtinstruments/asyncio-mqtt/issues"
4242

4343
[project.optional-dependencies]
44-
lint = ["mypy>=0.982", "ruff>=0.0.124", "types-paho-mqtt>=1.6.0.1"]
45-
format = ["black>=22.10.0", "isort>=5.10.1"]
44+
lint = ["mypy>=0.991", "ruff>=0.0.158", "types-paho-mqtt>=1.6.0.1"]
45+
format = ["black>=22.10.0"]
4646
tests = ["pytest>=7.2.0", "pytest-cov>=4.0.0", "anyio>=3.6.2"]
4747

4848
[tool.setuptools]
@@ -51,9 +51,6 @@ packages = ["asyncio_mqtt"]
5151
[tool.setuptools_scm]
5252
write_to = "asyncio_mqtt/_version.py"
5353

54-
[tool.isort]
55-
profile = "black"
56-
5754
[tool.ruff]
5855
select = [
5956
"A", # builtins
@@ -64,13 +61,19 @@ select = [
6461
"E", # style errors
6562
"F", # flakes
6663
"I", # import sorting
67-
"M", # meta
6864
"N", # naming
65+
"PGH", # pygrep-hooks
66+
"PLC", # pylint convention
67+
"PLE", # pylint error
68+
"PLR", # pylint refactor
69+
"PLW", # pylint warning
6970
"Q", # quotes
71+
"RET", # return
7072
"RUF", # ruff
7173
"S", # bandit
72-
"T", # print
73-
"U", # upgrade
74+
"T10", # debugger
75+
"T20", # print
76+
"UP", # upgrade
7477
"W", # style warnings
7578
"YTT", # sys.version
7679
]

tests/conftest.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ def anyio_backend() -> tuple[str, dict[str, Any]]:
1212
from asyncio.windows_events import WindowsSelectorEventLoopPolicy
1313

1414
return ("asyncio", {"policy": WindowsSelectorEventLoopPolicy()})
15-
else:
16-
return ("asyncio", {})
15+
return ("asyncio", {})

0 commit comments

Comments
 (0)