Repository navigation
[py] Add explicit stacklevel=2 to remaining warnings.warn calls - #18244
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
@saiyam-jain-dev thanks. I just pushed a commit to your branch that removed Also, do you use some kind of translator? All of your PR descriptions have really weird Unicode characters throughout them in various places. I just cleaned up your PR description for this one. |
|
Thanks for updating the Ruff ignore list and cleaning up the description, Corey! No translator at all. It was just an issue with my editor and clipboard tool escaping backticks with backslashes and mangling symbols like |
Description
When
warnings.warn()is invoked without an explicitstacklevelargument, Python defaults tostacklevel=1. This causes the emitted warning to point inside Selenium's internal implementation rather than pointing to the caller's callsite that invoked the method.Across most of
py/selenium/webdriver/,warnings.warn(..., stacklevel=2)is already used consistently. However, four call sites omittedstacklevel.This PR:
stacklevel=2on the remaining warning calls so warnings point to the caller's stack frame.DeprecationWarningtowith_tag_name().py/test/unit/selenium/webdriver/support/relative_locator_tests.py.B028across the entire Python bindings.Motivation and Context
Improves developer experience and debugging by correctly attributing warnings to the user's code, adhering to Ruff
B028.Types of changes
Checklist