-
-
Notifications
You must be signed in to change notification settings - Fork 3k
[1.16 regression] a cast is both needed and redundant at the same time #19170
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
Labels
Comments
Thanks! Probably proximal cause is #18588 If you'd like to upgrade to 1.16, |
Minimised repro:
I guess the cast is redundant the second time through the loop... |
Yes, I hope we just have to handle |
sthagen
pushed a commit
to sthagen/python-mypy
that referenced
this issue
Jun 6, 2025
…rnings in loops more robustly and efficiently, and avoid multiple `revealed type` notes for the same line. (python#19118) Fixes python#18606 Closes python#18511 Improves python#18991 Fixes python#19170 This change is an improvement over 9685171. Besides fixing the regressions reported in python#18606 and python#19170 and removing the duplicates reported in python#18511, it should significantly reduce the performance regression reported in python#18991. At least running `Measure-command {python runtests.py self}` on my computer (with removed cache) is 10 % faster.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Bug Report
Since 1.16, structlog's package type check fails with:
If I remove the cast, I get:
If I add a reveal_type, I get on both 1.15 & 1.16:
So I guess Mypy got somehow smarter/confused about that?
To Reproduce
git clone [email protected]:hynek/structlog.git
git checkout d948027
tox -e mypy-pkg
I really tried to create a minimal reproducer, but given that I don't quite understand what's going on, I've failed.
The relevant code is here: https://github.com/hynek/structlog/blob/e941e337d312eaf256595d9d09da4542c5e94d0b/src/structlog/stdlib.py#L1160
The types are defined here: https://github.com/hynek/structlog/blob/e941e337d312eaf256595d9d09da4542c5e94d0b/src/structlog/typing.py#L61-L76
Expected Behavior
I would expect it to keep working, or at least decide whether or not I need the cast. 🤓
Actual Behavior
I don't seem to find a way to make the code pass except using Any all over the place I guess.
Your Environment
mypy.ini
(and other config files): https://github.com/hynek/structlog/blob/e941e337d312eaf256595d9d09da4542c5e94d0b/pyproject.toml#L175-L191edit I managed to work around it with the help of @Tinche but it still looks like I managed to break poor little Mypy.
The text was updated successfully, but these errors were encountered: