-
Notifications
You must be signed in to change notification settings - Fork 116
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
Make get_or_create func placeholder return (model, bool) tuple #156
Make get_or_create func placeholder return (model, bool) tuple #156
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good but is missing tests!
from django.core.exceptions import MultipleObjectsReturned \ | ||
as MultipleObjectsReturnedException | ||
|
||
|
||
def __noop_get_or_create(self, *args, **kwargs): | ||
return (Model(), bool(random.randint(0, 1))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use random
? Why not return just True
or False
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation is closer to the original one, which may return either True
or False
and that makes it more error-proof if in the future pylint gets smart enough to run checks based on exact return values of functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. I still need a reproducer/test though.
@femdom can you post the original error being produced ? For some reason I was not able to reproduce. What pylint_django version do you have ? |
@atodorov I've faced the same issue:
produces
I use pylint v1.9.1 and pylint-django v0.11.1 |
the issue is not reproducible after the upgrade to pylint 2.0 where I deleted most of the transformations, including the offending one.
Otherwise, code like
raises pylint error.