-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Add --include-private option to stubgen to include private members. #3367
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
Conversation
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! Mostly looks good to me, just have few comments about test infrastructure.
mypy/stubgen.py
Outdated
except Exception as e: | ||
if not options.ignore_errors: | ||
raise e | ||
else: | ||
print("Stub generation failed for", module, file=sys.stderr) | ||
|
||
|
||
def parse_options() -> Options: | ||
args = sys.argv[1:] | ||
def parse_options(args: Optional[List[str]] = None) -> Options: |
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.
Do I understand correctly that this signature change is needed only for tests?
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.
Correct. Would you prefer that I make args
non-optional and pass sys.argv
from main
?
mypy/test/teststubgen.py
Outdated
@@ -104,11 +104,20 @@ def cases(self) -> List[DataDrivenTestCase]: | |||
return c | |||
|
|||
|
|||
def parse_args(line: str) -> Options: | |||
if line.startswith('# opts:'): |
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.
In other mypy tests this is called # flags:
, so that it would be better to be consistent.
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.
Ah, thanks, I missed that. I'll update this to behave like the others.
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! Now this looks good to me.
Thanks! |
I've found this option to be useful when generating stubs for some third party modules. It can also be useful when using stubs for internal use in place of comments annotations in python2. In this scenario, where stubs are used to type check their corresponding files, you can't omit members.