KEMBAR78
Make join of recursive types more robust by ilevkivskyi · Pull Request #13808 · python/mypy · GitHub
Skip to content

Conversation

@ilevkivskyi
Copy link
Member

Fixes #13795

Calculating tuple fallbacks on the fly creates a cycle between joins and subtyping. Although IMO this is conceptually not a right thing, it is hard to get rid of (unless we want to use unions in the fallbacks, cc @JukkaL). So instead I re-worked how join_types() works w.r.t. get_proper_type(), essentially it now follows the golden rule "Always pass on the original type if possible".

@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2022

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

items: list[Type] = []
for i in range(t.length()):
items.append(self.join(t.items[i], self.s.items[i]))
items.append(join_types(t.items[i], self.s.items[i]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be forwarding self.instance_joiner?

Copy link
Member Author

Choose a reason for hiding this comment

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

FWIW it didn't, so it should be a matter of a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also I am not sure it actually should.

@hauntsaninja hauntsaninja merged commit dbe9a88 into python:master Oct 8, 2022
@ilevkivskyi ilevkivskyi deleted the fix-rec-tuple branch October 8, 2022 21:42
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.

Core dumped when using JSON.loads with a recursive type

2 participants