diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index ac401a14..00000000 --- a/.coveragerc +++ /dev/null @@ -1,3 +0,0 @@ -[report] -show_missing = True -fail_under = 80 diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 4dbb28ad..a37df242 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -13,7 +13,7 @@ jobs: strategy: matrix: python-version: - - "3.12" + - "3.13" steps: - name: 📥 Checkout the repository diff --git a/pylintrc b/pylintrc deleted file mode 100644 index b2b29679..00000000 --- a/pylintrc +++ /dev/null @@ -1,50 +0,0 @@ -[MASTER] -ignore=tests -# Use a conservative default here; 2 should speed up most setups and not hurt -# any too bad. Override on command line as appropriate. -jobs=2 -persistent=no - -[BASIC] -good-names=id,i,j,k,ex,Run,_,fp -max-attributes=15 -argument-naming-style=snake_case -attr-naming-style=snake_case - -[MESSAGES CONTROL] -# Reasons disabled: -# locally-disabled - it spams too much -# too-many-* - are not enforced for the sake of readability -# too-few-* - same as too-many-* -# import-outside-toplevel - TODO -disable= - duplicate-code, - fixme, - import-outside-toplevel, - locally-disabled, - too-few-public-methods, - too-many-arguments, - too-many-public-methods, - too-many-instance-attributes, - too-many-branches, - too-many-statements, - broad-except, - too-many-lines, - too-many-locals, - unexpected-keyword-arg, - abstract-method, - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=8 - -[REPORTS] -score=no - -[TYPECHECK] -# For attrs -ignored-classes=_CountingAttr - -[FORMAT] -expected-line-ending-format=LF \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 445f13e8..58c5db1d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,32 @@ [tool.black] -target-version = ["py38"] +target-version = ["py311", "py312", "py313"] exclude = 'generated' +[tool.coverage.report] +show_missing = true +fail_under = 80 + +[tool.flake8] +exclude = [ + ".venv", + ".git", + ".tox", + "docs", + "venv", + "bin", + "lib", + "deps", + "build", +] +max-line-length = 88 +ignore = [ + "E501", # line too long + "W503", # Line break occurred before a binary operator + "E203", # Whitespace before ':' + "D202", # No blank lines allowed after function docstring + "W504", # Line break after binary operator +] + [tool.isort] # https://github.com/PyCQA/isort/wiki/isort-Settings profile = "black" @@ -15,11 +40,26 @@ forced_separate = [ "tests", ] combine_as_imports = true +multi_line_output = 3 +include_trailing_comma = true +force_grid_wrap = 0 +use_parentheses = true +line_length = 88 -[tool.pylint.MASTER] -ignore = [ - "tests", -] +[tool.mypy] +python_version = "3.13" +show_error_codes = true +ignore_errors = true +follow_imports = "silent" +ignore_missing_imports = true +warn_incomplete_stub = true +warn_redundant_casts = true +warn_unused_configs = true + +[tool.pylint] +ignore = ["tests"] +jobs = 2 +persistent = false # Use a conservative default here; 2 should speed up most setups and not hurt # any too bad. Override on command line as appropriate. # Disabled for now: https://github.com/PyCQA/pylint/issues/3584 @@ -27,13 +67,12 @@ ignore = [ load-plugins = [ "pylint_strict_informational", ] -persistent = false extension-pkg-whitelist = [ "ciso8601", "cv2", ] -[tool.pylint.BASIC] +[tool.pylint.basic] good-names = [ "_", "ev", @@ -46,8 +85,21 @@ good-names = [ "Run", "T", ] +max-attributes = 15 +argument-naming-style = "snake_case" +attr-naming-style = "snake_case" -[tool.pylint."MESSAGES CONTROL"] +[tool.pylint.exceptions] +overgeneral-exceptions = [ + "BaseException", + "Exception", + "HomeAssistantError", +] + +[tool.pylint.format] +expected-line-ending-format = "LF" + +[tool.pylint."messages control"] # Reasons disabled: # format - handled by black # locally-disabled - it spams too much @@ -62,17 +114,21 @@ good-names = [ # too-many-ancestors - it's too strict. # wrong-import-order - isort guards this disable = [ - "format", "abstract-class-little-used", "abstract-method", + "broad-except", "cyclic-import", "duplicate-code", + "fixme", + "format", + "import-outside-toplevel", "inconsistent-return-statements", "locally-disabled", "not-context-manager", "too-few-public-methods", "too-many-ancestors", "too-many-arguments", + "too-many-boolean-expressions", "too-many-branches", "too-many-instance-attributes", "too-many-lines", @@ -80,7 +136,7 @@ disable = [ "too-many-public-methods", "too-many-return-statements", "too-many-statements", - "too-many-boolean-expressions", + "unexpected-keyword-arg", "unused-argument", "wrong-import-order", ] @@ -89,23 +145,14 @@ enable = [ "use-symbolic-message-instead", ] -[tool.pylint.REPORTS] -score = false - -[tool.pylint.TYPECHECK] -ignored-classes = [ - "_CountingAttr", # for attrs -] +[tool.pylint.refactoring] +max-nested-blocks = 8 -[tool.pylint.FORMAT] -expected-line-ending-format = "LF" +[tool.pylint.reports] +score = false -[tool.pylint.EXCEPTIONS] -overgeneral-exceptions = [ - "BaseException", - "Exception", - "HomeAssistantError", -] +[tool.pylint.typecheck] +ignored-classes = ["_CountingAttr"] [tool.pytest.ini_options] testpaths = [ @@ -115,3 +162,53 @@ norecursedirs = [ ".git", "testing_config", ] +asyncio_mode = "auto" +asyncio_default_fixture_loop_scope = "function" + +[tool.tox.gh-actions] +python = """ + 3.11: py311 + 3.12: py312 + 3.13: py313 +""" + +[tool.tox] +skipsdist = true +requires = ["tox>=4.19"] +env_list = ["py311", "py312", "py313", "lint", "mypy"] +skip_missing_interpreters = true + +[tool.tox.env_run_base] +description = "Run tests with pytest" +commands = [ + "pytest -v --asyncio-mode=auto --timeout=30 --cov=custom_components/keymaster --cov-report=xml {posargs}", +] +deps = [ + "-rrequirements_test.txt", +] + +[tool.tox.env.lint] +description = "Lint code using black, flake8, pylint, and pydocstyle" +basepython = "python3" +ignore_errors = true +commands = [ + "black --check custom_components/", + "black --check tests/", + "flake8 custom_components/keymaster", + "pylint custom_components/keymaster", + "pydocstyle custom_components/keymaster tests", +] +deps = [ + "-rrequirements_test.txt", +] + +[tool.tox.env.mypy] +description = "Run mypy for type-checking" +basepython = "python3" +ignore_errors = true +commands = [ + "mypy custom_components/keymaster", +] +deps = [ + "-rrequirements_test.txt", +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index c2282f42..00000000 --- a/setup.cfg +++ /dev/null @@ -1,32 +0,0 @@ -[mypy] -python_version = 3.12 -show_error_codes = true -ignore_errors = true -follow_imports = silent -ignore_missing_imports = true -warn_incomplete_stub = true -warn_redundant_casts = true -warn_unused_configs = true - -[flake8] -exclude = .venv,.git,.tox,docs,venv,bin,lib,deps,build -# To work with Black -max-line-length = 88 -# E501: line too long -# W503: Line break occurred before a binary operator -# E203: Whitespace before ':' -# D202 No blank lines allowed after function docstring -# W504 line break after binary operator -ignore = - E501, - W503, - E203, - D202, - W504 - -[isort] -multi_line_output = 3 -include_trailing_comma = True -force_grid_wrap = 0 -use_parentheses = True -line_length = 88 diff --git a/tox.ini b/tox.ini deleted file mode 100644 index d3491069..00000000 --- a/tox.ini +++ /dev/null @@ -1,36 +0,0 @@ -[tox] -skipsdist = true -envlist = py310, py311, py312, lint, mypy -skip_missing_interpreters = True - -[gh-actions] -python = - 3.10: py310 - 3.11: py311 - 3.12: py312, lint, mypy - -[testenv] -commands = - pytest --asyncio-mode=auto --timeout=30 --cov=custom_components/keymaster --cov-report=xml {posargs} -deps = - -rrequirements_test.txt - -[testenv:lint] -basepython = python3 -ignore_errors = True -commands = - black --check custom_components/ - black --check tests/ - flake8 custom_components/keymaster - pylint custom_components/keymaster - pydocstyle custom_components/keymaster tests -deps = - -rrequirements_test.txt - -[testenv:mypy] -basepython = python3 -ignore_errors = True -commands = - mypy custom_components/keymaster -deps = - -rrequirements_test.txt