Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ruff isort plugin instead of isort #1353

Merged
merged 3 commits into from
Nov 5, 2023
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
9 changes: 2 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,12 @@ repos:
hooks:
- id: flake8
files: ^(xknx|examples|docs)/.+\.py$
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
args:
- --resolve-all-configs
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.292'
hooks:
- id: ruff
# in CI it is directly run by tox to allow dependency upgrade checks
stages: [pre-commit]
args: [ --fix, --exit-non-zero-on-fix ]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
Expand Down
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ nav_order: 2

- Parse `project_name` from an ETS Keyring.

### Internal

- Use ruff isort plugin, remove isort from requirements.

# 2.11.2 DPT 9 small negative fix 2023-07-24

### Bugfixes
Expand Down
13 changes: 5 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ version = {attr = "xknx.__version__.__version__"}
include = ["xknx*"]

[tool.black]
target-version = ["py39", "py310", "py311", "py312"]
exclude = "generated"


Expand All @@ -52,13 +51,6 @@ ignore-words-list = 'hass'
quiet-level = 2


[tool.isort]
profile = "black"
# will group `import x` and `from x import` of the same module.
force_sort_within_sections = true
combine_as_imports = true


[tool.mypy]
pretty = true
python_version = "3.9"
Expand Down Expand Up @@ -142,6 +134,7 @@ select = [
"D", # pydocstyle
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"RUF", # ruff specific
"T20", # print
"UP", # pyupgrade
Expand All @@ -157,6 +150,10 @@ extend-exclude = [
"script",
]

[tool.ruff.isort]
force-sort-within-sections = true
combine-as-imports = true

[tool.ruff.per-file-ignores]
"examples/*" = ["T20"] # print-used
"test/*" = ["RUF012"] # Mutable class attributes should be annotated with `typing.ClassVar`
2 changes: 1 addition & 1 deletion requirements/testing.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
-r production.txt
pre-commit==3.5.0
isort==5.12.0
flake8==6.1.0
pylint==3.0.2
pytest==7.4.3
Expand All @@ -10,4 +9,5 @@ pytest-icdiff==0.8
ruff==0.1.3
setuptools==68.2.2
tox==4.11.3
tox-gh-actions==3.1.3
mypy==1.6.1
20 changes: 15 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
[tox]
envlist = py39, py310, py311, py312, typing, lint, pylint
envlist = py39, py310, py311, py312, ruff, typing, lint, pylint
skip_missing_interpreters = True

[gh-actions]
python =
3.9: py39
3.10: py310
3.11: py310, ruff, typing, lint, pylint
3.12: py312

[testenv]
setenv =
PYTHONPATH = {toxinidir}
Expand All @@ -14,20 +21,23 @@ wheel_build_env = .pkg
[testenv:lint]
basepython = python3
commands =
ruff check {posargs:.}
pre-commit run codespell {posargs: --all-files}
pre-commit run flake8 {posargs: --all-files}
pre-commit run pyupgrade {posargs: --all-files}
pre-commit run black {posargs: --all-files}
pre-commit run isort {posargs: --all-files}
pre-commit run check-json {posargs: --all-files}
pre-commit run trailing-whitespace {posargs: --all-files}

[testenv:pylint]
basepython = python3
commands =
pylint --jobs=0 xknx examples
pylint --jobs=0 --disable=protected-access,abstract-class-instantiated test
pylint --jobs=0 xknx examples
pylint --jobs=0 --disable=protected-access,abstract-class-instantiated test

[testenv:ruff]
basepython = python3
commands =
ruff check {posargs:.}

[testenv:typing]
basepython = python3
Expand Down