Skip to content
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

Cleaner usage of get_proper_type() #13326

Merged
merged 18 commits into from
Aug 4, 2022

Conversation

ilevkivskyi
Copy link
Member

This is a follow up for #13297

I move around some calls to get_proper_type() to preserve original types as much as possible (plus few related required low-risk changes). This makes error messages much more concise, before some error messages in the tests I added were truly epic:

Incompatible types in assignment (expression has type "Sequence[Union[B, Sequence[Union[B, Sequence[Union[B, Sequence[Union[B, Sequence[Union[B, Sequence[Union[B, NestedB]]]]]]]]]]]]", variable has type "int")

cc @JukkaL

@ilevkivskyi
Copy link
Member Author

Btw I think that I checked and "optimized" completely the usage of get_proper_type() in the following files:

  • applytype.py
  • argmap.py
  • binder.py
  • erasetype.py
  • expandtype.py
  • join.py
  • meet.py
  • solve.py
  • subtypes.py

Plus also some important places in checker.py and checkexpr.py. There is definitely still room for improvement, but I think it can be done later (e.g. as requested by users).

@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2022

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

paasta (https://github.com/yelp/paasta)
- paasta_tools/instance/kubernetes.py:643: error: List item 1 has incompatible type "Task[List[TypedDict({'name'?: str, 'type'?: str, 'replicas'?: int, 'ready_replicas'?: int, 'create_timestamp'?: int, 'git_sha'?: str, 'image_version'?: Optional[str], 'config_sha'?: str, 'pods'?: Sequence[Mapping[str, Any]]})]]"; expected "Future[Dict[str, Any]]"
+ paasta_tools/instance/kubernetes.py:643: error: List item 1 has incompatible type "Task[List[KubernetesVersionDict]]"; expected "Future[Dict[str, Any]]"

@ilevkivskyi
Copy link
Member Author

TBH, I am not 100% sure how to explain the change in mypy_primer (probably my meet.py fix), but I definitely like the new error message.

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.

Everything in this PR looks great, I didn't check to see if there are changes elsewhere that could be made

@ilevkivskyi ilevkivskyi merged commit 43476aa into python:master Aug 4, 2022
@ilevkivskyi ilevkivskyi deleted the clean-get-proper-type branch August 4, 2022 20:40
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