bpo-37116: Use PEP 570 syntax for positional-only parameters. by serhiy-storchaka · Pull Request #13700 · python/cpython · GitHub
Skip to content

bpo-37116: Use PEP 570 syntax for positional-only parameters.#13700

Merged
serhiy-storchaka merged 13 commits into
python:masterfrom
serhiy-storchaka:use-pep-570-38
Jun 1, 2019
Merged

bpo-37116: Use PEP 570 syntax for positional-only parameters.#13700
serhiy-storchaka merged 13 commits into
python:masterfrom
serhiy-storchaka:use-pep-570-38

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented May 31, 2019

Copy link
Copy Markdown
Member

Based on #12620 but contains only changes that can be applied in 3.8. E.g. only getting rid of *args and name tricks and making self and cls positional-only.

https://bugs.python.org/issue37116

@serhiy-storchaka serhiy-storchaka changed the title Use PEP 570 syntax for positional-only parameters. bpo-37116: Use PEP 570 syntax for positional-only parameters. May 31, 2019

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All LGTM. Very nice cleanups!

It looks like we technically have to add / whenever there's a **kwds (assuming the kwds is passed through and could contain any key)...

Comment thread Lib/string.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not use object()? IIUC all the code below checks for its identity first and then substitutes another dict.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Because semantically the default value for the mapping parameter is an empty dict. The check mapping is _sentinel_dict is merely an optimization (we can avoid to create a ChainMap in this case).

Comment thread Lib/weakref.py
Comment thread Lib/unittest/case.py
@pablogsal

Copy link
Copy Markdown
Member

Thank you very much @serhiy-storchaka for working on this 🎉

Comment thread Lib/unittest/mock.py
Comment thread Lib/unittest/mock.py

@ilevkivskyi ilevkivskyi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typing/abc/collections code LGTM.

@serhiy-storchaka

serhiy-storchaka commented Jun 1, 2019

Copy link
Copy Markdown
Member Author

Yes, we can add / in most cases whenever there's a **kwds.

With bpo-36518 we should not even add it if all positional arguments are required (this covers the majority of cases).

@serhiy-storchaka

Copy link
Copy Markdown
Member Author

@pablogsal The two last bugs related to positional-only arguments I found when worked on this issue.

@tirkarthi tirkarthi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

mock changes LGTM. There are few places where _mock_self is used in the async helpers later assigning to self following older pattern. I will try to change them in another PR so that this is good for beta 1. Thanks Serhiy.

@serhiy-storchaka serhiy-storchaka requested a review from a team as a code owner June 1, 2019 07:38
@serhiy-storchaka serhiy-storchaka merged commit 2085bd0 into python:master Jun 1, 2019
@serhiy-storchaka serhiy-storchaka deleted the use-pep-570-38 branch June 1, 2019 08:00
@bedevere-bot

Copy link
Copy Markdown

DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants