From e060009a0088fe5cafe40a301ea286260ec2e99a Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Thu, 31 Oct 2024 16:49:45 +0000 Subject: [PATCH] Move to pyproject --- .github/workflows/lint.yml | 4 ++-- .ruff.toml | 48 -------------------------------------- pyproject.toml | 21 +++++++++++++---- 3 files changed, 19 insertions(+), 54 deletions(-) delete mode 100644 .ruff.toml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 98e994d..6648c94 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -6,13 +6,13 @@ on: - '**.py' # Run if pushed commits include a change to a Python (.py) file. - '.github/workflows/lint.yml' # Run if pushed commits include a change to a github actions workflow file. - 'requirements.txt' # Run if pushed commits include a change to the Python requirements.txt file. - - '.ruff.toml' # Run if ruff configuration file changes. + - '.pyprogject.toml' # Run if project configuration file changes. pull_request: paths: - '**.py' # Run if pushed commits include a change to a Python (.py) file. - '.github/workflows/lint.yml' # Run if pushed commits include a change to a github actions workflow file. - 'requirements.txt' # Run if pushed commits include a change to the Python requirements.txt file. - - '.ruff.toml' # Run if ruff configuration file changes. + - '.pyprogject.toml' # Run if project configuration file changes. workflow_dispatch: jobs: diff --git a/.ruff.toml b/.ruff.toml deleted file mode 100644 index 85f54ef..0000000 --- a/.ruff.toml +++ /dev/null @@ -1,48 +0,0 @@ -# The contents of this file is based on https://github.com/home-assistant/core/blob/dev/pyproject.toml - -target-version = "py312" - -lint.select = [ - "B007", # Loop control variable {name} not used within loop body - "B014", # Exception handler with duplicate exception - "C", # complexity - "D", # docstrings - "E", # pycodestyle - "F", # pyflakes/autoflake - "ICN001", # import concentions; {name} should be imported as {asname} - "PGH004", # Use specific rule codes when using noqa - "PLC0414", # Useless import alias. Import alias does not rename original package. - "SIM105", # Use contextlib.suppress({exception}) instead of try-except-pass - "SIM117", # Merge with-statements that use the same scope - "SIM118", # Use {key} in {dict} instead of {key} in {dict}.keys() - "SIM201", # Use {left} != {right} instead of not {left} == {right} - "SIM212", # Use {a} if {a} else {b} instead of {b} if not {a} else {a} - "SIM300", # Yoda conditions. Use 'age == 42' instead of '42 == age'. - "SIM401", # Use get from dict with default instead of an if block - "T20", # flake8-print - "TRY004", # Prefer TypeError exception for invalid type - "RUF006", # Store a reference to the return value of asyncio.create_task - "UP", # pyupgrade - "W", # pycodestyle -] - -lint.ignore = [ - "D202", # No blank lines allowed after function docstring - "D203", # 1 blank line required before class docstring - "D213", # Multi-line docstring summary should start at the second line - "D404", # First word of the docstring should not be This - "D406", # Section name should end with a newline - "D407", # Section name underlining - "D411", # Missing blank line before section - "E501", # line too long - "E731", # do not assign a lambda expression, use a def -] - -[lint.flake8-pytest-style] -fixture-parentheses = false - -[lint.pyupgrade] -keep-runtime-typing = true - -[lint.mccabe] -max-complexity = 25 diff --git a/pyproject.toml b/pyproject.toml index 04a3fc6..93fa65c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,7 @@ Changelog = "https://github.com/andrew-codechimp/HA-Hive-Local-Thermostat/releas build-backend = "poetry.core.masonry.api" requires = ["poetry-core"] -[tool.ruff] +[tool.lint.ruff] ignore = [ "ANN101", # Self... explanatory "ANN401", # Opiniated warning on disallowing dynamically typed expressions @@ -46,6 +46,16 @@ ignore = [ "D213", # Conflicts with other rules "TID252", # Relative imports "RUF012", # Just broken + "D202", # No blank lines allowed after function docstring + "D203", # 1 blank line required before class docstring + "D213", # Multi-line docstring summary should start at the second line + "D404", # First word of the docstring should not be This + "D406", # Section name should end with a newline + "D407", # Section name underlining + "D411", # Missing blank line before section + "E501", # line too long + "E731", # do not assign a lambda expression, use a def + # Formatter conflicts "COM812", @@ -62,7 +72,7 @@ ignore = [ select = ["ALL"] src = ["custom_components/hive_local_thermostat"] -[tool.ruff.flake8-import-conventions.extend-aliases] +[tool.link.flake8-import-conventions.extend-aliases] "homeassistant.helpers.area_registry" = "ar" "homeassistant.helpers.config_validation" = "cv" "homeassistant.helpers.device_registry" = "dr" @@ -70,7 +80,7 @@ src = ["custom_components/hive_local_thermostat"] "homeassistant.helpers.issue_registry" = "ir" voluptuous = "vol" -[tool.ruff.isort] +[tool.lint.isort] force-sort-within-sections = true known-first-party = ["homeassistant"] combine-as-imports = true @@ -106,7 +116,7 @@ check_untyped_defs = true disallow_any_generics = true # disallow_incomplete_defs = true disallow_subclassing_any = true -disallow_untyped_calls = true +# disallow_untyped_calls = true disallow_untyped_decorators = true # disallow_untyped_defs = true no_implicit_optional = true @@ -117,3 +127,6 @@ warn_redundant_casts = true warn_return_any = true warn_unused_configs = true warn_unused_ignores = true + +[tool.ruff.lint.mccabe] +max-complexity = 25