Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyproject-fmt unstable (2.0.4) #18

Closed
adamtheturtle opened this issue May 13, 2024 · 10 comments · Fixed by #19
Closed

pyproject-fmt unstable (2.0.4) #18

adamtheturtle opened this issue May 13, 2024 · 10 comments · Fixed by #19
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@adamtheturtle
Copy link

If I run pyproject-fmt pyproject.toml I get quite a big change. If I then run it again, I get a small diff.

pyproject.toml
[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",
    "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"}
keywords = [
    "client",
    "fake",
    "mock",
    "vuforia",
    "vws",
]
license = { file = "LICENSE" }
authors = [ { name = "Adam Dangoor", email = "adamdangoor@gmail.com"} ]
requires-python = ">=3.12"
classifiers = [
    "Development Status :: 5 - Production/Stable",
    "Environment :: Web Environment",
    "Framework :: Pytest",
    "License :: OSI Approved :: MIT License",
    "Operating System :: POSIX",
    "Programming Language :: Python :: 3 :: Only",
    "Programming Language :: Python :: 3.12",
]
dynamic = [
    "version",
]
dependencies = [
    "flask",
    "Pillow",
    "piq",
    "pydantic-settings",
    "requests",
    "requests-mock",
    "torchvision",
    'tzdata; sys_platform == "win32"',
    "vws-auth-tools",
    "Werkzeug",
]
[project.optional-dependencies]
dev = [
    "actionlint-py==1.6.27.13",
    "check-manifest==0.49",
    "check-wheel-contents==0.6.0",
    "deptry==0.16.1",
    "dirty-equals==0.7.1.post0",
    "doc8==1.1.1",
    "docker==7.0.0",
    "enum-tools[sphinx]==0.12.0",
    "freezegun==1.5.1",
    "furo==2024.5.6",
    "mypy==1.10.0",
    "pydocstyle==6.3",
    "pyenchant==3.2.2",
    "pylint==3.1.0",
    "pyproject-fmt==2.0.4",
    "pyright==1.1.362",
    "pyroma==4.2",
    "pytest==8.2.0",
    "pytest-cov==5.0.0",
    "pytest-retry==1.6.2",
    "pytest-xdist==3.6.1",
    "python-dotenv==1.0.1",
    "PyYAML==6.0.1",
    "requests-mock-flask==2023.5.14",
    "ruff==0.4.4",
    "Sphinx==7.3.7",
    "sphinx-prompt==1.8",
    "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.20240513",
    "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-web-tools==2023.12.26",
]
[project.urls]
Documentation = "https://vws-python-mock.readthedocs.io"
Source = "https://github.com/VWS-Python/vws-python-mock"

[tool.setuptools]
zip-safe = false

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
mock_vws = ["py.typed"]

[tool.pyproject-fmt]
indent = 4
keep_full_version = true

[tool.pyright]
reportUnnecessaryTypeIgnoreComment = true
typeCheckingMode = "strict"

[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"]

Small second diff:

--- pyproject.toml

+++ pyproject.toml

@@ -95,6 +95,7 @@

 ]
 urls.Documentation = "https://vws-python-mock.readthedocs.io"
 urls.Source = "https://github.com/VWS-Python/vws-python-mock"
+
 [tool.setuptools]
 zip-safe = false
@gaborbernat
Copy link
Member

PR welcome 👍

@gaborbernat gaborbernat added bug Something isn't working help wanted Extra attention is needed labels May 13, 2024
@ssbarnea
Copy link
Member

Not sure if the same bug, but this version is really messing some config files, as seen in pytest-dev/pytest#12321

@hugovk
Copy link

hugovk commented May 14, 2024

Similarly with hugovk/norwegianblue#212:

Original pyproject.toml
[build-system]
build-backend = "hatchling.build"
requires = [
  "hatch-vcs",
  "hatchling",
]

[project]
name = "norwegianblue"
description = "CLI to show end-of-life dates for a number of products"
readme = "README.md"
keywords = [
  "cli",
  "end-of-life",
  "endoflife",
  "eol",
]
license = {text = "MIT"}
authors = [{name = "Hugo van Kemenade"}]
requires-python = ">=3.8"
classifiers = [
  "Development Status :: 3 - Alpha",
  "Intended Audience :: Developers",
  "Intended Audience :: End Users/Desktop",
  "License :: OSI Approved :: MIT License",
  "Operating System :: OS Independent",
  "Programming Language :: Python :: 3 :: Only",
  "Programming Language :: Python :: 3.8",
  "Programming Language :: Python :: 3.9",
  "Programming Language :: Python :: 3.10",
  "Programming Language :: Python :: 3.11",
  "Programming Language :: Python :: 3.12",
  "Programming Language :: Python :: 3.13",
  "Programming Language :: Python :: Implementation :: CPython",
  "Programming Language :: Python :: Implementation :: PyPy",
]
dynamic = [
  "version",
]
dependencies = [
  "httpx>=0.19",
  "platformdirs",
  "prettytable>=2.4",
  "pytablewriter[html]>=0.63",
  "python-dateutil",
  "python-slugify",
  "termcolor>=2.1",
]
[project.optional-dependencies]
tests = [
  "freezegun",
  "pytest",
  "pytest-cov",
  "respx>=0.11",
]
[project.urls]
Changelog = "https://github.com/hugovk/norwegianblue/releases"
Homepage = "https://github.com/hugovk/norwegianblue"
Source = "https://github.com/hugovk/norwegianblue"
[project.scripts]
eol = "norwegianblue.cli:main"
norwegianblue = "norwegianblue.cli:main"

[tool.hatch]
version.source = "vcs"

[tool.hatch.version.raw-options]
local_scheme = "no-local-version"

[tool.ruff]
fix = true

[tool.ruff.lint]
select = [
  "C4", # flake8-comprehensions
  "E", # pycodestyle errors
  "EM", # flake8-errmsg
  "F", # pyflakes errors
  "I", # isort
  "ISC", # flake8-implicit-str-concat
  "LOG", # flake8-logging
  "PGH", # pygrep-hooks
  "RUF100", # unused noqa (yesqa)
  "UP", # pyupgrade
  "W", # pycodestyle warnings
  "YTT", # flake8-2020
]
extend-ignore = [
  "E203", # Whitespace before ':'
  "E221", # Multiple spaces before operator
  "E226", # Missing whitespace around arithmetic operator
  "E241", # Multiple spaces after ','
]

[tool.ruff.lint.isort]
known-first-party = ["norwegianblue"]
required-imports = ["from __future__ import annotations"]

[tool.pyproject-fmt]
max_supported_python = "3.13"

[tool.pytest.ini_options]
addopts = "--color=yes"

Second small diff:

diff --git a/pyproject.toml b/pyproject.toml
index 7cb4197..04d7e72 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -59,6 +59,7 @@ urls.Homepage = "https://github.com/hugovk/norwegianblue"
 urls.Source = "https://github.com/hugovk/norwegianblue"
 scripts.eol = "norwegianblue.cli:main"
 scripts.norwegianblue = "norwegianblue.cli:main"
+
 [tool.hatch]
 version.source = "vcs"

After this it is stable.

@gaborbernat
Copy link
Member

#16 should fix it

@gaborbernat
Copy link
Member

Fixed via https://github.com/tox-dev/pyproject-fmt/releases/tag/2.1.0

@blink1073
Copy link

I don't think 2.1.0 fixes the issue:

https://github.com/mongodb/mongo-python-driver/blob/328c06d4548d30ae7f4d5eaa8d3417ba73e7c05f/pyproject.toml

On the second run:

--- pyproject.toml

+++ pyproject.toml

@@ -49,6 +49,7 @@

 urls.Homepage = "https://www.mongodb.org"
 urls.Source = "https://github.com/mongodb/mongo-python-driver"
 urls.Tracker = "https://jira.mongodb.org/projects/PYTHON/issues"
+
 [tool.setuptools.dynamic]
 version = { attr = "pymongo._version.__version__" }

@@ -183,6 +184,7 @@

   "UP006",  # Use `type` instead of `Type` for type annotation"
   "UP007",  # Use `X | Y` for type annotation
 ]
+
 [tool.pytest.ini_options]
 minversion = "7"
 addopts = [

@adamtheturtle
Copy link
Author

Thank you @gaborbernat for working on this.

2.1.0 does not fix the issue with the pyproject.toml in the description.

@gaborbernat gaborbernat reopened this May 14, 2024
@gaborbernat gaborbernat transferred this issue from tox-dev/pyproject-fmt May 15, 2024
@gaborbernat
Copy link
Member

@blink1073
Copy link

Works for pymongo, thanks @gaborbernat!

@hugovk
Copy link

hugovk commented May 15, 2024

For norwegianblue as well, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants