Skip to content

Meaningful message with long tuple initializer #7995

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 7 commits into from
Dec 3, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add skeleton, need add logic for formatting error msg
  • Loading branch information
TH3CHARLie committed Nov 19, 2019
commit a55c84c4d1ed33fff0f96806b40d945a2e5891af
20 changes: 19 additions & 1 deletion mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4027,7 +4027,9 @@ def check_subtype(self,

subtype = get_proper_type(subtype)
supertype = get_proper_type(supertype)

if self.check_tuple_assignment(subtype, supertype, context, msg,
subtype_label, supertype_label, code=code):
return False
if self.should_suppress_optional_error([subtype]):
return False
extra_info = [] # type: List[str]
Expand Down Expand Up @@ -4378,6 +4380,22 @@ def infer_issubclass_maps(self, node: CallExpr,
yes_map, no_map = map(convert_to_typetype, (yes_map, no_map))
return yes_map, no_map

def check_tuple_assignment(self,
subtype: ProperType,
supertype: ProperType,
context: Context,
msg: str = message_registry.INCOMPATIBLE_TYPES,
subtype_label: Optional[str] = None,
supertype_label: Optional[str] = None,
code: Optional[ErrorCode] = None) -> bool:
if (isinstance(subtype, TupleType)
and isinstance(supertype, Instance)
and supertype.type.fullname == 'builtins.tuple'):
# TODO:
self.fail("error message", context, code=code)
return True
return False


def conditional_type_map(expr: Expression,
current_type: Optional[Type],
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