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

Consider deferring module top level in type checker #6356

Open
ilevkivskyi opened this issue Feb 7, 2019 · 4 comments
Open

Consider deferring module top level in type checker #6356

ilevkivskyi opened this issue Feb 7, 2019 · 4 comments

Comments

@ilevkivskyi
Copy link
Member

We currently never defer module top levels in type checker. This can cause some Cannot determine type of x errors in import cycles. They are real in some sense, because such code would almost certainly fail at runtime. However, this might sometimes be useful in stubs (as practice shows, this is however not important and shows up only in highly entangled import cycles, such as e.g. builtins SCC).

@ilevkivskyi
Copy link
Member Author

See #6312 for an example when the error happens.

@russelldavis
Copy link

They are real in some sense, because such code would almost certainly fail at runtime.

I think it's import to distinguish the ones that would fail at runtime from the ones that would not. I think there are a lot of common cases that do not fail at runtime that are worth supporting.

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
Copy link
Member Author

With some more experience, it looks like this can cause troubles.

More generally, the deferral in type checker is different from both semantic analyzer and the daemon: the first two defer either module top level or top-level function and defer until fixed point (our large cut-off), while type checker never defers module top levels, and defers innermost functions, and have hard-coded small number of deferrals.

@ilevkivskyi
Copy link
Member Author

(Raising priority to high since this appeared again.)

@ilevkivskyi ilevkivskyi removed their assignment Dec 9, 2019
everything411 pushed a commit to BITNP/keycloak-account-service that referenced this issue Aug 22, 2023
with some refactor to make sure oauth2_scheme can be passed to depends,
and to make mypy happy:
python/mypy#6356
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants