-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
unnecessary-lambda-assignment
false-positive (?) with pytest's __tracebackhide__
#6894
Comments
Adding discussion label and 2.15 milestone so a decision is taken by then. |
I think this is just the inherent limit of a style warning--if you know what you're doing and like the style, the check isn't very useful to you. (I disabled this check in |
In an effort to avoid many of my more pressing deadlines I have been working on a little something over on https://github.com/DanielNoord/pylint-pytest-plugin today. It's a plugin for For example, currently this is one of the functional tests: The plugin checks whether the message occurs in 1) a function starting with I'm not sure when I'll finish this plugin and I don't think it's current state is ready for publication, but I do think that this is better handled by a plugin than within |
Now available as https://pypi.org/project/pylint-pytest-plugin/.
|
Probably makes a lot of sense to have this in a pytest-specific plugin! Note however that there is already pylint-pytest with exactly the same aim. However, it might be dead: reverbc/pylint-pytest#31 But perhaps consider forking that and/or taking some inspiration from there? FWIW in qutebrowser, I currently run pylint separately from tests and disable some additional messages there. Not quite sure why I never tried that plugin, I think I just never got around to it and then forgot it again. |
Yeah the plugin seems to be dead. Either way I wanted to see how difficult or easy it is to create a I'll wait for a response in that issue to continue development though. |
Bug description
pytest has a feature which lets you set a
__tracebackhide__
local to suppress the given frame's source code from its output, normally used for assertion helpers:It's also supported to set
__tracebackhide__
to a callable instead, to only hide the frame if the given condition applies. In my codebase, I often use this with lambdas. From pytest's documentation, slightly altered:I think this should be considered suitable usage of
lambda
because of how__tracebackhide__
is just a normal boolean in its simple form. It seems odd to usedef
to define it.Granted, though, this doesn't seem widely used at all. In fact, I might be the only one doing this. If you disagree about this being a good idea, feel free to close this!
cc @jpy-git who introduced this checker in #6004.
Configuration
No response
Command used
Pylint output
Expected behavior
No message, if the local being assigned to is named
__tracebackhide__
.Pylint version
OS / Environment
No response
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: