Skip to content

Preserving existing annotations in stubgen #2106

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

Closed
JukkaL opened this issue Sep 7, 2016 · 2 comments
Closed

Preserving existing annotations in stubgen #2106

JukkaL opened this issue Sep 7, 2016 · 2 comments

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Sep 7, 2016

If code has annotations, it would be nice if stubgen would preserve them instead of filtering them out. Example (input -> output):

from mod import Thing
import mod2

def f(x: Thing) -> int:
    mod2.do_stuff()
    # more implementation

->

from mod import Thing

def f(x: Thing) -> int: ...

Maybe we should also (optionally) run type inference so that we could output inferred types for module-level variables and attributes.

See also discussion in #1899.

@yoongu
Copy link

yoongu commented Nov 5, 2016

It would be super helpful to us if this got implemented!

ilevkivskyi pushed a commit that referenced this issue Sep 22, 2017
This PR modifies heavily the stubgen to be able to create better stubs
when processing already annotated files (Implements #2106 ).
It essentially adds annotations on the stubs for:

* Variables/attributes with annotations
* Annotations on functions/methods
* TypeVar declarations
* Type Aliases

It also adds some fixes (handling of generics as base classes,
some formatting fixes in the output) that were natural consequences
of some of the refactoring I made.
@ilevkivskyi
Copy link
Member

This is now implemented in #3169.

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

No branches or pull requests

3 participants