Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix resolution of ParamSpec in circular dependencies
What's happening here? 1. We load module `bar`, by requesting it from the loader. 1. Before resolving types, we need to load its dependencies. So we load module `foo`. 1. We'd like to load `foo`'s dependencies, but that's `bar` and that's a circle, so we start resolving types in `foo`. 1. When resolving external types we create alias an `foo.bar`, copying the unresolved signature from `bar.bar`. 1. When resolving local types, `_P` is not resolvable within `foo`. 1. We run `visitors.AdjustTypeParameters`, which seems to require local type resolution, and runs afterwards. It declares `_P` in `foo`. Now `_P.args` would be resolvable but we already finished resolving local types and we don't do it again. 1. We resolve types in `bar`, validate `bar`'s AST and return. 1. We load module `foo`, by requesting it from the loader. 1. It's cached. We just need to validate it. We realize that types aren't resolved, yet, e.g. `_P.args`. We used to do only external type resolution again, which did not resolve ParamSpec, and we eventually bailed. This change also adds local type resolution again, which does resolve ParamSpec. PiperOrigin-RevId: 684443947
- Loading branch information