-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Resolving lint warnings and errors #1522
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
Conversation
Otherwise pylint will raise a warning if this is used: logger.debug('Logging value: {value}'.format(value=123)) And recommends using: logger.debug('Logging value: %(value)s', value=123)
7c65af4
to
ab20342
Compare
Big 👍 |
@@ -32,7 +32,7 @@ | |||
class ProjectResource(ModelResource, SearchMixin): | |||
users = fields.ToManyField('readthedocs.api.base.UserResource', 'users') | |||
|
|||
class Meta: | |||
class Meta(object): |
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 feels un-djangoy -- have they suggested doing this now, or is this just to make the linter happy?
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.
Also seems there are a bunch of other places where we're doing it and it isn't alerting. Is it special casing Django model's and forms, but not the api stuff?
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.
The linter complains if python old-style classes are used. Django makes the Meta
classes into new style classes automatically since this ticket: https://code.djangoproject.com/ticket/7342
The restframework however does not. So that's why we made them new-styles classes here by hand. I think of it as "future-proofing" as all classes will be new style classes in Python 3, so we do some testing in that regard here if we make the switch now.
We: the circular import, do we actually use the get_form method on the UserProfileForm? https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/core/models.py#L29-L31 is the issue, but yea, it doesn't break prod, so I'm not sure what the best course of action is. |
We could do a janky string-based import, but that's just working around the linter, not changing the logic. Perhaps we can just silence the linter? |
Gonna merge this, but curious about the Meta stuff -- this will rot quickly, so want to get it in. |
Resolving lint warnings and errors
This resolves (nearly) all lint errors. For reviewing this PR keep in mind that my intend was always to just fix the warnings and not do any other refactoring. If you see a semantic change in the PR, please report!
All changes that required changing the semantics were proposed as other PRs:
These warnings are still left:
The first one is discussed in #1512
For the second one, I have not idea how to resolve it. The
UserProfile.get_form
method importsfrom .forms import UserProfileForm
which is surely the cause for the warning, but the actual reported file that this error occurs in is always different for every run oftox -e lint
...