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: Update type aliases logic #6355

Closed
ilevkivskyi opened this issue Feb 7, 2019 · 1 comment · Fixed by #6390
Closed

New semantic analyzer: Update type aliases logic #6355

ilevkivskyi opened this issue Feb 7, 2019 · 1 comment · Fixed by #6390
Assignees
Labels
priority-0-high semantic-analyzer Problems that happen during semantic analysis

Comments

@ilevkivskyi
Copy link
Member

The old logic for type aliases will create variables in stead of aliases in case the target is class but it is not ready. An example is:

Text = str

class str(Sequence[str]):
    ...
@ilevkivskyi ilevkivskyi added priority-0-high semantic-analyzer Problems that happen during semantic analysis labels Feb 7, 2019
@ilevkivskyi ilevkivskyi self-assigned this Feb 7, 2019
@JukkaL
Copy link
Collaborator

JukkaL commented Feb 7, 2019

More generally, maybe we should create a PlaceholderNode if the rvalue contains some placeholders.

ilevkivskyi added a commit that referenced this issue Feb 12, 2019
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 added a commit that referenced this issue Feb 15, 2019
…es (and other aliases) (#6390)

Fixes #6355

This does three non-trivial things:
* Creates placeholder with `becomes_typeinfo=True` if r.h.s. is such a placeholder (i.e. the definition is a potential type alias).
* Defers all `Invalid type` and use of corresponding unbound types until final iteration.
* Moves few tests in newly enabled test file to new semantic analyzer only (those where new behaviour is clearly better).

I added a bunch of new tests for things that was broken, plus some variations (although some of them are trivial, replacing `NameExpr` with `MemberExpr` or `IndexExpr`).

I also verified that this PR fixes the crash in mypy self-check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-0-high semantic-analyzer Problems that happen during semantic analysis
Projects
None yet
2 participants