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

typecheck: Adding check for type resolving to generic containing same type #535

Merged

Conversation

justinpark715
Copy link
Contributor

Prompted by recursion errors raised by student code when creating nested lists with append

@@ -505,7 +505,10 @@ def resolve(self, t: type) -> TypeResult:
try:
repr = self.find_repr(self.type_to_tnode[str(t)])
if repr and repr.type is not t:
return self.resolve(repr.type)
if getattr(repr.type, '__args__', None) is not None and any(elt is t for elt in repr.type.__args__):
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be simplified by using getattr directly in the comprehension in the any: any(elt is t for elt in getattr(...)), of course choosing a good default value.

@david-yz-liu david-yz-liu merged commit 2dae560 into pyta-uoft:master Aug 8, 2018
@justinpark715 justinpark715 deleted the resolve-generic-typevar branch August 9, 2018 15:15
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