Skip to content

Flake8 and source code cleanup - #109

Merged
lesteve merged 12 commits into
dask:masterfrom
jhamman:flake8
Aug 13, 2018
Merged

lesteve merged 12 commits into
dask:masterfrom
jhamman:flake8

Conversation

@jhamman

@jhamman jhamman commented Jul 27, 2018 •

Copy link
Copy Markdown
Member

closes #38, closes #106

This uses the flake8 config from distributed and adds some boilerplate future imports.

Flake8 itself is being run in the none.sh build.

@lesteve

lesteve commented Jul 31, 2018

Copy link
Copy Markdown
Member

Personally as I tried to convey in #38, I would be in favour of stripping down the flake8 ignore we already have in setup.cfg rather than adding more. Here are the default ignore option from flake8 --help:

 --ignore=errors       Comma-separated list of errors and warnings to ignore
                        (or skip). For example, ``--ignore=E4,E51,W234``.
                        (Default: E121,E123,E126,E226,E24,E704,W503,W504)

With the default flake8 warnings: I get only two flake8 violations which are quite easy to fix and do not seem very controversial to me:

❯ flake8 dask_jobqueue --show-source --ignore='E121,E123,E126,E226,E24,E704,W503,W504'
dask_jobqueue/sge.py:80:49: E231 missing whitespace after ','
                  'resource_spec': resource_spec,}
                                                ^
dask_jobqueue/core.py:202:9: E265 block comment should start with '# '
        #This attribute should be overriden

For completeness sake is the diff I would be in favour of (+ fixing the 2 flake8 violations):

diff --git a/setup.cfg b/setup.cfg
index a42170f..d3913b0 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -7,22 +7,6 @@ license-file = LICENSE.txt
 # https://flake8.readthedocs.io/en/latest/user/error-codes.html
 
 # Note: there cannot be spaces after comma's here
-exclude = __init__.py
-ignore =
-    # Extra space in brackets
-    E20,
-    # Multiple spaces around ","
-    E231,E241,
-    # Comments
-    E26,
-    # Import formatting
-    E4,
-    # Comparing types instead of isinstance
-    E721,
-    # Assigning lambda expression
-    E731,
-    # Ambiguous variable names
-    E741
 max-line-length = 120
 
 [versioneer]

@guillaumeeb

Copy link
Copy Markdown
Member

If there is no strong reason to ignore all this, and no standard ignores defined for all the dask modules, then 👍 to @lesteve proposal.

@mrocklin

mrocklin commented Jul 31, 2018 via email

Copy link
Copy Markdown
Member

@jhamman

jhamman commented Jul 31, 2018

Copy link
Copy Markdown
Member Author

@lesteve - sounds great. This is my preference as well. I will update accordingly.

@lesteve

lesteve commented Aug 1, 2018 •

Copy link
Copy Markdown
Member

I am fine with keeping the original max-line-length = 120. At the moment you have some flake8 failures (see this Travis log) because some lines are over 79 characters (flake8 violations don't get the Travis build to fail, but #110 should fix that).

@guillaumeeb

Copy link
Copy Markdown
Member

Oh yes please, max-line-length to 120 characters. It's not like we've got low-res small screens anymore.

@mrocklin

mrocklin commented Aug 6, 2018

Copy link
Copy Markdown
Member

Checking in. What is the status on this?

@jhamman

jhamman commented Aug 6, 2018

Copy link
Copy Markdown
Member Author

provided the tests pass here, I think this is now ready to merge.

@mrocklin mrocklin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some comments about the config changes.

Comment thread docs/configurations.rst

queue: regular
project: null # TODO, change me
project: PXYZ123

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I anticipate that people who don't pay attention won't change this. I slightly prefer leaving this as null so that they get an appropriate message about it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I would be fine dropping this detail

Comment thread docs/configurations.rst Outdated
processes: 9 # Number of Python processes per job
interface: ib0 # Network interface to use like eth0 or ib0

queue: premium

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this definitely the right queue for everyone? I'm inclined to leave these things out if they're not universally useful.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No but this just an example and it tends to be what we use most often on this machine. Looking at the other deployments on this page, we seem to be okay with some user specific detail.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sounds good to me to have an as much as possible real example, so all except the project detail.

@guillaumeeb guillaumeeb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't like the too many line feeds here, was it due to the max-line-length parameter set to 80?

Just a minor concern though.

@jhamman

jhamman commented Aug 7, 2018

Copy link
Copy Markdown
Member Author

I would actually prefer sticking with 80 chars but 1) I'll get over it since there seems to be consensus among the other devs and 2) I've rolled back all line breaks that were between 80 and 120 chars in bad50ac. This may just be for demonstration or we can just go with it.

@mrocklin

mrocklin commented Aug 7, 2018

Copy link
Copy Markdown
Member

FWIW my operational line length in most personal projects tends to be "80 characters except when it's inconvenient".

@mrocklin

mrocklin commented Aug 7, 2018

Copy link
Copy Markdown
Member

No comment here though. I'm happy to stay out of this conversation :)

@guillaumeeb

Copy link
Copy Markdown
Member

Apparently I am the only one that prefers long lines, @lesteve was just fine keeping max-line-length = 120 for some lines, which looks like @mrocklin comment.

It is really a minor concern, so lets just keep it your way @jhamman!

For the test failures here, I had some problems with this file and the last line when pushing to #107.

@jhamman

jhamman commented Aug 10, 2018

Copy link
Copy Markdown
Member Author

This seems ready to merge. Since there were a few minor disagreements along the way on this one, I'll let @guillaumeeb or @lesteve have a final look.

@guillaumeeb guillaumeeb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some really minor comments, one about the max-line-length discussion, I'm really not sure about this one.

Other than that LGTM, thanks @jhamman.

Comment thread dask_jobqueue/core.py Outdated

This centralzies calls out to the command line, providing consistent
outputs, logging, and an opportunity to go asynchronous in the future
This centralzies calls out to the command line, providing consistent outputs, logging, and an opportunity

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Old typo in centralizes

Comment thread dask_jobqueue/pbs.py Outdated

def __init__(self, queue=None, project=None, resource_spec=None, walltime=None, job_extra=None, **kwargs):
def __init__(self, queue=None, project=None, resource_spec=None,
walltime=None, job_extra=None, **kwargs):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You still have some line breaks here and there, but this is not important.

Comment thread dask_jobqueue/tests/__init__.py Outdated
@@ -1,2 +1,4 @@
# flake8: noqa

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is there a noqa here? Do we need this import?

@lesteve

lesteve commented Aug 13, 2018

Copy link
Copy Markdown
Member

I pushed some tweaks to tackle @guillaumeeb's comment. Let's merge this one!

I am happy to give a go to a max-line-length of 120 characters. More than happy to revisit this decision in a little while if we realise this is a problem in practice.

@lesteve
lesteve merged commit 4ea3c98 into dask:master Aug 13, 2018
@lesteve

lesteve commented Aug 13, 2018

Copy link
Copy Markdown
Member

Thanks a lot @jhamman!

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.

Add flake8 to tests or black to CI flake8 ignore configuration

4 participants