Skip to content

Handle union types when binding self #18867

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 1 commit into from
Apr 1, 2025

Conversation

ilevkivskyi
Copy link
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().

Copy link
Contributor

github-actions bot commented Apr 1, 2025

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
18 checks passed
@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