Update ruff to 0.2.1 (#109796)
* Update ruff to 0.2.1 * Rename config sections * Update remapped error codes * Add ignorespull/109122/head
parent
a533fa222e
commit
545b888034
|
@ -1,6 +1,6 @@
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.1.15
|
rev: v0.2.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args:
|
args:
|
||||||
|
|
|
@ -96,7 +96,7 @@ class RingDataCoordinator(DataUpdateCoordinator[dict[int, RingDeviceData]]):
|
||||||
if history_task:
|
if history_task:
|
||||||
data[device.id].history = history_task.result()
|
data[device.id].history = history_task.result()
|
||||||
except ExceptionGroup as eg:
|
except ExceptionGroup as eg:
|
||||||
raise eg.exceptions[0]
|
raise eg.exceptions[0] # noqa: B904
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,8 @@ def _equivalent_units(units: set[str | None]) -> bool:
|
||||||
if len(units) == 1:
|
if len(units) == 1:
|
||||||
return True
|
return True
|
||||||
units = {
|
units = {
|
||||||
EQUIVALENT_UNITS[unit] if unit in EQUIVALENT_UNITS else unit for unit in units
|
EQUIVALENT_UNITS[unit] if unit in EQUIVALENT_UNITS else unit # noqa: SIM401
|
||||||
|
for unit in units
|
||||||
}
|
}
|
||||||
return len(units) == 1
|
return len(units) == 1
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# This extend our general Ruff rules specifically for tests
|
# This extend our general Ruff rules specifically for tests
|
||||||
extend = "../pyproject.toml"
|
extend = "../pyproject.toml"
|
||||||
|
|
||||||
[isort]
|
[lint.isort]
|
||||||
known-third-party = [
|
known-third-party = [
|
||||||
"pylint",
|
"pylint",
|
||||||
]
|
]
|
||||||
|
|
|
@ -221,7 +221,7 @@ disable = [
|
||||||
"duplicate-key", # F601
|
"duplicate-key", # F601
|
||||||
"duplicate-string-formatting-argument", # F
|
"duplicate-string-formatting-argument", # F
|
||||||
"duplicate-value", # F
|
"duplicate-value", # F
|
||||||
"eval-used", # PGH001
|
"eval-used", # S307
|
||||||
"exec-used", # S102
|
"exec-used", # S102
|
||||||
# "expression-not-assigned", # B018, ruff catches new occurrences, needs more work
|
# "expression-not-assigned", # B018, ruff catches new occurrences, needs more work
|
||||||
"f-string-without-interpolation", # F541
|
"f-string-without-interpolation", # F541
|
||||||
|
@ -241,7 +241,7 @@ disable = [
|
||||||
"named-expr-without-context", # PLW0131
|
"named-expr-without-context", # PLW0131
|
||||||
"nested-min-max", # PLW3301
|
"nested-min-max", # PLW3301
|
||||||
# "pointless-statement", # B018, ruff catches new occurrences, needs more work
|
# "pointless-statement", # B018, ruff catches new occurrences, needs more work
|
||||||
"raise-missing-from", # TRY200
|
"raise-missing-from", # B904
|
||||||
# "redefined-builtin", # A001, ruff is way more stricter, needs work
|
# "redefined-builtin", # A001, ruff is way more stricter, needs work
|
||||||
"try-except-raise", # TRY302
|
"try-except-raise", # TRY302
|
||||||
"unused-argument", # ARG001, we don't use it
|
"unused-argument", # ARG001, we don't use it
|
||||||
|
@ -569,13 +569,14 @@ filterwarnings = [
|
||||||
"ignore:pkg_resources is deprecated as an API:DeprecationWarning:webrtcvad",
|
"ignore:pkg_resources is deprecated as an API:DeprecationWarning:webrtcvad",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff.lint]
|
||||||
select = [
|
select = [
|
||||||
"B002", # Python does not support the unary prefix increment
|
"B002", # Python does not support the unary prefix increment
|
||||||
"B007", # Loop control variable {name} not used within loop body
|
"B007", # Loop control variable {name} not used within loop body
|
||||||
"B014", # Exception handler with duplicate exception
|
"B014", # Exception handler with duplicate exception
|
||||||
"B023", # Function definition does not bind loop variable {name}
|
"B023", # Function definition does not bind loop variable {name}
|
||||||
"B026", # Star-arg unpacking after a keyword argument is strongly discouraged
|
"B026", # Star-arg unpacking after a keyword argument is strongly discouraged
|
||||||
|
"B904", # Use raise from to specify exception cause
|
||||||
"C", # complexity
|
"C", # complexity
|
||||||
"COM818", # Trailing comma on bare tuple prohibited
|
"COM818", # Trailing comma on bare tuple prohibited
|
||||||
"D", # docstrings
|
"D", # docstrings
|
||||||
|
@ -589,7 +590,6 @@ select = [
|
||||||
"N804", # First argument of a class method should be named cls
|
"N804", # First argument of a class method should be named cls
|
||||||
"N805", # First argument of a method should be named self
|
"N805", # First argument of a method should be named self
|
||||||
"N815", # Variable {name} in class scope should not be mixedCase
|
"N815", # Variable {name} in class scope should not be mixedCase
|
||||||
"PGH001", # No builtin eval() allowed
|
|
||||||
"PGH004", # Use specific rule codes when using noqa
|
"PGH004", # Use specific rule codes when using noqa
|
||||||
"PLC0414", # Useless import alias. Import alias does not rename original package.
|
"PLC0414", # Useless import alias. Import alias does not rename original package.
|
||||||
"PLC", # pylint
|
"PLC", # pylint
|
||||||
|
@ -628,7 +628,6 @@ select = [
|
||||||
"T20", # flake8-print
|
"T20", # flake8-print
|
||||||
"TID251", # Banned imports
|
"TID251", # Banned imports
|
||||||
"TRY004", # Prefer TypeError exception for invalid type
|
"TRY004", # Prefer TypeError exception for invalid type
|
||||||
"TRY200", # Use raise from to specify exception cause
|
|
||||||
"TRY302", # Remove exception handler; error is immediately re-raised
|
"TRY302", # Remove exception handler; error is immediately re-raised
|
||||||
"UP", # pyupgrade
|
"UP", # pyupgrade
|
||||||
"W", # pycodestyle
|
"W", # pycodestyle
|
||||||
|
@ -681,7 +680,7 @@ ignore = [
|
||||||
"PLE0605",
|
"PLE0605",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.ruff.flake8-import-conventions.extend-aliases]
|
[tool.ruff.lint.flake8-import-conventions.extend-aliases]
|
||||||
voluptuous = "vol"
|
voluptuous = "vol"
|
||||||
"homeassistant.helpers.area_registry" = "ar"
|
"homeassistant.helpers.area_registry" = "ar"
|
||||||
"homeassistant.helpers.config_validation" = "cv"
|
"homeassistant.helpers.config_validation" = "cv"
|
||||||
|
@ -690,14 +689,14 @@ voluptuous = "vol"
|
||||||
"homeassistant.helpers.issue_registry" = "ir"
|
"homeassistant.helpers.issue_registry" = "ir"
|
||||||
"homeassistant.util.dt" = "dt_util"
|
"homeassistant.util.dt" = "dt_util"
|
||||||
|
|
||||||
[tool.ruff.flake8-pytest-style]
|
[tool.ruff.lint.flake8-pytest-style]
|
||||||
fixture-parentheses = false
|
fixture-parentheses = false
|
||||||
|
|
||||||
[tool.ruff.flake8-tidy-imports.banned-api]
|
[tool.ruff.lint.flake8-tidy-imports.banned-api]
|
||||||
"async_timeout".msg = "use asyncio.timeout instead"
|
"async_timeout".msg = "use asyncio.timeout instead"
|
||||||
"pytz".msg = "use zoneinfo instead"
|
"pytz".msg = "use zoneinfo instead"
|
||||||
|
|
||||||
[tool.ruff.isort]
|
[tool.ruff.lint.isort]
|
||||||
force-sort-within-sections = true
|
force-sort-within-sections = true
|
||||||
known-first-party = [
|
known-first-party = [
|
||||||
"homeassistant",
|
"homeassistant",
|
||||||
|
@ -705,12 +704,12 @@ known-first-party = [
|
||||||
combine-as-imports = true
|
combine-as-imports = true
|
||||||
split-on-trailing-comma = false
|
split-on-trailing-comma = false
|
||||||
|
|
||||||
[tool.ruff.per-file-ignores]
|
[tool.ruff.lint.per-file-ignores]
|
||||||
|
|
||||||
# Allow for main entry & scripts to write to stdout
|
# Allow for main entry & scripts to write to stdout
|
||||||
"homeassistant/__main__.py" = ["T201"]
|
"homeassistant/__main__.py" = ["T201"]
|
||||||
"homeassistant/scripts/*" = ["T201"]
|
"homeassistant/scripts/*" = ["T201"]
|
||||||
"script/*" = ["T20"]
|
"script/*" = ["T20"]
|
||||||
|
|
||||||
[tool.ruff.mccabe]
|
[tool.ruff.lint.mccabe]
|
||||||
max-complexity = 25
|
max-complexity = 25
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Automatically generated from .pre-commit-config.yaml by gen_requirements_all.py, do not edit
|
# Automatically generated from .pre-commit-config.yaml by gen_requirements_all.py, do not edit
|
||||||
|
|
||||||
codespell==2.2.2
|
codespell==2.2.2
|
||||||
ruff==0.1.15
|
ruff==0.2.1
|
||||||
yamllint==1.32.0
|
yamllint==1.32.0
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# This extend our general Ruff rules specifically for tests
|
# This extend our general Ruff rules specifically for tests
|
||||||
extend = "../pyproject.toml"
|
extend = "../pyproject.toml"
|
||||||
|
|
||||||
[isort]
|
[lint.isort]
|
||||||
forced-separate = [
|
forced-separate = [
|
||||||
"tests",
|
"tests",
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# This extend our general Ruff rules specifically for tests
|
# This extend our general Ruff rules specifically for tests
|
||||||
extend = "../pyproject.toml"
|
extend = "../pyproject.toml"
|
||||||
|
|
||||||
|
[lint]
|
||||||
extend-select = [
|
extend-select = [
|
||||||
"PT001", # Use @pytest.fixture without parentheses
|
"PT001", # Use @pytest.fixture without parentheses
|
||||||
"PT002", # Configuration for fixture specified via positional args, use kwargs
|
"PT002", # Configuration for fixture specified via positional args, use kwargs
|
||||||
|
@ -17,10 +18,11 @@ extend-ignore = [
|
||||||
"PLE", # pylint
|
"PLE", # pylint
|
||||||
"PLR", # pylint
|
"PLR", # pylint
|
||||||
"PLW", # pylint
|
"PLW", # pylint
|
||||||
|
"B904", # Use raise from to specify exception cause
|
||||||
"N815", # Variable {name} in class scope should not be mixedCase
|
"N815", # Variable {name} in class scope should not be mixedCase
|
||||||
]
|
]
|
||||||
|
|
||||||
[isort]
|
[lint.isort]
|
||||||
known-first-party = [
|
known-first-party = [
|
||||||
"homeassistant",
|
"homeassistant",
|
||||||
"tests",
|
"tests",
|
||||||
|
@ -34,4 +36,4 @@ known-third-party = [
|
||||||
]
|
]
|
||||||
forced-separate = [
|
forced-separate = [
|
||||||
"tests",
|
"tests",
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue