Skip to content

Delete old meet hack from checkmember.py #18662

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
Feb 12, 2025

Conversation

ilevkivskyi
Copy link
Member

The hack to use meet_types(original_type, itype) to select a correct element from a union appeared before we added proper handling of unions in various places related to checkmember.py. This is error prone, since meet_types() is one of least precise type ops (for good and bad reasons), and results in obscure bugs, see e.g. #15600

This hack should not be needed anymore, now we have three-level information available everywhere we needed it:

  • original_type - as the name says, a type from which everything started. This is used for error messages and for plugin hooks.
  • self_type - a specific element of the union is the original type is a union. The name is because this is what will be ultimately used by bind_self()
  • itype the actual instance type where we look up the attribute (this will be e.g. a fallback if the self_type is not an instance)

Copy link
Contributor

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.

Great!

@hauntsaninja hauntsaninja merged commit 9665c32 into python:master Feb 12, 2025
18 checks passed
@ilevkivskyi ilevkivskyi deleted the delete-meet-hack branch February 12, 2025 08:56
ericmarkmartin pushed a commit to ericmarkmartin/mypy that referenced this pull request Feb 19, 2025
The hack to use `meet_types(original_type, itype)` to select a correct
element from a union appeared before we added proper handling of unions
in various places related to `checkmember.py`. This is error prone,
since `meet_types()` is one of least precise type ops (for good and bad
reasons), and results in obscure bugs, see e.g.
python#15600

This hack should not be needed anymore, now we have three-level
information available everywhere we needed it:
* `original_type` - as the name says, a type from which everything
started. This is used for error messages and for plugin hooks.
* `self_type` - a specific element of the union is the original type is
a union. The name is because this is what will be ultimately used by
`bind_self()`
* `itype` the actual instance type where we look up the attribute (this
will be e.g. a fallback if the `self_type` is not an instance)
ericmarkmartin pushed a commit to ericmarkmartin/mypy that referenced this pull request Feb 19, 2025
The hack to use `meet_types(original_type, itype)` to select a correct
element from a union appeared before we added proper handling of unions
in various places related to `checkmember.py`. This is error prone,
since `meet_types()` is one of least precise type ops (for good and bad
reasons), and results in obscure bugs, see e.g.
python#15600

This hack should not be needed anymore, now we have three-level
information available everywhere we needed it:
* `original_type` - as the name says, a type from which everything
started. This is used for error messages and for plugin hooks.
* `self_type` - a specific element of the union is the original type is
a union. The name is because this is what will be ultimately used by
`bind_self()`
* `itype` the actual instance type where we look up the attribute (this
will be e.g. a fallback if the `self_type` is not an instance)
x612skm pushed a commit to x612skm/mypy-dev that referenced this pull request Feb 24, 2025
The hack to use `meet_types(original_type, itype)` to select a correct
element from a union appeared before we added proper handling of unions
in various places related to `checkmember.py`. This is error prone,
since `meet_types()` is one of least precise type ops (for good and bad
reasons), and results in obscure bugs, see e.g.
python#15600

This hack should not be needed anymore, now we have three-level
information available everywhere we needed it:
* `original_type` - as the name says, a type from which everything
started. This is used for error messages and for plugin hooks.
* `self_type` - a specific element of the union is the original type is
a union. The name is because this is what will be ultimately used by
`bind_self()`
* `itype` the actual instance type where we look up the attribute (this
will be e.g. a fallback if the `self_type` is not an instance)
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