Skip to content

Avoid forgetting about stacklevel in warnings#2594

Merged
Avasam merged 5 commits intomhammond:mainfrom
Avasam:Avoid-forgetting-about-stacklevel-in-warnings
Jun 22, 2025
Merged

Avoid forgetting about stacklevel in warnings#2594
Avasam merged 5 commits intomhammond:mainfrom
Avasam:Avoid-forgetting-about-stacklevel-in-warnings

Conversation

@Avasam
Copy link
Copy Markdown
Collaborator

@Avasam Avasam commented Apr 30, 2025

I myself forget about it from time to time.

stacklevel=2 helps point the warning to the caller's code.

B028 only warns if no stacklevel is specified. stacklevel=1 is perfectly valid if explicit about it. It doesn't force a specific level, it just makes it so you can't forget.

This is optionally autofixable (ruff check --fix --unsafe-fixes) to stacklevel=2.

@Avasam Avasam force-pushed the Avoid-forgetting-about-stacklevel-in-warnings branch from 49f0fe8 to 51b5992 Compare April 30, 2025 23:03
Comment thread Pythonwin/pywin/framework/app.py
Comment thread Pythonwin/pywin/framework/dbgcommands.py
@Avasam
Copy link
Copy Markdown
Collaborator Author

Avasam commented Jun 18, 2025

Back to stacklevel 1 those unactionable warnings go !

@Avasam Avasam merged commit e57a738 into mhammond:main Jun 22, 2025
28 checks passed
@Avasam Avasam deleted the Avoid-forgetting-about-stacklevel-in-warnings branch June 22, 2025 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants