From 7763cc454d686d51bf2e0ccc1f2ccf7d62a0d625 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 10:36:44 +0200 Subject: Merging upstream version 0.14.0. Signed-off-by: Daniel Baumann --- pyproject.toml | 210 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 153 insertions(+), 57 deletions(-) (limited to 'pyproject.toml') diff --git a/pyproject.toml b/pyproject.toml index 9a23db3..36ed176 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "anta" -version = "v0.13.0" +version = "v0.14.0" readme = "docs/README.md" authors = [{ name = "Khelil Sator", email = "ksator@arista.com" }] maintainers = [ @@ -22,12 +22,12 @@ dependencies = [ "click~=8.1.6", "click-help-colors~=0.9", "cvprac~=1.3.1", - "pydantic>=2.1.1,<2.7.0", + "pydantic>=2.6.1,<2.8.0", "pydantic-extra-types>=2.1.0", + "eval-type-backport~=0.1.3", # Support newer typing features in older Python versions (required until Python 3.9 support is removed) "PyYAML~=6.0", "requests~=2.31.0", "rich>=13.5.2,<13.8.0", - "rich>=13.5.2,<13.8.0", "asyncssh>=2.13.2,<2.15.0", "Jinja2~=3.1.2", ] @@ -41,7 +41,6 @@ classifiers = [ "Intended Audience :: Information Technology", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -51,19 +50,17 @@ classifiers = [ "Topic :: Software Development :: Testing", "Topic :: System :: Networking", ] -requires-python = ">=3.8" +requires-python = ">=3.9" [project.optional-dependencies] dev = [ "bumpver==2023.1129", - "black==24.2.0", - "flake8==7.0.0", - "isort==5.13.2", - "mypy~=1.7", + "codespell~=2.2.6", + "mypy~=1.9", "mypy-extensions~=1.0", "pre-commit>=3.3.3", "pylint>=2.17.5", - "ruff>=0.0.280", + "ruff~=0.3.5", "pytest>=7.4.0", "pytest-asyncio>=0.21.1", "pytest-cov>=4.1.0", @@ -79,6 +76,7 @@ dev = [ "yamllint>=1.32.0", ] doc = [ + "fontawesome_markdown", "mkdocs>=1.3.1", "mkdocs-autorefs>=0.4.1", "mkdocs-bootswatch>=1.1", @@ -87,9 +85,8 @@ doc = [ "mkdocs-material>=8.3.9", "mkdocs-material-extensions>=1.0.3", "mkdocstrings[python]>=0.20.0", - "fontawesome_markdown", "mike==2.0.0", - "griffe==0.41.1" + "griffe", ] [project.urls] @@ -100,7 +97,6 @@ Contributing = "https://www.anta.ninja/main/contribution/" [project.scripts] anta = "anta.cli:cli" - ################################ # Tools ################################ @@ -112,7 +108,7 @@ namespaces = false # Version ################################ [tool.bumpver] -current_version = "0.13.0" +current_version = "0.14.0" version_pattern = "MAJOR.MINOR.PATCH" commit_message = "bump: Version {old_version} -> {new_version}" commit = true @@ -125,21 +121,6 @@ push = false "docs/contribution.md" = ["anta {version}"] "docs/requirements-and-installation.md " = ["anta, version v{version}"] -################################ -# Linting -################################ -[tool.isort] -profile = "black" -line_length = 165 - -[tool.black] -line-length = 165 -force-exclude = """ -( -.*data.py| -) -""" - ################################ # Typing # mypy as per https://pydantic-docs.helpmanual.io/mypy_plugin/#enabling-the-plugin @@ -173,25 +154,20 @@ warn_untyped_fields = true # Testing ################################ [tool.pytest.ini_options] -# TODO - may need cov-append for Tox # When run from anta directory this will read cov-config from pyproject.toml -addopts = "-ra -q -s -vv --capture=tee-sys --cov --cov-report term:skip-covered --color yes" +addopts = "-ra -q -vv --cov --cov-report term:skip-covered --color yes" log_level = "WARNING" -log_cli = true render_collapsed = true -filterwarnings = [ - "ignore::urllib3.exceptions.InsecureRequestWarning" -] testpaths = ["tests"] [tool.coverage.run] branch = true source = ["anta"] parallel = true -omit = [ +omit= [ # omit aioeapi patch - "anta/aioeapi.py", - ] + "anta/aioeapi.py", +] [tool.coverage.report] # Regexes for lines to exclude from consideration @@ -237,12 +213,11 @@ envlist = clean, lint, type, - py{38,39,310,311,312}, + py{39,310,311,312}, report [gh-actions] python = - 3.8: py38 3.9: py39 3.10: py310 3.11: erase, py311, report @@ -259,9 +234,8 @@ commands = [testenv:lint] description = Check the code style commands = - black --check --diff --color . - isort --check --diff --color . - flake8 --max-line-length=165 --config=/dev/null anta tests + ruff check . + ruff format . --check pylint anta pylint tests @@ -289,17 +263,10 @@ commands = depends = py311 """ -# TRYING RUFF - NOT ENABLED IN CI NOR PRE-COMMIT +################################ +# Ruff +################################ [tool.ruff] -# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default. -# select = ["E", "F"] -# select all cause we like being suffering -select = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"] -ignore = [] - -# Allow autofix for all enabled rules (when `--fix`) is provided. -fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"] -unfixable = [] # Exclude a variety of commonly ignored directories. exclude = [ @@ -309,32 +276,161 @@ exclude = [ ".git", ".git-rewrite", ".hg", + ".ipynb_checkpoints", ".mypy_cache", ".nox", ".pants.d", + ".pyenv", + ".pytest_cache", ".pytype", ".ruff_cache", ".svn", ".tox", ".venv", + ".vscode", "__pypackages__", "_build", "buck-out", "build", "dist", "node_modules", + "site-packages", "venv", + ".github", + "aioeapi.py" # Remove this when https://github.com/jeremyschulman/aio-eapi/pull/13 is merged ] -# Same as Black. line-length = 165 +# Assume Python 3.9 as this is the lowest supported version for ANTA +target-version = "py39" + +[tool.ruff.lint] +# select all cause we like being suffering +select = ["ALL"] +ignore = [ + "ANN101", # Missing type annotation for `self` in method - we know what self is.. + "D203", # Ignoring conflicting D* warnings - one-blank-line-before-class + "D213", # Ignoring conflicting D* warnings - multi-line-summary-second-line + "COM812", # Ignoring conflicting rules that may cause conflicts when used with the formatter + "ISC001", # Ignoring conflicting rules that may cause conflicts when used with the formatter + "TD002", # We don't have require authors in TODO + "TD003", # We don't have an issue link for all TODOs today + "FIX002", # Line contains TODO - ignoring for ruff for now + "F821", # Disable undefined-name until resolution of #10451 +] + +# Allow autofix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + # Allow unused variables when underscore-prefixed. dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" -# Assume Python 3.8 as this is the lowest supported version for ANTA -target-version = "py38" +[tool.ruff.lint.pydocstyle] +convention = "numpy" + +[tool.ruff.lint.pylint] +# These settings are used to configure pylint rules run in ruff. In order to keep sane and while +# we have not removed pylint completely, these settings should be kept in sync with our pylintrc file. +# https://github.com/astral-sh/ruff/issues/970 +max-branches = 13 -[tool.ruff.mccabe] +[tool.ruff.lint.mccabe] # Unlike Flake8, default to a complexity level of 10. max-complexity = 10 + +[tool.ruff.lint.pep8-naming] +"ignore-names" = [ + "RICH_COLOR_PALETTE" +] + +[tool.ruff.lint.flake8-type-checking] +# These classes require that type annotations be available at runtime +runtime-evaluated-base-classes = ["pydantic.BaseModel", "anta.models.AntaTest.Input"] + + +[tool.ruff.lint.per-file-ignores] +"tests/*" = [ + "S101", # Complains about asserts in units and libs. + "SLF001", # Lots of private member accessed for test purposes +] +"tests/units/*" = [ + "BLE001", # Do not catch blind exception: `Exception` - already disabling this in pylint + "FBT001", # Boolean-typed positional argument in function definition + "PLR0913", # Too many arguments to function call (8 > 5) + "PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable + "S105", # Passwords are indeed hardcoded in tests + "S106", # Passwords are indeed hardcoded in tests + "S108", # Probable insecure usage of temporary file or directory +] +"tests/units/anta_tests/test_interfaces.py" = [ + "S104", # False positive for 0.0.0.0 bindings in test inputs +] +"anta/*" = [ + "BLE001", # Do not catch blind exception: `Exception` - caught by other linter + "TRY400", # Use `logging.exception` instead of `logging.error` - we know what we are doing +] +"anta/cli/exec/utils.py" = [ + "SLF001", # TODO: some private members, lets try to fix +] +"anta/cli/*" = [ + "PLR0913", # Allow more than 5 input arguments in CLI functions + "ANN401", # TODO: Check if we can update the Any type hints in the CLI +] +"anta/tests/field_notices.py" = [ + "PLR2004", # Magic value used in comparison, consider replacing 2131 with a constant variable - Field notice IDs are magic values + "C901", # TODO: test function is too complex, needs a refactor + "PLR0911", # TODO: Too many return statements, same as above needs a refactor +] +"anta/decorators.py" = [ + "ANN401", # Ok to use Any type hint in our decorators +] +"anta/tools.py" = [ + "ANN401", # Ok to use Any type hint in our custom get functions + "PLR0913", # Ok to have more than 5 arguments in our custom get functions +] +"anta/runner.py" = [ + "C901", # TODO: main function is too complex, needs a refactor + "PERF203", # TODO: try - except within a loop, same sa above needs a refactor +] +"anta/device.py" = [ + "PLR0913", # Ok to have more than 5 arguments in the AntaDevice classes +] +"anta/inventory/__init__.py" = [ + "PLR0913", # Ok to have more than 5 arguments in the AntaInventory class +] + +################################ +# Pylint +################################ +[tool.pylint.'MESSAGES CONTROL'] +disable = [ + "invalid-name", + "fixme" +] + +[tool.pylint.DESIGN] +max-statements=61 +max-returns=8 +max-locals=23 + +[tool.pylint.FORMAT] +max-line-length=165 +max-module-lines=1700 + +[tool.pylint.SIMILARITIES] +# making similarity lines limit a bit higher than default 4 +min-similarity-lines=10 + +[tool.pylint.TYPECHECK] +# https://stackoverflow.com/questions/49680191/click-and-pylint +signature-mutators="click.decorators.option" + +[tool.pylint.MAIN] +load-plugins="pylint_pydantic" +extension-pkg-whitelist="pydantic" +ignore-paths = [ + "^tests/units/anta_tests/.*/data.py$", + "^tests/units/anta_tests/routing/.*/data.py$", +] -- cgit v1.2.3