Skip to content
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

(📚) documentation for B028 is misleading #14289

Open
KotlinIsland opened this issue Nov 12, 2024 · 0 comments
Open

(📚) documentation for B028 is misleading #14289

KotlinIsland opened this issue Nov 12, 2024 · 0 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@KotlinIsland
Copy link
Contributor

KotlinIsland commented Nov 12, 2024

The warnings.warn method uses a stacklevel of 1 by default, which limits the rendered stack trace to that of the line on which the warn method is called.

https://docs.astral.sh/ruff/rules/no-explicit-stacklevel/#no-explicit-stacklevel-b028

reading this, it implies that if a higher number is set, then the stack trace will contain multiple entries

It's recommended to use a stacklevel of 2 or higher, give the caller more context about the warning.

- give
+ giving
OR
+ to give

maybe

The `warnings.warn` method uses a stacklevel of 1 by default, which will output a stack frame of the line on which the `warn` method is called. Setting it to a higher number will output a stack frame from higher up the stack.

It's recommended to use a `stacklevel` of 2 or higher, to give the caller a more appropriate context about the warning.
@dylwil3 dylwil3 added documentation Improvements or additions to documentation good first issue Good for newcomers labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants