Skip to content

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

Merged
merged 3 commits into from
May 17, 2017

Conversation

chadrik
Copy link
Contributor

@chadrik chadrik commented May 15, 2017

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.

Copy link
Member

@ilevkivskyi ilevkivskyi left a 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:
Copy link
Member

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?

Copy link
Contributor Author

@chadrik chadrik May 16, 2017

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?

@@ -104,11 +104,20 @@ def cases(self) -> List[DataDrivenTestCase]:
return c


def parse_args(line: str) -> Options:
if line.startswith('# opts:'):
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@ilevkivskyi ilevkivskyi left a 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.

@ilevkivskyi ilevkivskyi merged commit 2ca2eb4 into python:master May 17, 2017
@chadrik
Copy link
Contributor Author

chadrik commented May 17, 2017

Thanks!

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.

2 participants