Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Handle union types when binding self - #18867

Merged
ilevkivskyi merged 1 commit into
python:masterfrom
ilevkivskyi:classvar-union-bind-self
Apr 1, 2025
Merged

Handle union types when binding self#18867
ilevkivskyi merged 1 commit into
python:masterfrom
ilevkivskyi:classvar-union-bind-self

Conversation

@ilevkivskyi

Copy link
Copy Markdown
Member

Currently we only bind self if the type is callable, but we actually should do this for all callable items in a union.

This use case is probably quite niche (since adding an annotation makes a variable an instance variable, and we rarely infer unions). I found it when looking at checkmember-related issues it was easy to handle it. I also use this opportunity to refactor and add comments to analyze_var().

@github-actions

github-actions Bot commented Apr 1, 2025

Copy link
Copy Markdown
Contributor

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

spark (https://github.com/apache/spark)
+ python/pyspark/util.py:545: error: Unused "type: ignore[union-attr]" comment  [unused-ignore]
+ python/pyspark/util.py:584: error: Unused "type: ignore[union-attr]" comment  [unused-ignore]

@ilevkivskyi
ilevkivskyi merged commit 715b982 into python:master Apr 1, 2025
@ilevkivskyi
ilevkivskyi deleted the classvar-union-bind-self branch April 1, 2025 17:06
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.

2 participants