FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-90953: Emit deprecation warnings for `ast` features deprecated in Python 3.8 by AlexWaygood · Pull Request #104199 · python/cpython · GitHub

/ cpython Public

gh-90953: Emit deprecation warnings for ast features deprecated in Python 3.8 - #104199

Merged
AlexWaygood merged 29 commits into
python:mainfrom
AlexWaygood:ast-deprecation-warnings
May 6, 2023
Merged

gh-90953: Emit deprecation warnings for ast features deprecated in Python 3.8#104199
AlexWaygood merged 29 commits into
python:mainfrom
AlexWaygood:ast-deprecation-warnings

Conversation

AlexWaygood commented May 5, 2023
edited
Loading

Copy link
Copy Markdown
Member

This is a continuation of @serhiy-storchaka's PR #31432, but removes the deprecation warnings for ast.ExtSlice and ast.Index, which were only deprecated in Python 3.9 (rationale for excluding them: #31432 (comment)).


📚 Documentation preview 📚: https://cpython-previews--104199.org.readthedocs.build/

AlexWaygood added type-feature A feature request or enhancement stdlib Standard Library Python modules in the Lib/ directory 3.12 only security fixes labels May 5, 2023
AlexWaygood requested a review from isidentical as a code owner May 5, 2023 12:03
Comment thread Doc/whatsnew/3.12.rst Outdated
Comment thread Doc/whatsnew/3.12.rst Outdated
Comment thread Doc/whatsnew/3.12.rst Outdated
Comment thread Lib/test/test_ast.py
self.assertIsInstance(n, N)
self.assertIsinstance(n, ast.Num)
self.assertNotIsInstance(n, N2)
self.assertNotIsInstance(ast.Num(42), N)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nice :)

By the way, https://github.com/isidentical/teyit / https://pypi.org/project/teyit/ is a nice tool that can upgrade some of these automatically.

barneygale left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is it necessary to emit deprecation warnings when the names are accessed on the ast module? Would it not be sufficient to emit warnings when these classes are instantiated (+ isinstance etc)?

Comment thread Lib/ast.py
Comment thread Lib/ast.py Outdated

Copy link
Copy Markdown
Member Author

Is it necessary to emit deprecation warnings when the names are accessed on the ast module? Would it not be sufficient to emit warnings when these classes are instantiated (+ isinstance etc)?

I guess I lean towards keeping them just to ensure maximum visibility. There are edge cases where you might not be "using" the class or calling isinstance() on it, but you do reference it (if type(blah) is ast.Num, etc.). But you are right that we could probably simplify the code somewhat if we only warned on instantiation and isinstance() checks.

@hugovk, do you have any thoughts on this?

hugovk commented May 6, 2023

Copy link
Copy Markdown
Member

If there are two common ways of accessing something, I'd also lean towards more visibility for both.

Speaking from a position of having dealt with the fallout of removing something without a DeprecationWarning first, just mentioning in docs :)

AlexWaygood enabled auto-merge (squash) May 6, 2023 16:20

AlexWaygood commented May 6, 2023
edited
Loading

Copy link
Copy Markdown
Member Author

Thanks very much, both of you!

AlexWaygood merged commit 376137f into python:main May 6, 2023
AlexWaygood deleted the ast-deprecation-warnings branch May 6, 2023 16:51
jbower-fb pushed a commit to jbower-fb/cpython that referenced this pull request May 8, 2023
…ed in Python 3.8 (python#104199)

`ast.Num`, `ast.Str`, `ast.Bytes`, `ast.Ellipsis` and `ast.NameConstant` now all emit deprecation warnings on import, access, instantation or `isinstance()` checks.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

Copy link
Copy Markdown
Member

@AlexWaygood Is it time to make the PR to remove them now?

Copy link
Copy Markdown
Member Author

@AlexWaygood Is it time to make the PR to remove them now?

yes

Copy link
Copy Markdown
Member Author

@AlexWaygood Is it time to make the PR to remove them now?

See #119563

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.12 only security fixes stdlib Standard Library Python modules in the Lib/ directory type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants


Back | FazBrowse Home | New Git URL