Skip to content

Fix a bug where inline configurations of error codes would lose their values if accompanied by another inline configuration. #19075

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 19 commits into from
Aug 2, 2025

Conversation

wyattscarpenter
Copy link
Contributor

@wyattscarpenter wyattscarpenter commented May 12, 2025

The following code produces a name-defined code error, despite our instructions. How can it be?!

# mypy: disable-error-code=name-defined
# mypy: strict-equality
a

The answer is, there was a bug that caused all inline configurations, even those that didn't specify any enable/disables, to overwrite the lists of enable/disables. I have now fixed that. I've also added some tests.

Closes #12342 — I discovered this problem while investigating the last foible of issue #12342 (itself of tangential interest to something else I was doing), which can now be closed.

This comment has been minimized.

This comment has been minimized.

@wyattscarpenter wyattscarpenter marked this pull request as draft May 12, 2025 04:44

This comment has been minimized.

This comment has been minimized.

@wyattscarpenter wyattscarpenter marked this pull request as ready for review May 12, 2025 18:02

This comment has been minimized.

Copy link
Collaborator

@sterliakov sterliakov left a comment

Choose a reason for hiding this comment

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

Thanks, looks great! And the problem is rather annoying. Added one nit below.

Co-authored-by: Stanislav Terliakov <[email protected]>

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Jul 4, 2025

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thanks!

@hauntsaninja hauntsaninja merged commit 813b4d1 into python:master Aug 2, 2025
20 checks passed
@wyattscarpenter wyattscarpenter deleted the per-m branch August 3, 2025 20: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.

(🐞) Invalid per-module options in inline configuration are silently ignored
3 participants