♻️ refactor: modernize for Python 3.10+ and public pytest APIs#202
Merged
gaborbernat merged 2 commits intopytest-dev:mainfrom Feb 11, 2026
Merged
♻️ refactor: modernize for Python 3.10+ and public pytest APIs#202gaborbernat merged 2 commits intopytest-dev:mainfrom
gaborbernat merged 2 commits intopytest-dev:mainfrom
Conversation
The project declares requires-python >= 3.10 but had runtime version checks and used deprecated/private pytest APIs. This cleans that up. Drop sys.version_info guard on Formatter dataclass since slots and kw_only are always available. Replace private _pytest.fixtures.SubRequest with public pytest.FixtureRequest. Remove unused Formatter construction in create_pretty_printer fixture. Migrate tests from legacy pytest.Testdir (py.path-based) to modern pytest.Pytester (pathlib-based), eliminating the Path(str(tmpdir)) workaround. Switch type checker from mypy to ty and migrate tox.ini to tox.toml. Suppress RUF067 since code in __init__ modules is intentional here.
CaptureManager remains on _pytest.capture as pytest does not expose it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The project declares
requires-python = ">=3.10"but carried runtime version guards and relied on private_pytestinternals that have public replacements. This cleans up those legacy patterns to reduce coupling to pytest internals and remove dead code.The
Formatterdataclass used asys.version_infocheck to conditionally passslotsandkw_only— unnecessary since 3.10 is the floor. Fixture signatures used_pytest.fixtures.SubRequestand_pytest.terminal.TerminalReporterwhenpytest.FixtureRequestandpytest.TerminalReporterare the public equivalents. Thecreate_pretty_printerfixture constructed aFormatterthat was immediately discarded. ♻️ All of these are cleaned up.Tests migrated from the legacy
pytest.Testdir(backed bypy.path.local) topytest.Pytester(backed bypathlib.Path), removing thePath(str(testdir.tmpdir))workaround. 🔧 Build tooling moves fromtox.initotox.tomland the type checker switches from mypy to ty.