diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 514379cd2..d6afa00c9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -95,18 +95,6 @@ repos: # want. entry: ghcr.io/hadolint/hadolint hadolint - - id: ruff-check - name: Ruff check - entry: ruff check - language: system - types: [python] - - - id: ruff-format-check - name: Ruff format check - entry: ruff format --check - language: system - types: [python] - - id: ruff-check-fix name: Ruff check fix entry: ruff check --fix @@ -125,13 +113,6 @@ repos: language: system types: [rst] - - id: pyproject-fmt-check - name: pyproject-fmt check - entry: pyproject-fmt --check - language: system - types: [toml] - files: pyproject.toml - - id: pyproject-fmt-fix name: pyproject-fmt entry: pyproject-fmt diff --git a/pyproject.toml b/pyproject.toml index 17c1b4c51..e808f250c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,252 +1,16 @@ -[tool.pylint] - - [tool.pylint.'MASTER'] - - # Pickle collected data for later comparisons. - persistent = true - - # Use multiple processes to speed up Pylint. - jobs = 0 - - # List of plugins (as comma separated values of python modules names) to load, - # usually to register additional checkers. - # See https://chezsoi.org/lucas/blog/pylint-strict-base-configuration.html. - # We do not use the plugins: - # - pylint.extensions.code_style - # - pylint.extensions.magic_value - # - pylint.extensions.while_used - # as they seemed to get in the way. - load-plugins = [ - 'pylint.extensions.bad_builtin', - 'pylint.extensions.comparison_placement', - 'pylint.extensions.consider_refactoring_into_while_condition', - 'pylint.extensions.docparams', - 'pylint.extensions.dunder', - 'pylint.extensions.eq_without_hash', - 'pylint.extensions.for_any_all', - 'pylint.extensions.mccabe', - 'pylint.extensions.no_self_use', - 'pylint.extensions.overlapping_exceptions', - 'pylint.extensions.private_import', - 'pylint.extensions.redefined_loop_name', - 'pylint.extensions.redefined_variable_type', - 'pylint.extensions.set_membership', - 'pylint.extensions.typing', - ] - - [tool.pylint.'MESSAGES CONTROL'] - - # Enable the message, report, category or checker with the given id(s). You can - # either give multiple identifier separated by comma (,) or put this option - # multiple time (only on the command line, not in the configuration file where - # it should appear only once). See also the "--disable" option for examples. - enable = [ - 'bad-inline-option', - 'deprecated-pragma', - 'file-ignored', - 'spelling', - 'use-symbolic-message-instead', - 'useless-suppression', - ] - - - # Disable the message, report, category or checker with the given id(s). You - # can either give multiple identifiers separated by comma (,) or put this - # option multiple times (only on the command line, not in the configuration - # file where it should appear only once).You can also use "--disable=all" to - # disable everything first and then reenable specific checks. For example, if - # you want to run only the similarities checker, you can use "--disable=all - # --enable=similarities". If you want to run only the classes checker, but have - # no Warning level messages displayed, use"--disable=all --enable=classes - # --disable=W" - - disable = [ - # Style issues that we can deal with ourselves - 'too-few-public-methods', - 'too-many-ancestors', - 'too-many-locals', - 'too-many-arguments', - 'too-many-instance-attributes', - 'too-many-return-statements', - 'too-many-lines', - 'too-many-statements', - 'locally-disabled', - # Let flake8 handle long lines - 'line-too-long', - # Let flake8 handle unused imports - 'unused-import', - # Let isort deal with sorting - 'ungrouped-imports', - # We don't need everything to be documented because of mypy - 'missing-type-doc', - 'missing-return-type-doc', - # Too difficult to please - 'duplicate-code', - # Let isort handle imports - 'wrong-import-order', - ] - - [tool.pylint.'FORMAT'] - - # Allow the body of an if to be on the same line as the test if there is no - # else. - single-line-if-stmt = false - - [tool.pylint.'SPELLING'] - - # Spelling dictionary name. Available dictionaries: none. To make it working - # install python-enchant package. - spelling-dict = 'en_US' - - # A path to a file that contains private dictionary; one word per line. - spelling-private-dict-file = 'spelling_private_dict.txt' - - # Tells whether to store unknown words to indicated private dictionary in - # --spelling-private-dict-file option instead of raising a message. - spelling-store-unknown-words = 'no' - -[tool.coverage.run] - -branch = true - -[tool.coverage.report] - -exclude_also = [ - "if TYPE_CHECKING:", - "class .*\\bProtocol\\):", -] - -[tool.pytest.ini_options] - -xfail_strict = true -log_cli = true -addopts = ["--strict-markers"] -markers = ["requires_docker_build"] - -# Options for pytest-retry. -retries = 10 -retry_delay = 10 -cumulative_timing = false - -[tool.check-manifest] - -ignore = [ - "*.enc", - "admin/**", - "readthedocs.yaml", - "CHANGELOG.rst", - "CODE_OF_CONDUCT.rst", - "CONTRIBUTING.rst", - "LICENSE", - "Makefile", - "ci", - "ci/**", - "codecov.yaml", - "docs", - "docs/**", - ".git_archival.txt", - "spelling_private_dict.txt", - "tests", - "tests/**", - "vuforia_secrets.env.example", - "lint.mk", - "src/mock_vws/_flask_server/Dockerfile", - "secrets.tar.gpg", -] - -[tool.mypy] - -strict = true -plugins = ["pydantic.mypy"] - -[tool.pydantic-mypy] -init_forbid_extra = true -init_typed = true -warn_required_dynamic_aliases = true -warn_untyped_fields = true - -[tool.doc8] - -max_line_length = 2000 -ignore_path = [ - "./.eggs", - "./docs/build", - "./docs/build/spelling/output.txt", - "./node_modules", - "./src/*.egg-info/", - "./src/*/_setuptools_scm_version.txt", -] - -[tool.setuptools_scm] - -# We use a fallback version like -# https://github.com/pypa/setuptools_scm/issues/77 so that we do not -# error in the Docker build stage of the release pipeline. -# -# This must be a PEP 440 compliant version. -fallback_version = "0.0.0" - [build-system] build-backend = "setuptools.build_meta" requires = [ "pip", "setuptools", - "setuptools_scm[toml]==7.1", + "setuptools-scm[toml]==7.1", "wheel", ] -[tool.ruff] -line-length = 79 -target-version = "py311" - -[tool.ruff.lint] -select = ["ALL"] - -ignore = [ - # We do not annotate the type of 'self', or 'cls'. - "ANN101", - "ANN102", - # Ruff warns that this conflicts with the formatter. - "COM812", - # Allow our chosen docstring line-style - no one-line summary. - "D200", - "D205", - "D212", - "D415", - # Ruff warns that this conflicts with the formatter. - "ISC001", - # Ignore "too-many-*" errors as they seem to get in the way more than - # helping. - "PLR0913", - # Allow 'assert' in tests as it is the standard for pytest. - # Also, allow 'assert' in other code as it is the standard for Python type hint - # narrowing - see - # https://mypy.readthedocs.io/en/stable/type_narrowing.html#type-narrowing-expressions. - "S101", -] - -# Do not automatically remove commented out code. -# We comment out code during development, and with VSCode auto-save, this code -# is sometimes annoyingly removed. -unfixable = ["ERA001"] - -[tool.ruff.lint.pydocstyle] -convention = "google" - -[tool.ruff.lint.per-file-ignores] -"tests/**" = [ - # Allow possible hardcoded passwords in tests. - "S105", - "S106", -] - -[tool.distutils.bdist_wheel] -universal = true - [project] name = "vws-python-mock" description = "A mock for the Vuforia Web Services (VWS) API." -readme = { file = "README.rst", content-type = "text/x-rst"} +readme = { file = "README.rst", content-type = "text/x-rst" } keywords = [ "client", "fake", @@ -255,7 +19,9 @@ keywords = [ "vws", ] license = { file = "LICENSE" } -authors = [ { name = "Adam Dangoor", email = "adamdangoor@gmail.com"} ] +authors = [ + { name = "Adam Dangoor", email = "adamdangoor@gmail.com" }, +] requires-python = ">=3.12" classifiers = [ "Development Status :: 5 - Production/Stable", @@ -271,18 +37,17 @@ dynamic = [ ] dependencies = [ "flask", - "Pillow", + "pillow", "piq", "pydantic-settings", "requests", "requests-mock", "torchvision", - 'tzdata; sys_platform == "win32"', + "tzdata; sys_platform=='win32'", "vws-auth-tools", - "Werkzeug", + "werkzeug", ] -[project.optional-dependencies] -dev = [ +optional-dependencies.dev = [ "actionlint-py==1.6.27.13", "check-manifest==0.49", "check-wheel-contents==0.6.0", @@ -298,7 +63,7 @@ dev = [ "pydocstyle==6.3", "pyenchant==3.2.2", "pylint==3.2.0", - "pyproject-fmt==1.8.0", + "pyproject-fmt==2.1.1", "pyright==1.1.362", "pyroma==4.2", "pytest==8.2.0", @@ -306,54 +71,299 @@ dev = [ "pytest-retry==1.6.3", "pytest-xdist==3.6.1", "python-dotenv==1.0.1", - "PyYAML==6.0.1", + "pyyaml==6.0.1", "requests-mock-flask==2023.5.14", "ruff==0.4.4", - "Sphinx==7.3.7", + "sphinx==7.3.7", + "sphinx-paramlinks==0.6", "sphinx-prompt==1.8", - "Sphinx-Substitution-Extensions==2024.2.25", + "sphinx-substitution-extensions==2024.2.25", "sphinx-toolbox==3.5", - "sphinx_paramlinks==0.6", "sphinxcontrib-httpdomain==1.8.1", "sphinxcontrib-spelling==8", "sybil==6.1.1", "tenacity==8.3.0", "torch==2.3.0", "types-docker==7.0.0.20240515", - "types-Pillow==10.2.0.20240511", - "types-PyYAML==6.0.12.20240311", + "types-pillow==10.2.0.20240511", + "types-pyyaml==6.0.12.20240311", "types-requests==2.31.0.20240406", "urllib3==2.2.1", "vulture==2.11", "vws-python==2024.2.19", - "VWS-Test-Fixtures==2023.3.5", + "vws-test-fixtures==2023.3.5", "vws-web-tools==2023.12.26", ] -[project.urls] -Documentation = "https://vws-python-mock.readthedocs.io" -Source = "https://github.com/VWS-Python/vws-python-mock" +urls.Documentation = "https://vws-python-mock.readthedocs.io" +urls.Source = "https://github.com/VWS-Python/vws-python-mock" [tool.setuptools] zip-safe = false [tool.setuptools.packages.find] -where = ["src"] +where = [ + "src", +] [tool.setuptools.package-data] -mock_vws = ["py.typed"] +mock_vws = [ + "py.typed", +] + +[tool.distutils.bdist_wheel] +universal = true + +[tool.setuptools_scm] + +# We use a fallback version like +# https://github.com/pypa/setuptools_scm/issues/77 so that we do not +# error in the Docker build stage of the release pipeline. +# +# This must be a PEP 440 compliant version. +fallback_version = "0.0.0" + +[tool.ruff] +target-version = "py311" + +line-length = 79 +lint.select = [ + "ALL", +] +lint.per-file-ignores."tests/**" = [ + # Allow possible hardcoded passwords in tests. + "S105", + "S106", +] +lint.unfixable = [ + "ERA001", +] +lint.pydocstyle.convention = "google" +lint.ignore = [ + # We do not annotate the type of 'self', or 'cls'. + "ANN101", + "ANN102", + # Ruff warns that this conflicts with the formatter. + "COM812", + # Allow our chosen docstring line-style - no one-line summary. + "D200", + "D205", + "D212", + "D415", + # Ruff warns that this conflicts with the formatter. + "ISC001", + # Ignore "too-many-*" errors as they seem to get in the way more than + # helping. + "PLR0913", + # Allow 'assert' in tests as it is the standard for pytest. + # Also, allow 'assert' in other code as it is the standard for Python type hint + # narrowing - see + # https://mypy.readthedocs.io/en/stable/type_narrowing.html#type-narrowing-expressions. + "S101", +] +# Do not automatically remove commented out code. +# We comment out code during development, and with VSCode auto-save, this code +# is sometimes annoyingly removed. + +[tool.pylint] + +[tool.pylint.'MASTER'] + +# Pickle collected data for later comparisons. +persistent = true + +# Use multiple processes to speed up Pylint. +jobs = 0 + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +# See https://chezsoi.org/lucas/blog/pylint-strict-base-configuration.html. +# We do not use the plugins: +# - pylint.extensions.code_style +# - pylint.extensions.magic_value +# - pylint.extensions.while_used +# as they seemed to get in the way. +load-plugins = [ + 'pylint.extensions.bad_builtin', + 'pylint.extensions.comparison_placement', + 'pylint.extensions.consider_refactoring_into_while_condition', + 'pylint.extensions.docparams', + 'pylint.extensions.dunder', + 'pylint.extensions.eq_without_hash', + 'pylint.extensions.for_any_all', + 'pylint.extensions.mccabe', + 'pylint.extensions.no_self_use', + 'pylint.extensions.overlapping_exceptions', + 'pylint.extensions.private_import', + 'pylint.extensions.redefined_loop_name', + 'pylint.extensions.redefined_variable_type', + 'pylint.extensions.set_membership', + 'pylint.extensions.typing', +] + +[tool.pylint.'MESSAGES CONTROL'] + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +enable = [ + 'bad-inline-option', + 'deprecated-pragma', + 'file-ignored', + 'spelling', + 'use-symbolic-message-instead', + 'useless-suppression', +] + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once).You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use"--disable=all --enable=classes +# --disable=W" + +disable = [ + # Style issues that we can deal with ourselves + 'too-few-public-methods', + 'too-many-ancestors', + 'too-many-locals', + 'too-many-arguments', + 'too-many-instance-attributes', + 'too-many-return-statements', + 'too-many-lines', + 'too-many-statements', + 'locally-disabled', + # Let flake8 handle long lines + 'line-too-long', + # Let flake8 handle unused imports + 'unused-import', + # Let isort deal with sorting + 'ungrouped-imports', + # We don't need everything to be documented because of mypy + 'missing-type-doc', + 'missing-return-type-doc', + # Too difficult to please + 'duplicate-code', + # Let isort handle imports + 'wrong-import-order', +] + +[tool.pylint.'FORMAT'] + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt = false + +[tool.pylint.'SPELLING'] + +# Spelling dictionary name. Available dictionaries: none. To make it working +# install python-enchant package. +spelling-dict = 'en_US' + +# A path to a file that contains private dictionary; one word per line. +spelling-private-dict-file = 'spelling_private_dict.txt' + +# Tells whether to store unknown words to indicated private dictionary in +# --spelling-private-dict-file option instead of raising a message. +spelling-store-unknown-words = 'no' + +[tool.check-manifest] + +ignore = [ + "*.enc", + "admin/**", + "readthedocs.yaml", + "CHANGELOG.rst", + "CODE_OF_CONDUCT.rst", + "CONTRIBUTING.rst", + "LICENSE", + "Makefile", + "ci", + "ci/**", + "codecov.yaml", + "docs", + "docs/**", + ".git_archival.txt", + "spelling_private_dict.txt", + "tests", + "tests/**", + "vuforia_secrets.env.example", + "lint.mk", + "src/mock_vws/_flask_server/Dockerfile", + "secrets.tar.gpg", +] + +[tool.deptry] +pep621_dev_dependency_groups = [ + "dev", +] + +[tool.deptry.per_rule_ignores] +# tzdata is needed on Windows for zoneinfo to work. +# See https://docs.python.org/3/library/zoneinfo.html#data-sources. +DEP002 = [ + "tzdata", +] [tool.pyproject-fmt] indent = 4 keep_full_version = true +[tool.pytest.ini_options] + +xfail_strict = true +log_cli = true +addopts = [ + "--strict-markers", +] +markers = [ + "requires_docker_build", +] + +# Options for pytest-retry. +retries = 10 +retry_delay = 10 +cumulative_timing = false + +[tool.coverage.run] + +branch = true + +[tool.coverage.report] + +exclude_also = [ + "if TYPE_CHECKING:", + "class .*\\bProtocol\\):", +] + +[tool.mypy] + +strict = true +plugins = [ + "pydantic.mypy", +] + [tool.pyright] reportUnnecessaryTypeIgnoreComment = true typeCheckingMode = "strict" -[tool.deptry] -pep621_dev_dependency_groups = ["dev"] +[tool.pydantic-mypy] +init_forbid_extra = true +init_typed = true +warn_required_dynamic_aliases = true +warn_untyped_fields = true -[tool.deptry.per_rule_ignores] -# tzdata is needed on Windows for zoneinfo to work. -# See https://docs.python.org/3/library/zoneinfo.html#data-sources. -DEP002 = ["tzdata"] +[tool.doc8] + +max_line_length = 2000 +ignore_path = [ + "./.eggs", + "./docs/build", + "./docs/build/spelling/output.txt", + "./node_modules", + "./src/*.egg-info/", + "./src/*/_setuptools_scm_version.txt", +]