Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-106240: Add stdlib_deprecations module#106241
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
vstinner commented Jun 29, 2023 • edited by github-actions bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by github-actions bot
Uh oh!
There was an error while loading. Please reload this page.
vstinner commented Jun 29, 2023
This PR is incomplete: I wrote it to propose the idea of a new "stdlib_deprecations" module: API to query if a function is deprecated or not. The API should be designed. So far, I only proposed a very basic API:
Internally, I wrote a dataclass which contains the following data:
My current API doesn't provide all data. Maybe the API should be TODO: enhance the API to support other deprecation kinds, like deprecation of a function parameter. I propose |
vstinner commented Jun 29, 2023
cc @hugovk |
sobolevn left a comment
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.
I like the idea! 👍
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ec8e571 to 50a6e53Comparevstinner commented Jun 29, 2023
I changed the API to: |
| _deprecate('asynchat', '3.6', remove='3.12', replace='asyncio'), | ||
| _deprecate('smtpd', '3.6', remove='3.12', replace='aiosmtp'), | ||
| _deprecate('ssl.RAND_pseudo_bytes', '3.6', remove='3.12', | ||
| replace='os.urandom()'), |
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.
Does this mean the exact call os.urandom() without args, or is it a reference to the function with parentheses added like in C documentation?
Being a Python dev and not a C dev, I take os.urandom to mean one thing and os.urandom() to mean another thing!
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.
os.urandom() has no arguments. Adding parenthesis is a hint to show that it's a function
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.
OK but my point is that it’s not a great doc convention for Python. I think the functions that follow need arguments but have () too, that’s misleading.
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.
I presume that ssl.RAND_pseudo_bytes is the name of a function. The exact replacement is os.random, without (). I think it should be given than way.
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.
In practice, I expect that the most usual usage of a function like ssl.RAND_pseudo_bytes is to call it: ssl.RAND_pseudo_bytes(). So I prefer to specify the replacement with parenthesis as well: os.urandom(). In my current implementation, Deprecation.message is an arbitrary string, it's not designed to automate replacement by a linter or a similar tool.
50a6e53 to b717488Comparevstinner commented Jun 30, 2023
It seems like pylint would prefer a JSON file than a stdlib module. I'm not sure that this module is a good idea :-) |
michaelfm1211 commented Jul 1, 2023
Just from a quick look over the documentation preview, it looks like there's something wrong with the synatx. The |
vstinner commented Jul 1, 2023
Oh right, it was because of |
vstinner commented Jul 1, 2023
I'm not sure about this approach. Linters developpers seem to prefer JSON files rather than an import. |
merwok commented Jul 2, 2023
Yea, the discussion thread seems to agree on a data file rather than a module. |
vstinner commented Jul 3, 2023
Right. I close my issue and its PR. |
📚 Documentation preview 📚: https://cpython-previews--106241.org.readthedocs.build/