-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[py] added decorator for handling deprecations. #12432
[py] added decorator for handling deprecations. #12432
Conversation
This is a cool idea, but I'm not sure the advantage of this over a more straightforward method? Does it show up differently in the IDE with this annotation? Does the wrapper know the name of the function so we don't have to put it in the string? |
py/selenium/deprecated.py
Outdated
for attr in attrs: | ||
_attr = getattr(args[0], attr, None) | ||
if _attr: | ||
warn(f"'{message}': will be removed from {removed_from_version}", DeprecationWarning, stacklevel=2) |
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 stacklevel=2
play nice with a decorator (especially one with args?) in terms of the stack in the output? would need to double check
this stuff is quite trick with edge cases, for example a from selenium.deprecations import deprecated
deprecated(message=..., version=4.12") Theres possibly alot of edge cases with the decorator approach. |
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## trunk #12432 +/- ##
==========================================
- Coverage 57.40% 56.65% -0.76%
==========================================
Files 86 87 +1
Lines 5369 5368 -1
Branches 206 207 +1
==========================================
- Hits 3082 3041 -41
- Misses 2081 2120 +39
- Partials 206 207 +1
☔ View full report in Codecov by Sentry. |
Yes wrappers know the name of the function. |
I have checked for |
630a135
to
5e7b404
Compare
Getting |
Actually we don't have to write custom decorator. In |
aha, this is the PR I was looking for last week and couldn't find when I raised #13402 I think we decided we want to use the annotation that is in |
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
The motivation for this PR is #12409
In this PR, I have created a decorator to handle deprecations in a much better and maintainable way.
Motivation and Context
deprecated_function
anddeprecated_attributes
inselenium/deprecated.py
deprecated_function
decorator which takes care of logging warning message and from what version of selenium the function would be deprecated.deprecated_attributes
decorator, which takes care of logging appropriate warning message for corresponding deprecated variable.Types of changes
Checklist