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

Add a flake8 command to etstool.py #1027

Merged
merged 2 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions etstool.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
"pygments",
"coverage",
"pillow",
"flake8",
"flake8_ets",
}

source_dependencies = {
Expand Down Expand Up @@ -462,6 +464,30 @@ def test_all(edm):
sys.exit(1)


@cli.command()
@edm_option
@click.option('--runtime', default="3.6")
@click.option('--toolkit', default="pyqt5")
@click.option(
"--environment", default=None, help="Name of EDM environment to check."
)
@click.option(
'--strict/--not-strict',
default=False,
help="Use strict configuration for flake8 [default: --not-strict]",
)
def flake8(edm, runtime, toolkit, environment, strict):
"""Run a flake8 check in a given environment."""
parameters = get_parameters(edm, runtime, toolkit, environment)
config = ""
if strict:
config = "--config=flake8_strict.cfg "
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what this file is. should this be setup.cfg?

Also, I don't fully understand what the point of "strict" vs "non-strict" options for flake8 is - don't we always want to use "strict"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a copy-pasta from TraitsUI - the idea was strict is something like what we are aiming for (and so new code should pass strict), but there are a lot of issues that need fixing before old code could pass the strict version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Obviously I'll fix one way or another.

commands = [
"edm run -e {environment} -- python -m flake8 " + config,
]
execute(commands, parameters)


# ----------------------------------------------------------------------------
# Utility routines
# ----------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions flake8_strict.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
ignore = E266,W503,E722,E731,E741
per-file-ignores = */api.py:F401
10 changes: 10 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[flake8]
exclude = docs
per-file-ignores = */api.py:F401,examples/*:H101
ignore =
# codes we ignore as part of ETS style
E266,W503,E722,E731,E741
# codes we are ignoring pending clean-up
F401,F403,F405,F811,F821,F841,H101
# codes for formatting pending clean-up
E111,E114,E117,E120,E121,E126,E128,E203,E225,E226,E231,E241,E265,E302,E303,E401,E402,E501,E504,E711,E712,E714,W291,W293,W391,W504,W605