Skip to content

Commit

Permalink
Update Ruff and fix new lint errors
Browse files Browse the repository at this point in the history
* [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 <13716151+JonathanPlasse@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] and JonathanPlasse authored Dec 5, 2022
1 parent e6f834b commit 0403a17
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.139
rev: v0.0.158
hooks:
- id: ruff
args:
Expand Down Expand Up @@ -50,4 +50,4 @@ repos:
rev: v1.9.0
hooks:
- id: python-check-blanket-type-ignore
- id: python-no-eval
- id: python-check-blanket-noqa
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ pre-commit install

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

- `black` and `isort` to format.
- `black` to format.
- `mypy` to lint.
- Install [charliermarsh.ruff](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) extension to lint (`ruff` is a fast equivalent to `flake8`)
- 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`)

```json
{
Expand Down
6 changes: 3 additions & 3 deletions asyncio_mqtt/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ def __init__(self, rc: int | mqtt.ReasonCodes | None, *args: Any):
def __str__(self) -> str:
if isinstance(self.rc, mqtt.ReasonCodes):
return f"[code:{self.rc.value}] {str(self.rc)}"
elif isinstance(self.rc, int):
if isinstance(self.rc, int):
return f"[code:{self.rc}] {mqtt.error_string(self.rc)}"
else:
return f"[code:{self.rc}] {super().__str__()}"
return f"[code:{self.rc}] {super().__str__()}"


class MqttConnectError(MqttCodeError):
Expand All @@ -36,6 +35,7 @@ def __init__(self, rc: int | mqtt.ReasonCodes):
except KeyError:
pass
super().__init__(rc, msg)
return None


_CONNECT_RC_STRINGS: dict[int, str] = {
Expand Down
19 changes: 11 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ dynamic = ["version"]
"Issue tracker" = "https://github.com/sbtinstruments/asyncio-mqtt/issues"

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

[tool.setuptools]
Expand All @@ -51,9 +51,6 @@ packages = ["asyncio_mqtt"]
[tool.setuptools_scm]
write_to = "asyncio_mqtt/_version.py"

[tool.isort]
profile = "black"

[tool.ruff]
select = [
"A", # builtins
Expand All @@ -64,13 +61,19 @@ select = [
"E", # style errors
"F", # flakes
"I", # import sorting
"M", # meta
"N", # naming
"PGH", # pygrep-hooks
"PLC", # pylint convention
"PLE", # pylint error
"PLR", # pylint refactor
"PLW", # pylint warning
"Q", # quotes
"RET", # return
"RUF", # ruff
"S", # bandit
"T", # print
"U", # upgrade
"T10", # debugger
"T20", # print
"UP", # upgrade
"W", # style warnings
"YTT", # sys.version
]
Expand Down
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ def anyio_backend() -> tuple[str, dict[str, Any]]:
from asyncio.windows_events import WindowsSelectorEventLoopPolicy

return ("asyncio", {"policy": WindowsSelectorEventLoopPolicy()})
else:
return ("asyncio", {})
return ("asyncio", {})

0 comments on commit 0403a17

Please sign in to comment.