Skip to content

Conversation

@dylwil3
Copy link
Collaborator

@dylwil3 dylwil3 commented Dec 7, 2024

This PR introduces an unsafe autofix for no-explicit-stacklevel (B028): we add the stacklevel argument, set to 2.

Closes #14805

let mut diagnostic = Diagnostic::new(NoExplicitStacklevel, call.func.range());

let edit = add_argument(
"stacklevel=2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm super surprised this method doesn't need to know if this is a keyword or positional argument!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also surprised... it seems like it would actually be unsafe to use this method for positional arguments, since it always adds the argument to the end? If that's correct and you'd like me to make a followup PR, let me know - I'd be happy to!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah feel free to take a look!

@charliermarsh charliermarsh added the fixes Related to suggested fixes for violations label Dec 7, 2024
@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@charliermarsh charliermarsh merged commit d340134 into astral-sh:main Dec 7, 2024
21 checks passed
@dylwil3 dylwil3 deleted the stacklevel-fix branch December 7, 2024 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fixes Related to suggested fixes for violations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Autofix request] B028: no-explicit-stacklevel

2 participants