Skip to content

Commit

Permalink
new: dev: Invoke: quality task implemented #154
Browse files Browse the repository at this point in the history
Run `inv qa` to test this functionality. CAVEAT: at the moment, qa runs flake8, pylint and mypy sequentially. Black is not run because it would modify the source code.
  • Loading branch information
pietrodantuono committed Apr 12, 2023
1 parent ef891b3 commit d1cfaeb
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
max-line-length = 79
exclude = **/__pycache__
max-complexity = 20
ignore = E203, W503
jobs=4
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -488,5 +488,5 @@ min-public-methods=1
[EXCEPTIONS]

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception
# "builtins.Exception"
overgeneral-exceptions=builtins.Exception
1 change: 1 addition & 0 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
flake8 >= 6.0.0
invoke >= 2.0.0
mypy>=0.942
pycodestyle>=2.8.0
Expand Down
4 changes: 2 additions & 2 deletions tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from invoke import Collection

# from . import quality
from . import quality
# from . import docs
from . import test
# from . import ado
Expand All @@ -13,7 +13,7 @@


ns = Collection()
# ns.add_collection(quality, name="qa")
ns.add_collection(quality, name="qa")
# ns.add_collection(docs)
ns.add_collection(test)
# ns.add_collection(ado)
Expand Down
51 changes: 51 additions & 0 deletions tasks/quality.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""Quality assessment tasks. Run all quality checks with `inv qa`.
The quality checks are:
- black
- flake8
- pylint
- mypy
"""

from invoke import task
from .colors import colorize

from .system import OperatingSystem, get_current_system

PTY = True
if get_current_system() == OperatingSystem.WINDOWS:
PTY = False


# @task
# def black(c_r):
# """Run code formatter: black."""
# print(colorize("-> Running black..."))
# c_r.run(f"black {c_r.project_slug}", pty=PTY)


@task
def flake(c_r):
"""Run style guide enforcement: flake8."""
print(colorize("-> Running flake8..."))
c_r.run(f"flake8 {c_r.project_slug}", warn=True, pty=PTY)


@task
def pylint(c_r):
"""Run code analysis: pylint."""
print(colorize("-> Running pylint..."))
c_r.run(f"pylint {c_r.project_slug}", warn=True, pty=PTY)


@task
def mypy(c_r):
"""Run static type checking: mypy."""
print(colorize("-> Running mypy..."))
c_r.run(f"mypy {c_r.project_slug}", warn=True, pty=PTY)


# @task(post=[black, flake, pylint, mypy], default=True)
@task(post=[flake, pylint, mypy], default=True)
def all(c_r): # pylint: disable=W0622,W0613 # noqa: F811
"""Run all quality checks."""

0 comments on commit d1cfaeb

Please sign in to comment.