Skip to content
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

gh-109413: libregrtest: enable mypy's --strict-optional check on most files #112586

Merged

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Dec 1, 2023

Mypy's --strict-optional check is one of its most important checks, and it's enabled by default when you run mypy. It warns you if it infers that an object might be of type Foo | None at runtime, even though the code is only guaranteed to work if the object is an instance of Foo.

We currently have --strict-optional disabled on several files, as there were too many errors to deal with initially, and the priority was to have mypy enabled in CI so that we could work on improving the type annotations incrementally. This PR re-enables --strict-optional on four files where it's easy to do so.

Lib/test/libregrtest/runtests.py Outdated Show resolved Hide resolved
Lib/test/libregrtest/single.py Show resolved Hide resolved
Lib/test/libregrtest/utils.py Outdated Show resolved Hide resolved
@AlexWaygood
Copy link
Member Author

On hold until #112588 is merged

@AlexWaygood AlexWaygood marked this pull request as draft December 1, 2023 13:10
Co-authored-by: Victor Stinner <vstinner@python.org>
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

@AlexWaygood AlexWaygood marked this pull request as ready for review December 1, 2023 13:49
@AlexWaygood AlexWaygood enabled auto-merge (squash) December 1, 2023 13:55
@AlexWaygood AlexWaygood added needs backport to 3.11 only security fixes needs backport to 3.12 bug and security fixes labels Dec 1, 2023
@AlexWaygood AlexWaygood merged commit 70a38ff into python:main Dec 1, 2023
36 checks passed
@AlexWaygood AlexWaygood deleted the libregrtest-easy-strict-optional branch December 1, 2023 14:54
@miss-islington-app
Copy link

Thanks @AlexWaygood for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @AlexWaygood, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 70a38ffb3d712f973eb17bd1bda541f238ae70d2 3.12

@miss-islington-app
Copy link

Sorry, @AlexWaygood, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 70a38ffb3d712f973eb17bd1bda541f238ae70d2 3.11

AlexWaygood added a commit to AlexWaygood/cpython that referenced this pull request Dec 1, 2023
… on most files (python#112586)

Co-authored-by: Victor Stinner <vstinner@python.org>
@bedevere-app
Copy link

bedevere-app bot commented Dec 1, 2023

GH-112602 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Dec 1, 2023
@AlexWaygood AlexWaygood removed the needs backport to 3.11 only security fixes label Dec 1, 2023
@AlexWaygood
Copy link
Member Author

I added the "needs backport to 3.11" label to the 3.12 branch to take care of the 3.11 backport.

AlexWaygood added a commit that referenced this pull request Dec 1, 2023
…k on most files (#112586) (#112602)

gh-109413: libregrtest: enable mypy's `--strict-optional` check on most files (#112586)

Co-authored-by: Victor Stinner <vstinner@python.org>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 1, 2023
…` check on most files (pythonGH-112586) (pythonGH-112602)

pythongh-109413: libregrtest: enable mypy's `--strict-optional` check on most files (pythonGH-112586)

(cherry picked from commit 36dbebe)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
AlexWaygood added a commit that referenced this pull request Dec 1, 2023
…l` check on most files (GH-112586) (GH-112602) (#112603)

[3.12] gh-109413: libregrtest: enable mypy's `--strict-optional` check on most files (GH-112586) (GH-112602)

gh-109413: libregrtest: enable mypy's `--strict-optional` check on most files (GH-112586)

(cherry picked from commit 36dbebe)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
… on most files (python#112586)

Co-authored-by: Victor Stinner <vstinner@python.org>
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
… on most files (python#112586)

Co-authored-by: Victor Stinner <vstinner@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants