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

isort #1924

Merged
merged 17 commits into from
Feb 27, 2018
Merged

isort #1924

merged 17 commits into from
Feb 27, 2018

Conversation

max-sixty
Copy link
Collaborator

Not sure if we want this?

Probably too strict to enforce on every commit, more permissible to do a one-time update, assuming it doesn't cause merge conflicts.

You can get the same result by running isort -y

import numpy as np
import pandas as pd
import seaborn as sns # pandas aware plotting library
import seaborn as sns # pandas aware plotting library
Copy link
Contributor

Choose a reason for hiding this comment

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

F401 'seaborn as sns' imported but unused

setup.py Outdated
@@ -4,8 +4,7 @@
import sys
import warnings

from setuptools import setup, find_packages
from setuptools import Command
from setuptools import Command, find_packages, setup
Copy link
Contributor

Choose a reason for hiding this comment

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

F401 'setuptools.Command' imported but unused

@@ -2,14 +2,14 @@


see pandas/pandas/util/_print_versions.py'''
import codecs
Copy link
Contributor

Choose a reason for hiding this comment

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

W1618 import missing from __future__ import absolute_import

@max-sixty
Copy link
Collaborator Author

Requires #1925 to make @stickler-ci happy (and this needs to stop the I002 disabling when that is merged)

@max-sixty
Copy link
Collaborator Author

Updated

@@ -66,7 +71,7 @@ def test_async(c, s, a, b):
assert dask.is_dask_collection(y.var2)

z = y.persist()
assert str(z)
assert str(z)©
Copy link
Contributor

Choose a reason for hiding this comment

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

E999 SyntaxError: invalid syntax

@shoyer
Copy link
Member

shoyer commented Feb 22, 2018

Is it possible to enforce this programmatically, e.g., with flake8?

I'm a little surprised flake8 doesn't already require sorted imports by default. We use a modified version of pylint internally at Google that does this.

from . import (
TestCase, requires_netcdftime, assert_array_equal)
import pytest
TestCase, assert_array_equal, requires_netCDF4, requires_netcdftime)
Copy link
Member

Choose a reason for hiding this comment

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

if you remove requires_netCDF4, I think the flake8 tests will pass.

@dopplershift
Copy link
Contributor

I recommend flake8-import-order. If you install that plugin, then flake8 will enforce import ordering and grouping.

@max-sixty
Copy link
Collaborator Author

max-sixty commented Feb 22, 2018

We use flake8-isort, which implements isort itself in flake8. @dopplershift do you have a view between them?

One advantage of isort is that there's a link between the formatter and the checker, so running isort can never cause errors.

But stepping back, we should think about whether we want to mandate this on every PR. It doesn't matter that much (less than flake8 imo), and it can be frustrating to have formatting errors get in the way of a PR. A tool that automatically corrects the code like @stickler-ci is great, but it doesn't support this one.

A compromise could be to put it in allowed failures in Travis? Or if people think we should add this, let's do it.

@dopplershift
Copy link
Contributor

I don't have much preference between the two--I picked one and it worked for me. I just fixed up the initial import cleanups by hand and didn't find the need for a tool to do so.

In my experience, having formatting errors hold up a PR hasn't been a problem. IMO, import ordering is a more important style issue than many of the things that flake8 catches.

@shoyer
Copy link
Member

shoyer commented Feb 22, 2018

I would also be OK with just fixing this up in occasional cleanup PR.

If Stickler-CI supported this that might be a decisive consideration in terms of enforcing it. Certainly it's a better experience for contributors to get formatting errors as comments on a PR rather than a failed build.

@max-sixty
Copy link
Collaborator Author

max-sixty commented Feb 22, 2018

as comments on a PR

+ the really cool feature is that it'll add commits with changes, where it can

@max-sixty
Copy link
Collaborator Author

I would also be OK with just fixing this up in occasional cleanup PR.

Would you prefer in allowed failures, or that's a bad middle-ground?

@max-sixty
Copy link
Collaborator Author

max-sixty commented Feb 27, 2018

@jhamman @shoyer green!

No auto-check, but easier to add those in the future than thrash between too lenient and too harsh, imo

@max-sixty max-sixty merged commit 0e73e24 into pydata:master Feb 27, 2018
@max-sixty max-sixty deleted the isort branch February 27, 2018 19:33
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.

5 participants