KEMBAR78
Don't assume that for loop body index variable is always set by JukkaL · Pull Request #18631 · python/mypy · GitHub
Skip to content

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Feb 7, 2025

Fixes #18629. Fixes #16321. Fixes #8637.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2025

Diff from mypy_primer, showing the effect of this PR on open source code:

pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/assertion/rewrite.py:731: error: Item "None" of "Optional[stmt]" has no attribute "lineno"  [union-attr]

kopf (https://github.com/nolar/kopf): 1.83x faster (40.2s -> 22.0s in a single noisy sample)

core (https://github.com/home-assistant/core)
+ homeassistant/components/blueprint/importer.py:223: error: Value of type "Any | None" is not indexable  [index]

pyodide (https://github.com/pyodide/pyodide)
+ src/py/pyodide/code.py:45: error: Unsupported operand types for + ("None" and "int")  [operator]
+ src/py/pyodide/code.py:45: note: Left operand is of type "int | None"

@JukkaL
Copy link
Collaborator Author

JukkaL commented Feb 7, 2025

All the new mypy_primer errors look right.

@JukkaL JukkaL requested a review from ilevkivskyi February 7, 2025 15:37
@ilevkivskyi
Copy link
Member

@JukkaL I think this may also fix #8637 (an old high priority bug), could you please double-check?

@JukkaL
Copy link
Collaborator Author

JukkaL commented Feb 10, 2025

I think this may also fix #8637 (an old high priority bug)

Yes, it is fixed!

@JukkaL JukkaL merged commit f946af4 into master Feb 10, 2025
18 checks passed
@JukkaL JukkaL deleted the for-loop-binder branch February 10, 2025 10:00
x612skm pushed a commit to x612skm/mypy-dev that referenced this pull request Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants