Skip to content
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

[BEAM-2821] Run isort and autopep8 in preparation for futurize. #3785

Closed
wants to merge 17 commits into from

Conversation

holdenk
Copy link
Contributor

@holdenk holdenk commented Aug 29, 2017

In preparation for running futurize (py2/3 support) run isort on the imports and autopep8 ( W391,W293,W291,E306,E305,E304,E303). This also adds isort to run_pylint but skips the files where isort was doing things which conflicted with pylint.

@holdenk holdenk changed the title [WIP][BREAM-2821] Run isort and autopep8 in preparation for futurize. [WIP][BEAM-2821] Run isort and autopep8 in preparation for futurize. Aug 29, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.008%) to 69.96% when pulling 7ae79b7 on holdenk:BEAM-2821-isort-and-autopep8 into 6280d49 on apache:master.

@holdenk
Copy link
Contributor Author

holdenk commented Aug 30, 2017

Run Python Postcommit

@holdenk holdenk changed the title [WIP][BEAM-2821] Run isort and autopep8 in preparation for futurize. [BEAM-2821] Run isort and autopep8 in preparation for futurize. Aug 30, 2017
@holdenk
Copy link
Contributor Author

holdenk commented Aug 30, 2017

cc @robertwb

Copy link
Contributor

@robertwb robertwb left a comment

Choose a reason for hiding this comment

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

Is there an option to put multiple imports on distinct lines. For example

from apache_beam.transforms import core, ptransform, window

is particularly odd. Also, we prefer long lines to wrapping with \.

@@ -20,8 +20,6 @@
import logging
import unittest


Copy link
Contributor

Choose a reason for hiding this comment

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

Don't remove this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Restored

# importing following private classes for testing
from apache_beam.io.concat_source import ConcatSource
from apache_beam.io.filebasedsource import _SingleFileSource as SingleFileSource

from apache_beam.io.filebasedsource import \
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

default isort was 79, switched to 80 and reverted

@holdenk
Copy link
Contributor Author

holdenk commented Aug 30, 2017

@robertwb there is an option to do multi imports per single line with isort, let me poke at it.

@holdenk
Copy link
Contributor Author

holdenk commented Aug 30, 2017

An unexpected benefit of SL mode is it seems to agree with pylint a lot more (which is good since newer pylints use isort internally so the disagreements are a little confusing).

@holdenk
Copy link
Contributor Author

holdenk commented Aug 31, 2017

The flink runner failed which doesn't make a lot of sense for the changes, jenkins retest this please.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 69.728% when pulling f7f5e68 on holdenk:BEAM-2821-isort-and-autopep8 into 6280d49 on apache:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.003%) to 69.735% when pulling 7ee5d4e on holdenk:BEAM-2821-isort-and-autopep8 into c9653f2 on apache:master.

Copy link
Contributor

@robertwb robertwb left a comment

Choose a reason for hiding this comment

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

Thanks! Basically looks good to me. Just a couple of comments, and also there's a few more files that need to be fixed/ignored according to jenkins:

ERROR: /home/jenkins/jenkins-slave/workspace/beam_PreCommit_Java_MavenInstall/sdks/python/apache_beam/io/gcp/datastore/v1/datastoreio.py Imports are incorrectly sorted.
ERROR: /home/jenkins/jenkins-slave/workspace/beam_PreCommit_Java_MavenInstall/sdks/python/apache_beam/io/gcp/datastore/v1/adaptive_throttler_test.py Imports are incorrectly sorted.
ERROR: /home/jenkins/jenkins-slave/workspace/beam_PreCommit_Java_MavenInstall/sdks/python/apache_beam/runners/direct/transform_evaluator.py Imports are incorrectly sorted.
ERROR: /home/jenkins/jenkins-slave/workspace/beam_PreCommit_Java_MavenInstall/sdks/python/apache_beam/runners/dataflow/native_io/iobase_test.py Imports are incorrectly sorted.

from apache_beam.testing.test_pipeline import TestPipeline
from apache_beam.testing.util import assert_that
from apache_beam.testing.util import equal_to
from apache_beam.transforms.display import DisplayData
from apache_beam.transforms.display_test import DisplayDataItemMatcher

# Importing following private class for testing purposes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a huge fan of this change, but it's probably not worth fighting the tool...

@@ -19,7 +19,8 @@
# NOTE: This file is autogenerated and should not be edited by hand.
from apitools.base.py import base_api

from apache_beam.io.gcp.internal.clients.bigquery import bigquery_v2_messages as messages
from apache_beam.io.gcp.internal.clients.bigquery import \
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer ignoring line length limits for these imports over wrapping.

# Skip files where isort is behaving weirdly
ISORT_EXCLUDED=(
"avroio_test.py"
"fast_coders_test.py"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an odd ordering. At least put the two coders tests next to each other.

…dering a bit, manually remove single line isort continuations as asked to remove.
@holdenk
Copy link
Contributor Author

holdenk commented Sep 1, 2017

Thanks @robertwb ! I've updated it a bit, I hope your staying cool in the heat wave (if you're in an area impacted by it). Looking forward to moving on to the next bit of Py3 support :)

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 69.683% when pulling 2d79c8d on holdenk:BEAM-2821-isort-and-autopep8 into c9653f2 on apache:master.

@asfgit asfgit closed this in 3aa2bef Sep 1, 2017
@robertwb
Copy link
Contributor

robertwb commented Sep 1, 2017

LGTM

@holdenk
Copy link
Contributor Author

holdenk commented Sep 1, 2017

Thanks 😀

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.

None yet

3 participants