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

Protocol support #163

Closed
wants to merge 50 commits into from
Closed

Protocol support #163

wants to merge 50 commits into from

Conversation

JelleZijlstra
Copy link
Contributor

@JelleZijlstra JelleZijlstra commented May 2, 2021

  • Fix 3.7
  • Extract protocols from stubs
  • Make protocol bases from typeshed work
  • Test against internal codebase
  • Profile to see if some additional caching is valuable

@JelleZijlstra
Copy link
Contributor Author

I added a LazyValue to help with some recursive protocols; e.g. typing.Iterable and typing.Iterator are mutually recursive. This has become complicated enough that I'm going to try to extract some smaller parts and land them separately.

@JelleZijlstra
Copy link
Contributor Author

Current status:

  • Need to fix one more test
  • Incompatible argument type for actual: expected Container[Any] but got str still happens

@JelleZijlstra
Copy link
Contributor Author

I've been sitting on this for a while and I think the approach in this branch (a new Value class) won't work well.

What I'd like to do instead:

  • TypedValue can contain either a type or a fully-qualified reference to a type defined in a stub.
  • We lazily create something like the current TypeObject from that type or reference. The type object contains flags for whether it is a structural or a nominal type, and further information for types defined only in stubs (like the method dictionary).
  • Creating the TypeObject will require a typeshed client, so we do it lazily in can_assign().
  • Applying typevars should probably make a new TypeObject.

@JelleZijlstra
Copy link
Contributor Author

#295 implements a basic version of the above (only for stub-only protocols for now). Closing this PR (which is full of merge conflicts anyway).

@JelleZijlstra JelleZijlstra deleted the protocol branch December 8, 2021 05:49
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.

None yet

1 participant