Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upFix `issubclass()` to narrow down types of type variables #7930
Conversation
Thanks for PR! Here I have few comments. |
This comment has been minimized.
This comment has been minimized.
Thanks for the detailed review! I patched it up in df62cbc
|
Thanks for updates! Here are some more comments. |
@@ -3726,32 +3726,7 @@ def find_isinstance_check(self, node: Expression | |||
elif refers_to_fullname(node.callee, 'builtins.issubclass'): | |||
if len(node.args) != 2: # the error will be reported elsewhere | |||
return {}, {} | |||
expr = node.args[0] | |||
if literal(expr) == LITERAL_TYPE: |
This comment has been minimized.
This comment has been minimized.
ilevkivskyi
Nov 13, 2019
Collaborator
I would keep the above two lines in this function. To make the refactoring more 1-to-1.
@@ -4194,6 +4169,40 @@ def push_type_map(self, type_map: 'TypeMap') -> None: | |||
for expr, type in type_map.items(): | |||
self.binder.put(expr, type) | |||
|
|||
def infer_issubclass_maps(self, node: CallExpr, | |||
type_map: Dict[Expression, Type] | |||
) -> Tuple[TypeMap, TypeMap]: |
This comment has been minimized.
This comment has been minimized.
return other.field | ||
return 0 | ||
|
||
[builtins fixtures/isinstancelist.pyi] |
This comment has been minimized.
This comment has been minimized.
ilevkivskyi
Nov 13, 2019
Collaborator
OK, now the two classes don't look the same, but you didn't do what I asked, I wanted type variables with different upper bounds, like Type[SomeClass]
, not just type
.
…ring for helper
Some more comments here. Also please don't hurry, it is not a competition. |
This comment has been minimized.
This comment has been minimized.
You are right and I shouldn't be in such a hurry. I had some misunderstanding about this issue from the very beginning and that mistake continues in my testcase. I apologize for that and am trying my best to fill my knowledge gap on type systems(mainly by reading TAPL) Now I look it again and realize |
Looks good now, thanks! |
This comment has been minimized.
This comment has been minimized.
Thanks for the guidance! Again, quite an education on both software engineering and type system aspects and that means a lot to me. |
TH3CHARLie commentedNov 12, 2019
•
edited
resolves #7920
Currently, no testcases break so I did not look into
meet.py
for further investigation