Skip to content

Fix issue 7863 #7933

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 11 commits into from
Nov 15, 2019
Prev Previous commit
Next Next commit
get_proper_type before isinstance, balance is_property branch
  • Loading branch information
beezee committed Nov 13, 2019
commit a2b8bad1186e3e3bb9e4252f1de8c155ac9497e1
8 changes: 5 additions & 3 deletions mypy/checkmember.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ def analyze_var(name: str,
mx.msg.cant_assign_to_classvar(name, mx.context)
t = get_proper_type(expand_type_by_instance(typ, itype))
result = t # type: Type
typ = get_proper_type(typ)
if var.is_initialized_in_class and isinstance(typ, FunctionLike) and not typ.is_type_obj():
if mx.is_lvalue:
if var.is_property:
Expand All @@ -557,12 +558,13 @@ def analyze_var(name: str,
mx.context, name, mx.msg)
signature = freshen_function_type_vars(functype)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should freshen the function type vars before the check_self_arg, to match how it is done elsewhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks for the pointer.

signature = bind_self(signature, mx.self_type, var.is_classmethod)
expanded_signature = get_proper_type(expand_type_by_instance(signature, itype))
if var.is_property:
# A property cannot have an overloaded type => the cast is fine.
assert isinstance(signature, CallableType)
result = signature.ret_type
assert isinstance(expanded_signature, CallableType)
result = expanded_signature.ret_type
else:
result = get_proper_type(expand_type_by_instance(signature, itype))
result = expanded_signature
else:
if not var.is_ready:
mx.not_ready_callback(var.name(), mx.context)
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy