Skip to content

PEP8 and Flake8 fixes #4613

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

Closed
wants to merge 3 commits into from
Closed

PEP8 and Flake8 fixes #4613

wants to merge 3 commits into from

Conversation

adamn
Copy link

@adamn adamn commented Oct 21, 2016

Ok, here we go with serializers added back as prefixes. fields and relations, which never were module prefixes because usage was passing through serializers for the fields and relations are not there. We could add them or not - up to you.

Copy link
Member

@tomchristie tomchristie left a comment

Choose a reason for hiding this comment

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

The change footprint of this PR is far too large. Not even possible to properly review. (Eg. so many changes that a reviewer could easily miss if an argument signature accidentally changed in between versions)

We really can't accept something like this in the current state. I'd suggest:

  • A PR to update everything except the linter.
  • A PR to update the linter, with the absolute minimum possible changes in order to continue passing the tests, with our current linting settings.

If the second one of those isn't possible to do with a small footprint then we'll need to reconsider our linter settings, or consider not upgrading, or even opening an issue against the linter package.

If the second one is possible then we could always consider following up with further stylistic changes, but making sure to isolate those down to a single style aspect at a time.

Thanks for your time & effort, hopefully we can reach something that we can accept. 😄

DecimalField, DictField, EmailField, Field, FileField, FloatField,
ImageField, IntegerField, ListField, MultipleChoiceField, NullBooleanField,
OrderedDict, RegexField, SlugField, TimeField, URLField
)
Copy link
Member

Choose a reason for hiding this comment

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

Is this change strictly necessary?

Copy link
Author

Choose a reason for hiding this comment

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

In order to use the current linter, yes.

])
return OrderedDict([(field_name, self.get_field_info(field))
for field_name, field in
serializer.fields.items()])
Copy link
Member

Choose a reason for hiding this comment

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

Is this different indentation style mandatory? It reads less obviously to me. If we can avoid changing it let's do so.

Copy link
Author

Choose a reason for hiding this comment

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

That's the only indentation style that works within the 79 character limit. Since I only noticed that we're ignoring the line length PEP8 rule after the fact, we don't need to worry about the indentation style changing.

Still, that is the only way to make the linter work and not ignore the line length rule (which I would be in favor of doing). I think the best course of action is to continue ignoring the line length, do everything else, and then decide about the line length at some future date. I would be in favor of the 79 character limit though - it's really easier once you take the plunge...

}
for choice_value, choice_name in field.choices.items()
]
field_info['choices'] = [{'value': choice_value,
Copy link
Member

Choose a reason for hiding this comment

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

Again, this seems less clear.

Copy link
Author

Choose a reason for hiding this comment

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

Same issue as above

@@ -64,15 +70,16 @@ class JSONRenderer(BaseRenderer):
# We don't set a charset because JSON is a binary encoding,
# that can be encoded as utf-8, utf-16 or utf-32.
# See: http://www.ietf.org/rfc/rfc4627.txt
# Also: http://lucumr.pocoo.org/2013/7/19/application-mimetypes-and-encodings/
# http://lucumr.pocoo.org/2013/7/19/application-mimetypes-and-encodings/
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't have to alter our docstring text in order to keep the linter happy. I'm happy to have strict linting for almost everything, but I think the line length should be a guideline rather than mandatory, because of cases like this where it forces authors to alter what they would otherwise write.

Copy link
Author

Choose a reason for hiding this comment

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

If/When the decision is made to follow a 79 character line length, the comments should be pulled over too. But since that won't be happening in the short term, the comments will stay the same.

charset = None

def get_indent(self, accepted_media_type, renderer_context):
if accepted_media_type:
# If the media type looks like 'application/json; indent=4',
# then pretty print the result.
# Note that we coerce `indent=0` into `indent=None`.
base_media_type, params = parse_header(accepted_media_type.encode('ascii'))
base_media_type, params = parse_header(
accepted_media_type.encode('ascii'))
Copy link
Member

Choose a reason for hiding this comment

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

:-/

@@ -260,88 +268,93 @@ class HTMLFormRenderer(BaseRenderer):
base_template = 'form.html'

default_style = ClassLookupDict({
serializers.Field: {
Field: {
Copy link
Member

Choose a reason for hiding this comment

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

Again, would much rather keep the serializers.<SomeField> style throughout. It's an important bit of namespacing, and we've been very strongly consistent about it's use and recommending it to others. If the linting tool is going to force this to change, then I don't see us accepting that aspect of the linting.

Copy link
Author

Choose a reason for hiding this comment

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

Agreed. In a new ticket we will use relations. and fields. to replace where serializers. used to be used (since those fields aren't actually in serializers, they were just available because of the import *)

else:
serializer = view.get_serializer(**kwargs)
else:
# at this point we must have a serializer_class
if method in ('PUT', 'PATCH'):
serializer = self._get_serializer(view.serializer_class, view,
request, instance=instance, **kwargs)
serializer = self._get_serializer(view.serializer_class,
Copy link
Member

Choose a reason for hiding this comment

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

Not convinced by this indentation style. If we must push arguments onto a newline, let's stick with ...

something(
    arg1,
    arg2
 )

Seems far more readable to me than the "push everything up to the initial bracket" style

@adamn
Copy link
Author

adamn commented Oct 25, 2016

I'll open up a new ticket so we can accept a path before doing the work. I put comments inline - hope that's not too messy.

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.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy