Skip to content

Conversation

@FozzieHi
Copy link
Contributor

This PR adds a lint which checks for an explicitly defined stacklevel keyword argument on the warn method from the warnings module. If stacklevel is not explicitly defined, this lint triggers. See #299 for more information.

I am new to this project and ASTs in general, so any feedback is appreciated! Specifically I don't know whether this should be B028 or B029, as B028 was used before by B907.

Closes #299

Copy link
Collaborator

@cooperlees cooperlees left a comment

Choose a reason for hiding this comment

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

Many thanks. I've seen this a lot and is a good new addition to me. I'm also happy to reuse B028 since we renamed the old check to be optional ...

Will leave for 24 hours to let others comment.

@jakkdl
Copy link
Contributor

jakkdl commented Jan 31, 2023

Since B028 had a bunch of false positives I suspect there are going to be some configs out there that disabled it, and unless they closely track development haven't re-enabled it since it became optional. But I suspect there's not a ton of those, and B028 was renamed within three days, so it's probably fine to expect those people to update their configs. But one could also let B028 be for some time before using it again.

(it would be nice if there was a warning for disabled checks that don't exist... 🤔)

@cooperlees cooperlees merged commit e7bbdeb into PyCQA:main Feb 2, 2023
@FozzieHi FozzieHi deleted the warnings-warn-stacklevel branch February 2, 2023 22:59
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.

Require warnings.warn stacklevel argument as 2+

3 participants