Skip to content

Fix deprecated use of List#28821

Merged
Fidget-Spinner merged 1 commit intopython:mainfrom
MicaelJarniac:patch-2
Oct 9, 2021
Merged

Fix deprecated use of List#28821
Fidget-Spinner merged 1 commit intopython:mainfrom
MicaelJarniac:patch-2

Conversation

@MicaelJarniac
Copy link
Copy Markdown
Contributor

@MicaelJarniac MicaelJarniac commented Oct 8, 2021

Some typing examples were still using `List[...]` instead of `list[...]`.

https://docs.python.org/3/library/typing.html#typing.List
"Deprecated since version 3.9: builtins.list now supports []. See PEP 585 and Generic Alias Type."
@MicaelJarniac
Copy link
Copy Markdown
Contributor Author

This PR is essentially #28814 but targeting the correct branch this time, and fixing two extra occurrences of List on the same document.

@bedevere-bot bedevere-bot added awaiting review docs Documentation in the Doc dir labels Oct 8, 2021
@the-knights-who-say-ni
Copy link
Copy Markdown

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 Missing

Our records indicate the following people have not signed the CLA:

@MicaelJarniac

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
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

@MicaelJarniac
Copy link
Copy Markdown
Contributor Author

I've signed the CLA yesterday, as soon as it asked me to, so I think it should show up here soon.

@Fidget-Spinner Fidget-Spinner added the needs backport to 3.10 only security fixes label Oct 8, 2021
Copy link
Copy Markdown
Member

@Fidget-Spinner Fidget-Spinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for retargeting against main.

@serhiy-storchaka
Copy link
Copy Markdown
Member

What is wrong with using a member of the typing module in the documentation of the typing module? Is not it a purpose of the module documentation?

@MicaelJarniac
Copy link
Copy Markdown
Contributor Author

What is wrong with using a member of the typing module in the documentation of the typing module? Is not it a purpose of the module documentation?

As far as I know, although List is still a member of the typing module, it's said to be deprecated:

Deprecated since version 3.9: builtins.list now supports []. See PEP 585 and Generic Alias Type.
https://docs.python.org/3/library/typing.html#typing.List

The deprecated functionality will be removed from the typing module in the first Python version released 5 years after the release of Python 3.9.0.
https://www.python.org/dev/peps/pep-0585/#implementation

So in my opinion it makes more sense to use the new list[...] instead when writing examples. That way, it's safe to learn from those examples, to use them, and so on.

For me, examples, especially those in the official documentation, should be as up-to-date and "correct" as possible, showing the best practices and the right way of doing things, at least whenever possible.

I believe that having examples that are outdated, using deprecated things, and so on can lead to confusion.

@gvanrossum
Copy link
Copy Markdown
Member

What Ken Jin said. And this is in examples for something else (TypeGuard) that is in typing.py. There’s no particular reason to use deprecated idioms for parts of the example that are just illustrative.

@Fidget-Spinner Fidget-Spinner merged commit a98b273 into python:main Oct 9, 2021
@miss-islington
Copy link
Copy Markdown
Contributor

Thanks @MicaelJarniac for the PR, and @Fidget-Spinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@bedevere-bot
Copy link
Copy Markdown

GH-28825 is a backport of this pull request to the 3.10 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 9, 2021
)

The ``List[...]`` form is deprecated since 3.9.
(cherry picked from commit a98b273)

Co-authored-by: Micael Jarniac <[email protected]>
@Fidget-Spinner
Copy link
Copy Markdown
Member

Thank you @MicaelJarniac for the fix.

@MicaelJarniac MicaelJarniac deleted the patch-2 branch October 10, 2021 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip issue skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants