Repository navigation
Add PytestRemovedIn11Warning for unreleased deprecations - #15203
Draft
RonnyPfannschmidt wants to merge 1 commit into
Draft
RonnyPfannschmidt wants to merge 1 commit into
RonnyPfannschmidt wants to merge 1 commit into
Conversation
The next release is planned as pytest 10.0 (#15200), which turns PytestRemovedIn10Warning into errors. Three deprecations on main were never released, so they would go straight from nothing to an error. Add PytestRemovedIn11Warning and use it for: - module/package/session-scoped fixtures defined as instance methods (class-scoped ones, deprecated in 9.1, stay on pytest 10) - non-string values for string-typed ini options - the _pytest.python.CallSpec2 alias Also correct two "deprecated since" versions in deprecations.rst: config.inicfg was deprecated in 9.1 (not 9.0), and the CallSpec2 alias is unreleased (not 9.1). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
RonnyPfannschmidt
force-pushed
the
claude/pytest11-deprecations-ws7d1o
branch
from
October 18, 2026 15:44
7f8c6da to
9664b82
Compare
This branch has not been deployed
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.
Requested by Ronny · project thread
🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.
Before: three deprecations that exist only on main use
PytestRemovedIn10Warning. With the next release planned as 10.0 (#15200), which turns those warnings into errors, they would go from not existing straight to an error.After: they use a new
PytestRemovedIn11Warning, so 10.0 ships them as warnings and 11.0 removes them:string-typed ini options, from fix config: add deprecation warning for non-string value in string-typed ini option #14811_pytest.python.CallSpec2alias, from python: rename CallSpec2 -> CallSpec #14742All deprecations released in 9.1 or earlier stay scheduled for pytest 10.
How: add and export the warning class, add a
HIGHER_SCOPED_FIXTURE_INSTANCE_METHODwarning that reuses the class-scope message and is picked by fixture scope, and update docs, tests and the unreleased changelog fragments. Also fixes two wrong.. deprecated::versions indeprecations.rst:config.inicfgwas deprecated in 9.1 (not 9.0), and theCallSpec2alias is unreleased (not 9.1).Coverage of the warning sites
Checked by running the full test suite under coverage on this branch and looking up every line in
src/_pytestthat emits a constant from_pytest/deprecated.py.Moved to pytest 11, all covered:
CLASS_FIXTURE_INSTANCE_METHOD/HIGHER_SCOPED_FIXTURE_INSTANCE_METHODfixtures.pyresolve_fixture_function(scope pick and__tracebackhide__)deprecated_test.py::test_higher_scope_instance_method_is_deprecated(class → In10, module/package/session → In11)INI_STRING_TYPE_NON_STR_VALUEconfig/__init__.py_getinitest_config.py::TestConfigAPI::test_addini_string_non_str_deprecatedCALLSPEC2_RENAMEDpython.pymodule__getattr__deprecated_test.py::test_callspec2_renamedStaying on pytest 10: every emit site is covered except
MONKEYPATCH_LEGACY_NAMESPACE_PACKAGES(monkeypatch.py). Its only test,test_monkeypatch.py::test_syspath_prepend_with_namespace_packages, doesimportorskip("pkg_resources")and was skipped locally because the installed setuptools has nopkg_resources. I did not check whether any CI job installs it. Codecov patch is green for this PR.Affected open PRs
PytestRemovedIn11Warningclass (plus export and reference docs). Whichever merges second has to drop its copy.CONFTEST_IMPORT_SKIP) and Deprecate passing bytes to TerminalReporter.write_line #15202 (TERMINAL_WRITE_LINE_BYTES) add new deprecations withPytestRemovedIn10Warning. They are unreleased, so they should usePytestRemovedIn11Warningonce this lands.WarningTemplate.warn; fix the instance #14931 missed #15137 renamesUnformattedWarningtoWarningTemplateacross_pytest/deprecated.py, includingINI_STRING_TYPE_NON_STR_VALUE, so the two PRs conflict textually.WarningTemplatekeeps the.templateattribute thatHIGHER_SCOPED_FIXTURE_INSTANCE_METHODreads, so resolving it is mechanical.yield_fixturetoPytestRemovedIn10Warningafter 9.1. That deprecation itself is from 6.2, so it stays on 10 here. Whether it should move is an open question.