Clarifying documentation of typing.Set
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
Documentation
Edit: I added some more clarification.
Documentation of typing.Set is not entirely clear
The typing module's documentation currently requires two hops when the reader looks up typing.Set.
- In the docstring of
typing.Setit states "To annotate arguments it is preferred to use an abstract collection type such as AbstractSet." This is referring totyping.AbstractSet - Docstring of
typing.AbstractSetsays that it is deprecated and refers the reader tocollections.abc.Set, which has no docstring of its own (it is grouped together with the docstring ofcollections.abc.MutableSet.
I feel we can prevent these two hops i.e.typing.Set --> typing.AbstractSet --> collections.abc.Setand direct the reader to the final destination i.e.typing.Set -> collections.abc.Set.
Suggested change
typing.Setshould say something like --
"To annotate arguments it is preferred to use an abstract collection type such as
collections.abc.Set.
"To annotate everything else, the use oftyping.Setis deprecated since version 3.9:builtins.setnow supports[]. SeePEP 585andGeneric Alias Type"
- Docstring of
typing.AbstractSetis fine as it is. collections.abc.Setshould say something like --
"Use this to annotate arguments. For all other annotations, use
builtins.set, which now supported[]. SeePEP 585...
Other generic alias types like List, Tuple, FrozenSet etc. probably could use a similar change (IF others agree that this is something that needs to changed at all.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the docstrings for typing.Set and collections.abc.Set, then compare the related generic alias documentation and the guidance in PEP 585. Done means the documentation directs readers from typing.Set to collections.abc.Set without the extra hop and clearly explains when to use builtins.set.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100