- Notifications
You must be signed in to change notification settings - Fork675
chore: create a customwarnings.warn wrapper#1882
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 ourterms of service andprivacy 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
codecov-commenter commentedFeb 5, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report
@@ Coverage Diff @@## main #1882 +/- ##==========================================+ Coverage 92.50% 92.52% +0.02%========================================== Files 78 78 Lines 4871 4885 +14 ==========================================+ Hits 4506 4520 +14 Misses 365 365
Flags with carried forward coverage won't be shown.Click here to find out more.
|
JohnVillalovos commentedFeb 5, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Test script: With this PR, warning shows against the script: Without this PR, warning shows against /home/python-gitlab/gitlab/__init__.py:43:DeprecationWarning:Directaccessto'gitlab.OWNER_ACCESS'isdeprecatedandwillberemovedinafuturemajorpython-gitlabrelease.Pleaseuse'gitlab.const.OWNER_ACCESS'instead.warnings.warn( Also tested the REPL with the PR: |
4d14986 toc31c6feComparenejch commentedFeb 6, 2022
Thanks@JohnVillalovos. If I understand correctly you want to show the caller and not the source in our library when showing warnings. Wouldn't this achieve the goal without custom wrappers? warnings.warn(f"\nDirect access to 'gitlab.{name}' is deprecated and will be "f"removed in a future major python-gitlab release. Please "f"use 'gitlab.const.{name}' instead.",DeprecationWarning,stacklevel=2, ) Let me know if that works. |
JohnVillalovos commentedFeb 6, 2022
It works but have to determine what Some of these require |
nejch commentedFeb 6, 2022
Ahh I see, ok, that wasn't clear to me at first glance. I was hoping it was a simpler one-time thing and we'd avoid having a heated debate about required keyword-only arguments but now we'll have to have it 😅 |
nejch 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.
Just had some comments@JohnVillalovos after the explanation now :)
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
c31c6fe tof72a79aCompare7802ade to75c5089CompareCreate a custom `warnings.warn` wrapper that will walk the stack traceto find the first frame outside of the `gitlab/` path to print thewarning against. This will make it easier for users to find where intheir code the error is generated from
75c5089 to6ca9aa2Compare
Create a custom
warnings.warnwrapper that will walk the stack traceto find the first frame outside of the
gitlab/path to print thewarning against. This will make it easier for users to find where in
their code the error is generated from