Skip to content

Commit

Permalink
Use tools/lint.py in dev.py
Browse files Browse the repository at this point in the history
- Removed the `output-file` option, which was not applied consistently
  across linting tools.
- Hard-coded main branch as `main`: perhaps some logic to ensure that
  the branch is the latest master and up to date is warranted in a
  future PR?
  • Loading branch information
stefanv committed Jan 18, 2023
1 parent 76ef708 commit 0b97f7d
Showing 1 changed file with 11 additions and 32 deletions.
43 changes: 11 additions & 32 deletions dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def task_meta(cls, **kwargs):

import click
from click import Option, Argument
from doit import task_params
from doit.cmd_base import ModuleTaskLoader
from doit.reporter import ZeroReporter
from doit.exceptions import TaskError
Expand Down Expand Up @@ -269,7 +268,7 @@ def cli(ctx, **kwargs):
\b**python dev.py --build-dir my-build test -s stats**
"""
""" # noqa: E501
CLI.update_context(ctx, kwargs)


Expand Down Expand Up @@ -558,7 +557,7 @@ def copy_openblas(cls, dirs):
default `_distributor_init.py` file with the one
we use for wheels uploaded to PyPI so that DLL gets loaded.
Assumes pkg-config is installed and aware of OpenBLAS.
Assumes pkg-config is installed and aware of OpenBLAS.
The "dirs" parameter is typically a "Dirs" object with the
structure as the following, say, if dev.py is run from the
Expand Down Expand Up @@ -652,7 +651,7 @@ class Test(Task):
$ python dev.py test -s cluster -m full --durations 20
$ python dev.py test -s stats -- --tb=line # `--` passes next args to pytest
```
"""
""" # noqa: E501
ctx = CONTEXT

verbose = Option(
Expand Down Expand Up @@ -889,29 +888,14 @@ def emit_cmdstr(cmd):
console.print(f"{EMOJI.cmd} [cmd] {cmd}")


@task_params([{'name': 'output_file', 'long': 'output-file', 'default': None,
'help': 'Redirect report to a file'}])
def task_flake8(output_file):
"""Run flake8 over the code base and benchmarks."""
opts = ''
if output_file:
opts += f'--output-file={output_file}'

cmd = f"flake8 {opts} scipy benchmarks/benchmarks"
emit_cmdstr(f"{cmd}")
return {
'actions': [cmd],
'doc': 'Lint scipy and benchmarks directory',
}


def task_pep8diff():
def task_flake8_diff():
# Lint just the diff since branching off of main using a
# stricter configuration.
emit_cmdstr(os.path.join('tools', 'lint_diff.py'))
emit_cmdstr(os.path.join('tools', 'lint.py') + ' --diff-against main')
return {
'basename': 'pep8-diff',
'actions': [str(Dirs().root / 'tools' / 'lint_diff.py')],
'basename': 'flake8-diff',
'actions': [str(Dirs().root / 'tools' / 'lint.py') +
' --diff-against=main'],
'doc': 'Lint only files modified since last commit (stricter rules)',
}

Expand All @@ -937,16 +921,11 @@ def task_check_test_name():

@cli.cls_cmd('lint')
class Lint():
""":dash: Run flake8, check PEP 8 compliance on branch diff and check for
""":dash: Run flake8 on modified files and check for
disallowed Unicode characters and possibly-invalid test names."""
output_file = Option(
['--output-file'], default=None, help='Redirect report to a file')

def run(output_file):
opts = {'output_file': output_file}
def run():
run_doit_task({
'flake8': opts,
'pep8-diff': {},
'flake8-diff': {},
'unicode-check': {},
'check-testname': {},
})
Expand Down

0 comments on commit 0b97f7d

Please sign in to comment.