Add strict configuration option to enable all other strictness options #13839
Merged
bluetech merged 4 commits intopytest-dev:mainfrom Oct 26, 2025
Merged
Add strict configuration option to enable all other strictness options #13839bluetech merged 4 commits intopytest-dev:mainfrom
strict configuration option to enable all other strictness options #13839bluetech merged 4 commits intopytest-dev:mainfrom
Conversation
nicoddemus
approved these changes
Oct 23, 2025
Member
nicoddemus
left a comment
There was a problem hiding this comment.
Awesome work! Left some minor comments.
doc/en/reference/reference.rst
Outdated
|
|
||
| .. note:: | ||
| If new strictness options are added to pytest in the future, they will also be enabled by ``strict``. | ||
| We therefore only recommend using this option when using a locked version of pytest. |
Member
There was a problem hiding this comment.
Suggested change
| We therefore only recommend using this option when using a locked version of pytest. | |
| We therefore only recommend using this option when using a locked version of pytest or if you want to proactively adopt new strictness options as they are added. |
Comment on lines
+585
to
+587
| current_overrides = getattr(namespace, "override_ini", None) | ||
| if current_overrides is None: | ||
| current_overrides = [] |
Member
There was a problem hiding this comment.
This can be simplifed:
Suggested change
| current_overrides = getattr(namespace, "override_ini", None) | |
| if current_overrides is None: | |
| current_overrides = [] | |
| current_overrides = getattr(namespace, "override_ini", []) |
Member
Author
There was a problem hiding this comment.
It's written this way because namespace.override_ini can be set to None. I think it starts as None.
src/_pytest/mark/structures.py
Outdated
Comment on lines
588
to
591
| if self._config.hasini("strict_markers"): | ||
| strict_markers = self._config.getini("strict_markers") | ||
| else: | ||
| strict_markers = self._config.getini("strict") |
Member
There was a problem hiding this comment.
While simple, this pattern repeats, how about a simple convenience method?
Suggested change
| if self._config.hasini("strict_markers"): | |
| strict_markers = self._config.getini("strict_markers") | |
| else: | |
| strict_markers = self._config.getini("strict") | |
| strict_markers = self._config.getini_or("strict_markers", "strict") |
Not married to the name getini_or, other suggestions:
getini_fallbackgetini_or_else
Member
Author
There was a problem hiding this comment.
I'll comment about this in the issue.
Member
Author
|
TODO: Update goodpractices.rst to recommend setting strict = true. |
This is to make it consistent with the other `strict_` options. For pytest-dev#13823.
We want to have ini versions of all strictness flags, since they're usually more sensible as project configuration, and as preparation for adding the `strict` ini option. Refs pytest-dev#13823.
I figure the misspelling error is better than the "not found in `markers`" error.
The `--strict` option is undeprecated and enables `strict`. Fix pytest-dev#13823.
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.
This adds the
strictoption, as discussed in #13823.There are some prerequisites required to make everything consistent, as mentioned in the issue. Please see the commits for details.
Fixes #13823.
Fixes #7503.