-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
stubgen: Allow aliases below the top level #14388
Conversation
6e2a9f7
to
42af1f1
Compare
@hauntsaninja do you mind giving this a review? |
42af1f1
to
8ca84eb
Compare
Anyone have a minute for this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks reasonable.
Can we just make this the default and not have it be configurable? Could you also add some assignment statements inside methods in the test case to prove that they don't get included.
I was inclined to do that, but I don't know why it was specifically limited to module aliases in the first place. I can't see the scenario where that's preferable. I'm happy to delegate that decision to you or anyone else in the mypy crew.
sure. |
Let's make it the default |
8ca84eb
to
274cbc1
Compare
I backed out the commit that added the cli arg, and added a function level alias to the test. waiting for CI tests to pass. |
ready to go! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
(Explain how this PR changes mypy.)
stubgen currently allows a variable to be an alias to another, but only at the module level.
For example:
produces:
At the class level, these aliased variables are marked as
Incomplete
.In my experience, enabling aliases below the top level produces better stubs.
I'm not sure what the original reservations were around use of these aliases. If the concerns about class-level aliases are still valid, I can add an option to enable them.