Skip to content

fix: docs examples python version in tests #2069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2025

Conversation

stevenh
Copy link
Contributor

@stevenh stevenh commented Jun 25, 2025

When performing test on docs example use the version of Python that is specified by the test block to set the target version of Python.

This fixes failures with later ruff versions which validate the syntax according to the target Python version more strictly, which was resulting in a failure when except* was used in the example code against Python 3.9.

When performing test on docs example use the version of Python that is
specified by the test block to set the target version of Python.

This fixes failures with later ruff versions which validate the syntax
according to the target Python version more strictly, which was
resulting in a failure then except* was used in the example code against
Python 3.9.
@stevenh stevenh force-pushed the fix/examples-python-version branch from 00c9324 to 6c5a6e7 Compare June 25, 2025 08:14
@stevenh stevenh marked this pull request as ready for review June 25, 2025 09:52
@Kludex
Copy link
Member

Kludex commented Jun 25, 2025

I think this was on purpose, tho. Wasn't it @samuelcolvin ?

@stevenh
Copy link
Contributor Author

stevenh commented Jun 25, 2025

I had updated dependencies at the time, so I suspect that if you bump the version of ruff, you'll start seeing test failures when the examples are run with ruff target_version=py39 and using features like except* which aren't in python 3.9, even though the example block explicitly requests a higher version.

Hope that helps clarify what triggered it for me.

@stevenh
Copy link
Contributor Author

stevenh commented Jun 25, 2025

There's also a related PR to pytest-examples here.

@medaminezghal
Copy link
Contributor

@Kludex I've also faced the same problem that @stevenh suggest a fix for it.

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

This looks fine to me.

@Kludex Kludex merged commit e2e6a44 into pydantic:main Jun 27, 2025
18 checks passed
@stevenh stevenh deleted the fix/examples-python-version branch June 30, 2025 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants