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

New semantic analyzer: Support builtin typing aliases #6358

Merged
merged 23 commits into from
Feb 12, 2019

Conversation

ilevkivskyi
Copy link
Member

Fixes #6297

This adds support for real typeshed stubs that define dummy aliases like typing.List, typing.Dict, etc. This also fixes couple related issues, so that builtin SCC is almost clean (the two remaining errors are #6295 and #6357).

Most notably, this PR introduces some re-ordering of targets in builtin SCC, removing this reordering requires some non-trivial work (namely #6356, #6355, and deferring targets from named_type()).

@ilevkivskyi ilevkivskyi changed the title Support builtin typing aliases New semantic analyzer: Support builtin typing aliases Feb 11, 2019
@ilevkivskyi
Copy link
Member Author

Supporting Final depends on this, so it is better to review this one first.

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

This moves us very close to being able to support full builtins stubs! Looks good, just left a few minor comments. Feel free to merge after you've addressed them.

mypy/newsemanal/semanal.py Outdated Show resolved Hide resolved
# Tuple is special because it is involved in builtin import cycle
# and may be not ready when used.
sym = self.api.lookup_fully_qualified_or_none('builtins.tuple')
if not sym or isinstance(sym.node, PlaceholderNode):
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens if we don't use the correct fixture that defined tuple? Will this still generate a reasonable error message?

Copy link
Member Author

Choose a reason for hiding this comment

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

I fixed this to report a reasonable error, and added a test.

@ilevkivskyi ilevkivskyi merged commit 2ef066f into python:master Feb 12, 2019
@ilevkivskyi ilevkivskyi deleted the support-typing-aliases branch February 12, 2019 15:32
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.

New semantic analyzer: dummy alias definitions in typing stub (List etc.)
2 participants