Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-42280: Clarify docs on standard generic collections#29308
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
AlexWaygood commented Oct 29, 2021 • edited by bedevere-bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-bot
Uh oh!
There was an error while loading. Please reload this page.
This PR proposes adding two classes to the list of standard generic collections in the docs. These classes can be parametrised at runtime, but are currently omitted from the list. The PR also tweaks the wording introducing the list, to make clear that the docs are not promising that this is an exhaustive list. The PR does not add any of the classes from the ``queue`` module (``queue.Queue``, ``queue.LifoQueue``, ``queue.PriorityQueue``, ``queue.SimpleQueue``), even though these can be parametrised. I have excluded these from the PR, as the documentation states that this is a list of "standard-library collections", and the ``queue`` classes are not collections (they are neither sized, nor iterable). However, ``re.Pattern`` is included in this list, and ``re.Pattern`` objects are also not collections -- so, perhaps the ``queue`` classes should also be added to this list.
Fidget-Spinner commented Oct 29, 2021
I would prefer we explicitly say "This list is non-exhaustive.". We won't be able to keep up with all the classes supporting Related issue https://bugs.python.org/issue42280. |
AlexWaygood commented Oct 29, 2021
Ah, apologies, I didn't realise there was already an issue on this. I just stumbled across the list while doing the PR for the typing documentation. I agree with the thoughts on the BPO thread -- I think it's much wiser to clarify that the list is non-exhaustive rather than to attempt to put together an exhaustive list. Have edited the PR. |
Fidget-Spinner commented Oct 29, 2021
Yeah no issues (pun intended) there. I just linked the issue to provide some context behind our current stance. You don't have to link this PR to that (though I don't mind you linking it either :). |
Uh oh!
There was an error while loading. Please reload this page.
ambv commented Oct 29, 2021
@AlexWaygood, now that I think about it, I think you're making a good point about "collections" not being "collections" in the list. How about we fix it by:
|
AlexWaygood commented Oct 29, 2021
...how are we defining "data structures"? 🤔 If I think I'd be tempted to split it into two lists: a list of standard library collections that can be parameterised, and a list of standard library ABCs that can be parameterised. We have widely agreed-upon definitions for what constitutes a "collection" and what constitutes an "ABC", so it would make this problem easier to tackle. But I'm not sure the classes from the |
AlexWaygood commented Oct 30, 2021
I'm going to close this PR and open a new one. |
The documentation on ``GenericAlias`` objects implies at multiple points that only container classes can define ``__class_getitem__``. This is misleading. This PR proposes a rewrite of the documentation to clarify that non-container classes can define ``__class_getitem__``, and to clarify what it means when a non-container class is parameterized. See also: initial discussion of issues with this piece of documentation in python#29308, and previous BPO issue [42280](https://bugs.python.org/issue42280).
The documentation on ``GenericAlias`` objects implies at multiple points that only container classes can define ``__class_getitem__``. This is misleading. This PR proposes a rewrite of the documentation to clarify that non-container classes can define ``__class_getitem__``, and to clarify what it means when a non-container class is parameterized. See also: initial discussion of issues with this piece of documentation in GH-29308, and previous BPO issue [42280](https://bugs.python.org/issue42280). Also improved references in glossary and typing docs. Fixed some links. Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no> Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
…H-29335) The documentation on ``GenericAlias`` objects implies at multiple points that only container classes can define ``__class_getitem__``. This is misleading. This PR proposes a rewrite of the documentation to clarify that non-container classes can define ``__class_getitem__``, and to clarify what it means when a non-container class is parameterized. See also: initial discussion of issues with this piece of documentation in pythonGH-29308, and previous BPO issue [42280](https://bugs.python.org/issue42280). Also improved references in glossary and typing docs. Fixed some links. Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no> Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> (cherry picked from commit 0eae9a2) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
…H-29335) The documentation on ``GenericAlias`` objects implies at multiple points that only container classes can define ``__class_getitem__``. This is misleading. This PR proposes a rewrite of the documentation to clarify that non-container classes can define ``__class_getitem__``, and to clarify what it means when a non-container class is parameterized. See also: initial discussion of issues with this piece of documentation in pythonGH-29308, and previous BPO issue [42280](https://bugs.python.org/issue42280). Also improved references in glossary and typing docs. Fixed some links. Co-Authored-By: Erlend Egeberg Aasland <erlend.aasland@innova.no> Co-Authored-By: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-Authored-By: Alex Waygood <Alex.Waygood@Gmail.com>
…H-29335) (GH-30688) The documentation on ``GenericAlias`` objects implies at multiple points that only container classes can define ``__class_getitem__``. This is misleading. This PR proposes a rewrite of the documentation to clarify that non-container classes can define ``__class_getitem__``, and to clarify what it means when a non-container class is parameterized. See also: initial discussion of issues with this piece of documentation in GH-29308, and previous BPO issue [42280](). Also improved references in glossary and typing docs. Fixed some links. Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no> Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> (cherry picked from commit 0eae9a2) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Automerge-Triggered-By: GH:Fidget-Spinner
…H-29335) (GH-30689) The documentation on ``GenericAlias`` objects implies at multiple points that only container classes can define ``__class_getitem__``. This is misleading. This PR proposes a rewrite of the documentation to clarify that non-container classes can define ``__class_getitem__``, and to clarify what it means when a non-container class is parameterized. See also: initial discussion of issues with this piece of documentation in GH-29308, and previous BPO issue [42280](https://bugs.python.org/issue42280). Also improved references in glossary and typing docs. Fixed some links. (cherry picked from commit 0eae9a2) Co-Authored-By: Erlend Egeberg Aasland <erlend.aasland@innova.no> Co-Authored-By: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-Authored-By: Alex Waygood <Alex.Waygood@Gmail.com>
…ythonGH-29335) (pythonGH-30689) The documentation on ``GenericAlias`` objects implies at multiple points that only container classes can define ``__class_getitem__``. This is misleading. This PR proposes a rewrite of the documentation to clarify that non-container classes can define ``__class_getitem__``, and to clarify what it means when a non-container class is parameterized. See also: initial discussion of issues with this piece of documentation in pythonGH-29308, and previous BPO issue [42280](https://bugs.python.org/issue42280). Also improved references in glossary and typing docs. Fixed some links. (cherry picked from commit 0eae9a2) Co-Authored-By: Erlend Egeberg Aasland <erlend.aasland@innova.no> Co-Authored-By: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-Authored-By: Alex Waygood <Alex.Waygood@Gmail.com>
This PR proposes adding two classes to the list of standard generic collections in the docs. These classes can be parametrised at runtime, but are currently omitted from the list.
The PR also tweaks the wording introducing the list, to make clear that the docs are not promising that this is an exhaustive list.
The PR does not add any of the classes from the
queuemodule (queue.Queue,queue.LifoQueue,queue.PriorityQueue,queue.SimpleQueue), even though these can be parametrised. I have excluded these from the PR, as the documentation states that this is a list of "standard-library collections", and thequeueclasses are not collections (they are neither sized, nor iterable). However,re.Patternis included in this list, andre.Patternobjects are also not collections -- so, perhaps thequeueclasses should also be added to this list.https://bugs.python.org/issue42280