From a1d99e4bdd6effa2f2c9a50a2f4712e7fe1823d2 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Mon, 5 Feb 2024 13:56:07 +0100 Subject: [PATCH 1/8] [pyproject.toml] Move information from setup.cfg to pyproject.toml --- .pre-commit-config.yaml | 5 ----- pyproject.toml | 50 +++++++++++++++++++++++++++++++++++++++++ setup.cfg | 31 ------------------------- 3 files changed, 50 insertions(+), 36 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 032fe8c4d..ca3b41d58 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,11 +21,6 @@ repos: hooks: - id: blacken-docs additional_dependencies: [black==24.1.1] -- repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.5.0 - hooks: - - id: setup-cfg-fmt - args: ["--max-py-version=3.12", "--include-version-classifiers"] - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.10.0 hooks: diff --git a/pyproject.toml b/pyproject.toml index 15a855ce6..6e3d3612a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,53 @@ +[project] + +name = "pytest" +dynamic = [ + "version", + "optional-dependencies", + "dependencies", + "scripts", + "requires-python" +] +description = "pytest: simple powerful testing with Python" +authors = [ + {name = "Holger Krekel"}, + {name = "Bruno Oliveira"}, + {name = "Ronny Pfannschmidt"}, + {name = "Floris Bruynooghe"}, + {name = "Brianna Laugher"}, + {name = "Florian Bruhin"}, + {name = "Others (See AUTHORS)"}, +] +readme = "README.rst" +license = {text = "MIT"} +keywords = ["test", "unittest"] +classifiers = [ + "Development Status :: 6 - Mature", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Operating System :: Unix", + "Operating System :: POSIX", + "Programming Language :: Python :: 3", + "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", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Testing", + "Topic :: Utilities", +] + +[project.urls] +Homepage = "https://docs.pytest.org/en/latest/" +Changelog = "https://docs.pytest.org/en/stable/changelog.html" +Twitter = "https://twitter.com/pytestdotorg" +Source = "https://github.com/pytest-dev/pytest" +Tracker = "https://github.com/pytest-dev/pytest/issues" + [build-system] requires = [ "setuptools>=45.0", diff --git a/setup.cfg b/setup.cfg index a1a47e1ba..bf981840b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,36 +1,5 @@ [metadata] -name = pytest -description = pytest: simple powerful testing with Python -long_description = file: README.rst -long_description_content_type = text/x-rst -url = https://docs.pytest.org/en/latest/ -author = Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others -license = MIT -license_files = LICENSE platforms = unix, linux, osx, cygwin, win32 -classifiers = - Development Status :: 6 - Mature - Intended Audience :: Developers - License :: OSI Approved :: MIT License - Operating System :: MacOS :: MacOS X - Operating System :: Microsoft :: Windows - Operating System :: POSIX - Programming Language :: Python :: 3 - 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 - Topic :: Software Development :: Libraries - Topic :: Software Development :: Testing - Topic :: Utilities -keywords = test, unittest -project_urls = - Changelog=https://docs.pytest.org/en/stable/changelog.html - Twitter=https://twitter.com/pytestdotorg - Source=https://github.com/pytest-dev/pytest - Tracker=https://github.com/pytest-dev/pytest/issues [options] install_requires = From c3583dee0b274af84b56e70f270d3a42d0ce2463 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Mon, 5 Feb 2024 14:02:06 +0100 Subject: [PATCH 2/8] [pyproject.toml] Translate 'metadata:platforms' to pyproject.toml --- setup.cfg | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index bf981840b..8707c6180 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,3 @@ -[metadata] -platforms = unix, linux, osx, cygwin, win32 - [options] install_requires = iniconfig From 411c2cbf9d8f1e18aa4b7e53ff3d60790beacf1d Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Mon, 5 Feb 2024 14:20:10 +0100 Subject: [PATCH 3/8] [pyproject.toml] Translate dynamic option to pyproject.toml --- pyproject.toml | 35 +++++++++++++++++++++++++++-------- setup.cfg | 24 ------------------------ 2 files changed, 27 insertions(+), 32 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6e3d3612a..38a9471e0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,6 @@ [project] - name = "pytest" -dynamic = [ - "version", - "optional-dependencies", - "dependencies", - "scripts", - "requires-python" -] +dynamic = ["version"] description = "pytest: simple powerful testing with Python" authors = [ {name = "Holger Krekel"}, @@ -41,6 +34,32 @@ classifiers = [ "Topic :: Utilities", ] +dependencies = [ + "colorama;sys_platform=='win32'", + "exceptiongroup>=1.0.0rc8;python_version<'3.11'", + "iniconfig", + "packaging", + "pluggy>=1.4.0,<2.0", + "tomli>=1.0.0;python_version<'3.11'", +] +requires-python = ">=3.8" + +[project.optional-dependencies] +testing = [ + "argcomplete", + "attrs>=19.2.0", + "hypothesis>=3.56", + "mock", + "pygments>=2.7.2", + "requests", + "setuptools", + "xmlschema", +] + +[project.scripts] +"py.test" = "pytest:console_main" +pytest = "pytest:console_main" + [project.urls] Homepage = "https://docs.pytest.org/en/latest/" Changelog = "https://docs.pytest.org/en/stable/changelog.html" diff --git a/setup.cfg b/setup.cfg index 8707c6180..364db8d70 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,34 +1,10 @@ [options] -install_requires = - iniconfig - packaging - pluggy>=1.4.0,<2.0 - colorama;sys_platform=="win32" - exceptiongroup>=1.0.0rc8;python_version<"3.11" - tomli>=1.0.0;python_version<"3.11" -python_requires = >=3.8 package_dir = =src setup_requires = setuptools setuptools-scm>=6.0 -[options.entry_points] -console_scripts = - pytest=pytest:console_main - py.test=pytest:console_main - -[options.extras_require] -testing = - argcomplete - attrs>=19.2.0 - hypothesis>=3.56 - mock - pygments>=2.7.2 - requests - setuptools - xmlschema - [options.package_data] _pytest = py.typed pytest = py.typed From dab1583ce1ad9c08b64fefc632c9e3d900d4c3dd Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Mon, 5 Feb 2024 15:27:53 +0100 Subject: [PATCH 4/8] [pyproject.toml] Remove setup_requires / package_dir in setup.cfg already exists --- setup.cfg | 7 ------- 1 file changed, 7 deletions(-) diff --git a/setup.cfg b/setup.cfg index 364db8d70..3e72c56d7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,10 +1,3 @@ -[options] -package_dir = - =src -setup_requires = - setuptools - setuptools-scm>=6.0 - [options.package_data] _pytest = py.typed pytest = py.typed From c76ea72331f6c45e248b92be8233188ecd2347b7 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Mon, 5 Feb 2024 15:33:27 +0100 Subject: [PATCH 5/8] [pyproject.toml] Moving 'package_data' (py.typed) from setup.cfg --- pyproject.toml | 4 ++++ setup.cfg | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) delete mode 100644 setup.cfg diff --git a/pyproject.toml b/pyproject.toml index 38a9471e0..427de749a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,6 +74,10 @@ requires = [ ] build-backend = "setuptools.build_meta" +[tool.setuptools.package-data] +"_pytest" = ["py.typed"] +"pytest" = ["py.typed"] + [tool.setuptools_scm] write_to = "src/_pytest/_version.py" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 3e72c56d7..000000000 --- a/setup.cfg +++ /dev/null @@ -1,3 +0,0 @@ -[options.package_data] -_pytest = py.typed -pytest = py.typed From 835e8032f4b856c9e6d606dc909bde45281bdfb7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 20:29:38 +0000 Subject: [PATCH 6/8] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.15 → v0.2.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.15...v0.2.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 032fe8c4d..b5f68ecfc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.15" + rev: "v0.2.0" hooks: - id: ruff args: ["--fix"] From 757778f5f611a06ae5a8ac48c5c950cb1f8fceca Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Mon, 5 Feb 2024 20:20:31 +0100 Subject: [PATCH 7/8] [pyproject-fmt] Add pre-commit hook and autofix existing --- .pre-commit-config.yaml | 6 + pyproject.toml | 280 ++++++++++++++++++++-------------------- 2 files changed, 147 insertions(+), 139 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5c1ebb3c2..22a9ec95f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,6 +42,12 @@ repos: # for mypy running on python>=3.11 since exceptiongroup is only a dependency # on <3.11 - exceptiongroup>=1.0.0rc8 +- repo: https://github.com/tox-dev/pyproject-fmt + rev: "1.7.0" + hooks: + - id: pyproject-fmt + # https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version + additional_dependencies: ["tox>=4.9"] - repo: local hooks: - id: rst diff --git a/pyproject.toml b/pyproject.toml index 427de749a..98fa51c44 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,12 @@ [project] name = "pytest" -dynamic = ["version"] description = "pytest: simple powerful testing with Python" +readme = "README.rst" +keywords = [ + "test", + "unittest", +] +license = {text = "MIT"} authors = [ {name = "Holger Krekel"}, {name = "Bruno Oliveira"}, @@ -11,18 +16,15 @@ authors = [ {name = "Florian Bruhin"}, {name = "Others (See AUTHORS)"}, ] -readme = "README.rst" -license = {text = "MIT"} -keywords = ["test", "unittest"] +requires-python = ">=3.8" classifiers = [ "Development Status :: 6 - Mature", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: MacOS", "Operating System :: Microsoft :: Windows", - "Operating System :: Unix", "Operating System :: POSIX", - "Programming Language :: Python :: 3", + "Operating System :: Unix", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", @@ -33,21 +35,21 @@ classifiers = [ "Topic :: Software Development :: Testing", "Topic :: Utilities", ] - +dynamic = [ + "version", +] dependencies = [ - "colorama;sys_platform=='win32'", - "exceptiongroup>=1.0.0rc8;python_version<'3.11'", + 'colorama; sys_platform == "win32"', + 'exceptiongroup>=1.0.0rc8; python_version < "3.11"', "iniconfig", "packaging", - "pluggy>=1.4.0,<2.0", - "tomli>=1.0.0;python_version<'3.11'", + "pluggy<2.0,>=1.4", + 'tomli>=1; python_version < "3.11"', ] -requires-python = ">=3.8" - [project.optional-dependencies] testing = [ "argcomplete", - "attrs>=19.2.0", + "attrs>=19.2", "hypothesis>=3.56", "mock", "pygments>=2.7.2", @@ -55,24 +57,22 @@ testing = [ "setuptools", "xmlschema", ] - +[project.urls] +Changelog = "https://docs.pytest.org/en/stable/changelog.html" +Homepage = "https://docs.pytest.org/en/latest/" +Source = "https://github.com/pytest-dev/pytest" +Tracker = "https://github.com/pytest-dev/pytest/issues" +Twitter = "https://twitter.com/pytestdotorg" [project.scripts] "py.test" = "pytest:console_main" pytest = "pytest:console_main" -[project.urls] -Homepage = "https://docs.pytest.org/en/latest/" -Changelog = "https://docs.pytest.org/en/stable/changelog.html" -Twitter = "https://twitter.com/pytestdotorg" -Source = "https://github.com/pytest-dev/pytest" -Tracker = "https://github.com/pytest-dev/pytest/issues" - [build-system] -requires = [ - "setuptools>=45.0", - "setuptools-scm[toml]>=6.2.3", -] build-backend = "setuptools.build_meta" +requires = [ + "setuptools>=45", + "setuptools-scm[toml]>=6.2.3", +] [tool.setuptools.package-data] "_pytest" = ["py.typed"] @@ -81,122 +81,9 @@ build-backend = "setuptools.build_meta" [tool.setuptools_scm] write_to = "src/_pytest/_version.py" -[tool.pytest.ini_options] -minversion = "2.0" -addopts = "-rfEX -p pytester --strict-markers" -python_files = ["test_*.py", "*_test.py", "testing/python/*.py"] -python_classes = ["Test", "Acceptance"] -python_functions = ["test"] -# NOTE: "doc" is not included here, but gets tested explicitly via "doctesting". -testpaths = ["testing"] -norecursedirs = [ - "testing/example_scripts", - ".*", - "build", - "dist", -] -xfail_strict = true -filterwarnings = [ - "error", - "default:Using or importing the ABCs:DeprecationWarning:unittest2.*", - # produced by older pyparsing<=2.2.0. - "default:Using or importing the ABCs:DeprecationWarning:pyparsing.*", - "default:the imp module is deprecated in favour of importlib:DeprecationWarning:nose.*", - # distutils is deprecated in 3.10, scheduled for removal in 3.12 - "ignore:The distutils package is deprecated:DeprecationWarning", - # produced by pytest-xdist - "ignore:.*type argument to addoption.*:DeprecationWarning", - # produced on execnet (pytest-xdist) - "ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning", - # pytest's own futurewarnings - "ignore::pytest.PytestExperimentalApiWarning", - # Do not cause SyntaxError for invalid escape sequences in py37. - # Those are caught/handled by pyupgrade, and not easy to filter with the - # module being the filename (with .py removed). - "default:invalid escape sequence:DeprecationWarning", - # ignore not yet fixed warnings for hook markers - "default:.*not marked using pytest.hook.*", - "ignore:.*not marked using pytest.hook.*::xdist.*", - # ignore use of unregistered marks, because we use many to test the implementation - "ignore::_pytest.warning_types.PytestUnknownMarkWarning", - # https://github.com/benjaminp/six/issues/341 - "ignore:_SixMetaPathImporter\\.exec_module\\(\\) not found; falling back to load_module\\(\\):ImportWarning", - # https://github.com/benjaminp/six/pull/352 - "ignore:_SixMetaPathImporter\\.find_spec\\(\\) not found; falling back to find_module\\(\\):ImportWarning", - # https://github.com/pypa/setuptools/pull/2517 - "ignore:VendorImporter\\.find_spec\\(\\) not found; falling back to find_module\\(\\):ImportWarning", - # https://github.com/pytest-dev/execnet/pull/127 - "ignore:isSet\\(\\) is deprecated, use is_set\\(\\) instead:DeprecationWarning", -] -pytester_example_dir = "testing/example_scripts" -markers = [ - # dummy markers for testing - "foo", - "bar", - "baz", - # conftest.py reorders tests moving slow ones to the end of the list - "slow", - # experimental mark for all tests using pexpect - "uses_pexpect", -] - - -[tool.towncrier] -package = "pytest" -package_dir = "src" -filename = "doc/en/changelog.rst" -directory = "changelog/" -title_format = "pytest {version} ({project_date})" -template = "changelog/_template.rst" - - [[tool.towncrier.type]] - directory = "breaking" - name = "Breaking Changes" - showcontent = true - - [[tool.towncrier.type]] - directory = "deprecation" - name = "Deprecations" - showcontent = true - - [[tool.towncrier.type]] - directory = "feature" - name = "Features" - showcontent = true - - [[tool.towncrier.type]] - directory = "improvement" - name = "Improvements" - showcontent = true - - [[tool.towncrier.type]] - directory = "bugfix" - name = "Bug Fixes" - showcontent = true - - [[tool.towncrier.type]] - directory = "vendor" - name = "Vendored Libraries" - showcontent = true - - [[tool.towncrier.type]] - directory = "doc" - name = "Improved Documentation" - showcontent = true - - [[tool.towncrier.type]] - directory = "trivial" - name = "Trivial/Internal Changes" - showcontent = true - [tool.black] target-version = ['py38'] -# check-wheel-contents is executed by the build-and-inspect-python-package action. -[tool.check-wheel-contents] -# W009: Wheel contains multiple toplevel library entries -ignore = "W009" - [tool.ruff] src = ["src"] line-length = 88 @@ -266,6 +153,121 @@ lines-after-imports = 2 "src/_pytest/_version.py" = ["I001"] "testing/python/approx.py" = ["B015"] +[tool.check-wheel-contents] +# check-wheel-contents is executed by the build-and-inspect-python-package action. +# W009: Wheel contains multiple toplevel library entries +ignore = "W009" + +[tool.pyproject-fmt] +indent = 4 + +[tool.pytest.ini_options] +minversion = "2.0" +addopts = "-rfEX -p pytester --strict-markers" +python_files = ["test_*.py", "*_test.py", "testing/python/*.py"] +python_classes = ["Test", "Acceptance"] +python_functions = ["test"] +# NOTE: "doc" is not included here, but gets tested explicitly via "doctesting". +testpaths = ["testing"] +norecursedirs = [ + "testing/example_scripts", + ".*", + "build", + "dist", +] +xfail_strict = true +filterwarnings = [ + "error", + "default:Using or importing the ABCs:DeprecationWarning:unittest2.*", + # produced by older pyparsing<=2.2.0. + "default:Using or importing the ABCs:DeprecationWarning:pyparsing.*", + "default:the imp module is deprecated in favour of importlib:DeprecationWarning:nose.*", + # distutils is deprecated in 3.10, scheduled for removal in 3.12 + "ignore:The distutils package is deprecated:DeprecationWarning", + # produced by pytest-xdist + "ignore:.*type argument to addoption.*:DeprecationWarning", + # produced on execnet (pytest-xdist) + "ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning", + # pytest's own futurewarnings + "ignore::pytest.PytestExperimentalApiWarning", + # Do not cause SyntaxError for invalid escape sequences in py37. + # Those are caught/handled by pyupgrade, and not easy to filter with the + # module being the filename (with .py removed). + "default:invalid escape sequence:DeprecationWarning", + # ignore not yet fixed warnings for hook markers + "default:.*not marked using pytest.hook.*", + "ignore:.*not marked using pytest.hook.*::xdist.*", + # ignore use of unregistered marks, because we use many to test the implementation + "ignore::_pytest.warning_types.PytestUnknownMarkWarning", + # https://github.com/benjaminp/six/issues/341 + "ignore:_SixMetaPathImporter\\.exec_module\\(\\) not found; falling back to load_module\\(\\):ImportWarning", + # https://github.com/benjaminp/six/pull/352 + "ignore:_SixMetaPathImporter\\.find_spec\\(\\) not found; falling back to find_module\\(\\):ImportWarning", + # https://github.com/pypa/setuptools/pull/2517 + "ignore:VendorImporter\\.find_spec\\(\\) not found; falling back to find_module\\(\\):ImportWarning", + # https://github.com/pytest-dev/execnet/pull/127 + "ignore:isSet\\(\\) is deprecated, use is_set\\(\\) instead:DeprecationWarning", +] +pytester_example_dir = "testing/example_scripts" +markers = [ + # dummy markers for testing + "foo", + "bar", + "baz", + # conftest.py reorders tests moving slow ones to the end of the list + "slow", + # experimental mark for all tests using pexpect + "uses_pexpect", +] + +[tool.towncrier] +package = "pytest" +package_dir = "src" +filename = "doc/en/changelog.rst" +directory = "changelog/" +title_format = "pytest {version} ({project_date})" +template = "changelog/_template.rst" + + [[tool.towncrier.type]] + directory = "breaking" + name = "Breaking Changes" + showcontent = true + + [[tool.towncrier.type]] + directory = "deprecation" + name = "Deprecations" + showcontent = true + + [[tool.towncrier.type]] + directory = "feature" + name = "Features" + showcontent = true + + [[tool.towncrier.type]] + directory = "improvement" + name = "Improvements" + showcontent = true + + [[tool.towncrier.type]] + directory = "bugfix" + name = "Bug Fixes" + showcontent = true + + [[tool.towncrier.type]] + directory = "vendor" + name = "Vendored Libraries" + showcontent = true + + [[tool.towncrier.type]] + directory = "doc" + name = "Improved Documentation" + showcontent = true + + [[tool.towncrier.type]] + directory = "trivial" + name = "Trivial/Internal Changes" + showcontent = true + [tool.mypy] mypy_path = ["src"] check_untyped_defs = true From d1095426c163c8a005d0c1c81612c4cedfe698b5 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 6 Feb 2024 14:38:52 +0100 Subject: [PATCH 8/8] Update setuptools version to the one that support pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 98fa51c44..efbb9b6c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,7 +70,7 @@ pytest = "pytest:console_main" [build-system] build-backend = "setuptools.build_meta" requires = [ - "setuptools>=45", + "setuptools>=61", "setuptools-scm[toml]>=6.2.3", ]