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

DM-15515 Enable flake8 tests. #22

Merged
merged 3 commits into from Aug 30, 2018
Merged

DM-15515 Enable flake8 tests. #22

merged 3 commits into from Aug 30, 2018

Conversation

jeffcarlin
Copy link
Contributor

No description provided.

Copy link

@SimonKrughoff SimonKrughoff left a comment

Choose a reason for hiding this comment

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

Looks great.

@timj
Copy link
Member

timj commented Aug 24, 2018

You will need to add a simple test file to tests/ that imports ctrl_pool so that tests pass even if all the flake8 tests are skipped.

@@ -8,12 +8,11 @@
#

from __future__ import print_function
from builtins import map
import math
from builtins import range
Copy link
Member

Choose a reason for hiding this comment

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

You can remove the builtins imports and the __future__ while you are here. We don't need py2 compatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed builtins and __future__ from all files in this repo.

import lsst.log as lsstLog
from lsst.utils import getPackageDir
standard_library.install_aliases()
Copy link
Member

Choose a reason for hiding this comment

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

Remove this and from future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@@ -15,7 +15,6 @@
import contextlib
from lsst.pipe.base import CmdLineTask, TaskRunner
from .pool import startPool, Pool, NODE, abortOnError, setBatchType
from . import log # register pickle functions for log
Copy link
Member

Choose a reason for hiding this comment

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

The comment here suggests that this import has to happen even if log is not used. I suggest a # noqa here instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't see this line in parallel.py? Not sure where it went. Added it back in as "from . import log # noqa

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also - is this import unnecessary? I get this:

================================================================ FAILURES =================================================================
________________________________________ FLAKE8-check(ignoring E133 E226 E228 E251 N802 N803 N806) ________________________________________
/home/jcarlin/repos/ctrl_pool/python/lsst/ctrl/pool/parallel.py:64:5: F811 redefinition of unused 'log' from line 15

Copy link
Member

Choose a reason for hiding this comment

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

This is importing lsst.ctrl.pool.log. The problem is that in line 64 the code assigns a variable to log and that is triggering the warning because at that point the original log is lost. This is a tricky one to fix since people expect the logging system to be in log. Maybe change this import to

from . import log as dummyLog  # noqa

(I think you need two spaces before the #).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adopted your suggestion. (Not sure I understand why that import is needed, but trust your wisdom.)

Copy link
Member

Choose a reason for hiding this comment

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

it's needed because there is code in ctrl.pool.log that needs to be run even if you don't use it directly (it enables pickling). Not sure why that couldn't be in the __init__.py though.

@@ -1,8 +1,6 @@
from future import standard_library
Copy link
Member

Choose a reason for hiding this comment

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

Remove future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

from builtins import zip
from builtins import range
from past.builtins import basestring
from builtins import object
Copy link
Member

Choose a reason for hiding this comment

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

All these buitltins can go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed those.

setup.cfg Outdated

[tool:pytest]
addopts = --flake8
flake8-ignore = E133 E226 E228 E251 N802 N803 N806
Copy link
Member

Choose a reason for hiding this comment

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

You are ignoring one extra code here. This can be confusing because it means that the pytest check is different to the pull request check. I don't think we use E251 do we?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We were wondering about that. We got this setup from J. Sick, and noticed the extra there. According to https://developer.lsst.io/python/style.html?highlight=flake8#flake8-configuration-files we don't use E251.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed E251 from `setup.cfg'.

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