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

Merge in TypeVars and Generic base classes in ApplyTypeAnnotationVisitor #596

Merged
merged 1 commit into from
Jan 14, 2022
Merged

Merge in TypeVars and Generic base classes in ApplyTypeAnnotationVisitor #596

merged 1 commit into from
Jan 14, 2022

Conversation

martindemello
Copy link
Contributor

  • Tracks TypeVars that are used in type annotations in the pyi file, and
    adds their Assign statements to the merged file.
  • Adds Generic[T] as a base class if needed.

* Tracks TypeVars that are used in type annotations in the pyi file, and
  adds their Assign statements to the merged file.
* Adds Generic[T] as a base class if needed.
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 12, 2022
Copy link
Contributor

@stroxler stroxler left a comment

Choose a reason for hiding this comment

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

This looks great, thanks!

One question for you: will it work for your use case to match on just TypeVar, under the assumption that a stub always uses from typing import TypeVar?

Reason being, I think the current match won't work if the call is to typing.TypeVar.

If that's good enough for you, I'd say let's merge and I'll look at generalizing later. If not, my suggestion would be to get rid of the filter on Name, and instead use the qualified name provider to get the full name and compare to typing.TypeVar.

@martindemello
Copy link
Contributor Author

yes, i think just TypeVar should be fine for now, we typically don't qualify typing imports. the logic to not add unnecessary typevars is not 100% but it should be good enough to merge and augment later.

Copy link
Contributor

@stroxler stroxler left a comment

Choose a reason for hiding this comment

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

Sounds good.

I'll aim to use QalifiedNameProvider at some later point but happy to unblock you now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants