Skip to content

Mark inspect.getmembers as Optional for both Py2 and Py3 #2172

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

Conversation

mlhamel
Copy link
Contributor

@mlhamel mlhamel commented May 29, 2018

Description

Looking at the code of getmembers in Lib/inspect.py (https://github.com/python/cpython/blob/master/Lib/inspect.py#L316) it really like predicate could be None sometime, especially since the default value is None.

And we seems to check even for this possibility at https://github.com/python/cpython/blob/master/Lib/inspect.py#L354

Proposition

Change the type assertion from Callable[[Any], bool] to Optional[Callable[[Any], bool]] both for Python 2 and Python 3 for every versions.

@JelleZijlstra JelleZijlstra merged commit 351d019 into python:master May 29, 2018
@JelleZijlstra
Copy link
Member

Thanks!

yedpodtrzitko pushed a commit to yedpodtrzitko/typeshed that referenced this pull request Jan 23, 2019
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