-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Use list[int] instead of typing.List[int] in generics.rst #11377
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
Conversation
Also change typing.Tuple to tuple, typing.Dict to dict, etc. Using standard containers is the best practice moving forward, so we should encourage it in examples. I just deleted the info about `typing.List` and friends from the "Generic class internals" section, since that shouldn't be needed going forward, and I wanted to try to keep this doc as slim as possible.
Also not sure if this is the direction you're looking for, or if this change needs more explicit mention of the difference between |
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.
Thanks, this looks good :-)
Python 3.9 is new enough that I think it's still worth keeping around the deleted note about indexing builtins and just clarifying that it applies only to Python 3.8 and lower.
Sounds good, thanks @hauntsaninja! I added a comment within the code block to make it even more obvious since I thought the modifier in the paragraph before ("For Python 3.8 and below...") would be way too easy to miss. I stacked a new commit on top so the progression is recorded. The two commits should be squashed when they are actually merged. |
Thanks! |
As well as `Dict[X, Y]` -> `dic[X, Y]`, etc. This is a follow-up to python#11377, where just a single page of the docs was transitioned. I did a grep through the docs/ directory for anything matching "List[", "Dict[", "Tuple[", and "Set[" and corrected any examples. Perhaps I missed something, but my goal was to clean all of the docs. I tried to strike a balance of how explicit to be: In places related to collections, such as the "Explicit types for collections" section of `type_inference_and_annotations.rst`, I kept in notes about the differences between `List` and `list`. But in most examples that were focused on some other topic, I just deleted any reference to `typing.List`. I thought any notes there would just add noise. There also is a correction to `command_line.rst`, I tested using `--disallow-any-generics` with `list[int]` and it works fine. There are a few typos and style fixes scattered throughout as well when I touched them.
As well as `Dict[X, Y]` -> `dic[X, Y]`, etc. This is a follow-up to python#11377, where just a single page of the docs was transitioned. I did a grep through the docs/ directory for anything matching "List[", "Dict[", "Tuple[", and "Set[" and corrected any examples. Perhaps I missed something, but my goal was to clean all of the docs. I tried to strike a balance of how explicit to be: In places related to collections, such as the "Explicit types for collections" section of `type_inference_and_annotations.rst`, I kept in notes about the differences between `List` and `list`. But in most examples that were focused on some other topic, I just deleted any reference to `typing.List`. I thought any notes there would just add noise. There also is a correction to `command_line.rst`, I tested using `--disallow-any-generics` with `list[int]` and it works fine. There are a few typos and style fixes scattered throughout as well when I touched them.
Also change typing.Tuple to tuple, typing.Dict to dict, etc.
Also change typing.Tuple to tuple, typing.Dict to dict, etc.
Using standard containers is the best practice moving
forward, so we should encourage it in examples.
I just deleted the info about
typing.List
and friends from the"Generic class internals" section, since that shouldn't be needed
going forward, and I wanted to try to keep this doc as slim as possible.
Description
Doesn't change behavior
Test Plan
Haven't tested rebuilding docs, I assume CI will test that if you approve it to run.