Skip to content

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

Merged
merged 3 commits into from
Nov 2, 2021

Conversation

NickCrews
Copy link
Contributor

@NickCrews NickCrews commented Oct 23, 2021

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.

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.
@NickCrews
Copy link
Contributor Author

Also not sure if this is the direction you're looking for, or if this change needs more explicit mention of the difference between typing.Dict and dict, etc.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a 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.

@NickCrews
Copy link
Contributor Author

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.

@hauntsaninja hauntsaninja merged commit 5703bec into python:master Nov 2, 2021
@hauntsaninja
Copy link
Collaborator

Thanks!

NickCrews added a commit to NickCrews/mypy that referenced this pull request Nov 3, 2021
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.
NickCrews added a commit to NickCrews/mypy that referenced this pull request Nov 3, 2021
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.
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this pull request Jan 20, 2022
Also change typing.Tuple to tuple, typing.Dict to dict, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants