Skip to content
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

bpo-38008: Move builtin protocol whitelist to mapping instead of list #15647

Merged
merged 3 commits into from
Sep 12, 2019

Conversation

jivid
Copy link
Contributor

@jivid jivid commented Sep 2, 2019

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Our records indicate we have not received your CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

Lib/typing.py Outdated
'Hashable', 'Sized', 'Container', 'Collection', 'Reversible',
'ContextManager', 'AsyncContextManager']
_PROTO_WHITELIST = {
'Callable': 'collections.abc',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to write code in this way.
'Callable': collections.abc.__name__,
It can catch typo error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively I would just avoid the repetition by making _PROTO_WHITELIST a dictionary mapping module to set of names in it. So that the code below would be

    base.__module__ in _PROTO_WHITELIST and
    base.__name__ in _PROTO_WHITELIST[base.__module__]

Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add news entries by using blurb tool.

https://devguide.python.org/committing/#what-s-new-and-news-entries

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 for PR!

I have just one suggestion, could you please add some tests? (and a news entry as @corona10 suggested)

Lib/typing.py Outdated
'Hashable', 'Sized', 'Container', 'Collection', 'Reversible',
'ContextManager', 'AsyncContextManager']
_PROTO_WHITELIST = {
'Callable': 'collections.abc',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively I would just avoid the repetition by making _PROTO_WHITELIST a dictionary mapping module to set of names in it. So that the code below would be

    base.__module__ in _PROTO_WHITELIST and
    base.__name__ in _PROTO_WHITELIST[base.__module__]

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, LGTM!

(Also there is a tool called blurb, so that you don't need to create the news items manually.)

@jivid
Copy link
Contributor Author

jivid commented Sep 12, 2019

Thanks @ilevkivskyi, didn't know about that!

@ilevkivskyi ilevkivskyi added needs backport to 3.8 type-bug An unexpected behavior, bug, or error labels Sep 12, 2019
@ilevkivskyi ilevkivskyi merged commit 692a0dc into python:master Sep 12, 2019
@miss-islington
Copy link
Contributor

Thanks @jivid for the PR, and @ilevkivskyi for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 12, 2019
@bedevere-bot
Copy link

GH-16021 is a backport of this pull request to the 3.8 branch.

miss-islington added a commit that referenced this pull request Sep 12, 2019
YouJiacheng added a commit to YouJiacheng/typing_extensions that referenced this pull request Mar 28, 2023
and rename _PROTO_WHITELIST to _PROTO_ALLOWLIST

taken from python/cpython#15647 and python/cpython#21825
YouJiacheng added a commit to YouJiacheng/typing_extensions that referenced this pull request Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants