Skip to content

Conversation

@bluetech
Copy link
Member

This adds the strict option, 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.

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.
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 23, 2025
Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! Left some minor comments.


.. 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's written this way because namespace.override_ini can be set to None. I think it starts as None.

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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_fallback
  • getini_or_else

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll comment about this in the issue.

The `--strict` option is undeprecated and enables `strict`.

Fix pytest-dev#13823.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--strict deprecation was botched - what to do about it Make --strict imply --strict-config / xfail_strict?

3 participants