-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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-41810: Reintroduce types.EllipsisType
, .NoneType
& .NotImplementedType
#22336
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA 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 You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
types.EllipsisType
types.EllipsisType
For reference: I just signed the CLA a few minutes ago. |
`type(NotImplemented)` and `type(None)` have, respectively, been replaced with `types.NotImplementedType` and `types.NoneType`
types.EllipsisType
types.EllipsisType
, .NoneType
& .NotImplementedType
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.
I've not done a thorough review yet. These comments are just about the blurb.
Misc/NEWS.d/next/Library/2020-09-20-15-14-05.bpo-41810.7l8lyV.rst
Outdated
Show resolved
Hide resolved
Misc/NEWS.d/next/Library/2020-09-20-15-14-05.bpo-41810.7l8lyV.rst
Outdated
Show resolved
Hide resolved
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
If you want I can remove those changes; they're localized to 0a97a88 and 2791a23 so reverting them should be straightforward. |
@ericvsmith, what do you think? |
I do think it would be easier to review if they were moved to a separate PR, even if it's on the same bpo. |
Reverts python@2791a23 and python@0a97a88. Save this for a follow up.
The changes have been reverted as of 84ebe18. |
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.
I think the docs for the three special objects should not start with “The sole value of the type ...”.
The first sentence should serve as a brief summary of what the object is used for. You can then follow up with the detail about its singleton type.
Otherwise LGTM. Thanks for your patience!
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.
This looks good to me!
It's just mirroring the existing documentation for |
I did not particularly want the change in IDLE, because 1) I am not sure I prefer it (partly because of the extra import) and I don't know that PEP-8 'mandates' it*, and 2) I cannot backport it to actively maintained 3.8 and 3.9 code, so it would cause a merge conflict if I patched that section of code. I checked that the latter seems unlikely in this particular case. I think the effort to 'sanitize' all existing code is futile, since people will continue to put |
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.
Approved, but only with misleading wording fixed.
Doc/library/constants.rst
Outdated
@@ -19,14 +19,15 @@ A small number of constants live in the built-in namespace. They are: | |||
|
|||
.. data:: None | |||
|
|||
The sole value of the type ``NoneType``. ``None`` is frequently used to | |||
The sole value of the type :data:`types.NoneType`. ``None`` is frequently used to |
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.
"The sole value of the type NoneType" is most easily read (parsed) as referring to NoneType's usefulness. I expected it to be followed by 'is to ...' and initially read 'is frequently' as a grammatical error. It took awhile to realize that this is a convoluted way to say 'None'. I strongly recommend a rewording.
The sole value of the type :data:`types.NoneType`. ``None`` is frequently used to | |
''None'' is the only instance of :data:`types.NoneType`. It is frequently used to |
types.NoneType
is already twice identified as a type, so a third mention is not needed.
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.
Based on your and Guido's feedback (#22336 (review)) I'm proposing something like this:
.. data:: None
An object frequently used to represent the absence of a value, as when
default arguments are not passed to a function. Assignments to ``None``
are illegal and raise a :exc:`SyntaxError`.
Sole instance of the :data:`types.NoneType` type.
Any thoughts?
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.
That's much better, I think. Although I'd make the last sentence (with the correct markup): "None is the sole instance of the NoneType type."
Doc/library/constants.rst
Outdated
Sole value of the type :data:`types.NotImplementedType` and a | ||
special value which should be returned by the binary special methods |
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.
See above. Use a parallel construction.
Sole value of the type :data:`types.NotImplementedType` and a | |
special value which should be returned by the binary special methods | |
``NotImplemented is the only instance of :data:`types.NotImplementedType`. It is a | |
special value which should be returned by the binary special methods |
Doc/library/constants.rst
Outdated
@@ -59,7 +60,8 @@ A small number of constants live in the built-in namespace. They are: | |||
.. index:: single: ...; ellipsis literal | |||
.. data:: Ellipsis | |||
|
|||
The same as the ellipsis literal "``...``". Special value used mostly in conjunction | |||
The same as the ellipsis literal "``...``" and sole value of the type |
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.
The same as the ellipsis literal "``...``" and sole value of the type | |
The same as the ellipsis literal "``...``" and the only instance of |
|
||
Reintroduced the :data:`types.EllipsisType`, :data:`types.NoneType` | ||
and :data:`types.NotImplementedType` classes, providing a new set | ||
of types readily interpretable by type checkers. |
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.
I think this and the blurb are fine, providing a reason without saying either that this is the only reason or that these should be use everywhere.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
@terryjreedy the documentation changes have been implemented as of 23ed559. |
* origin/master: (27 commits) bpo-41428: Fix compiler warnings in unionobject.c (pythonGH-22388) bpo-41654: Fix compiler warning in MemoryError_dealloc() (pythonGH-22387) bpo-41833: threading.Thread now uses the target name (pythonGH-22357) bpo-30155: Add macros to get tzinfo from datetime instances (pythonGH-21633) bpo-33822: Update IDLE section of What's New 3.8 (pythonGH-22383) bpo-41844: Add IDLE section to What's New 3.9 (GN-22382) bpo-41841: Prepare IDLE News for 3.10 (pythonGH-22379) bpo-37779 : Add information about the overriding behavior of ConfigParser.read (pythonGH-15177) bpo-40170: Use inline _PyType_HasFeature() function (pythonGH-22375) bpo-40941: Fix stackdepth compiler warnings (pythonGH-22377) bpo-40941: Fix fold_tuple_on_constants() compiler warnings (pythonGH-22378) bpo-40521: Fix PyUnicode_InternInPlace() (pythonGH-22376) bpo-41834: Remove _Py_CheckRecursionLimit variable (pythonGH-22359) bpo-1635741, unicodedata: add ucd_type parameter to UCD_Check() macro (pythonGH-22328) bpo-1635741: Port _lsprof extension to multi-phase init (PEP 489) (pythonGH-22220) bpo-41513: Improve order of adding fractional values. Improve variable names. (pythonGH-22368) bpo-41816: `StrEnum.__str__` is `str.__str__` (pythonGH-22362) bpo-35764: Rewrite the IDLE Calltips doc section (pythonGH-22363) bpo-41810: Reintroduce `types.EllipsisType`, `.NoneType` & `.NotImplementedType` (pythonGH-22336) bpo-41602: raise SIGINT exit code on KeyboardInterrupt from pymain_run_module (python#21956) ...
…mentedType` (pythonGH-22336) closes issue 41810
See the relevant BPO for more details: https://bugs.python.org/issue41810.
https://bugs.python.org/issue41810