Skip to content

Commit

Permalink
Apply black and isort, add corresponding nox session stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
aperezdc committed Apr 25, 2022
1 parent a8975c3 commit 431e307
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 94 deletions.
59 changes: 37 additions & 22 deletions noxfile.py
@@ -1,15 +1,18 @@
# noqa: INP001

import nox
from itertools import product
from pathlib import Path

import nox

py_default = "3.10"
py_envs = (py_default, "3.6")

nox.options.error_on_external_run = True
nox.options.sessions = (
"clean", *map("-".join, product(("test",), py_envs)), "report",
"clean",
*map("-".join, product(("test",), py_envs)),
"report",
)


Expand All @@ -23,35 +26,47 @@ def clean(session):
@nox.session(python=py_default)
def lint(session):
"""Run static code checks."""
session.install("flakeheaven",
"flake8-2020",
"flake8-bugbear",
"flake8-builtins",
"flake8-comprehensions",
"flake8-debugger",
"flake8-eradicate",
"flake8-implicit-str-concat",
"flake8-multiline-containers",
"flake8-no-pep420",
"flake8-noqa",
"flake8-pep3101",
"flake8-pie",
"flake8-simplify",
"flake8-string-format",
"flake8-type-checking",
"flake8-use-pathlib",
)
session.install(
"flakeheaven",
"flake8-2020",
"flake8-black",
"flake8-bugbear",
"flake8-builtins",
"flake8-comprehensions",
"flake8-debugger",
"flake8-eradicate",
"flake8-implicit-str-concat",
"flake8-isort",
"flake8-multiline-containers",
"flake8-no-pep420",
"flake8-noqa",
"flake8-pep3101",
"flake8-pie",
"flake8-simplify",
"flake8-string-format",
"flake8-type-checking",
"flake8-use-pathlib",
)
args = session.posargs or ("lint", "src", "tests", "noxfile.py", "README.rst")
session.run("flakeheaven", *args)


@nox.session(python=py_default)
def black(session):
"""Reformat code using Black."""
session.install("black")
args = session.posargs or ("src", "tests", "noxfile.py")
session.run("black", *args)


@nox.session(python=py_envs)
def test(session):
"""Run unit tests, produce coverage data."""
session.notify("report")
session.install("coverage[toml]<6.3", "pytest", "xdoctest", "pygments", ".")
session.run("coverage", "run", "-m", "pytest", "--xdoctest", "-vv",
*session.posargs)
session.run(
"coverage", "run", "-m", "pytest", "--xdoctest", "-vv", *session.posargs
)


@nox.session(python=py_default)
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Expand Up @@ -16,13 +16,17 @@ show_missing = true
skip_covered = true
fail_under = 25

[tool.isort]
profile = "black"
src_paths = ["src", "tests"]

[tool.flakeheaven]
format = "colored"
show_source = true
max_line_length = 120
noqa-require-code = true

[tool.flakeheaven.plugins]
pycodestyle = ["+*", "-E501", "-E722"]
pycodestyle = ["+*", "-E203", "-E501", "-E722", "-W503"]
pyflakes = ["+*"]
"flake8-*" = ["+*"]

0 comments on commit 431e307

Please sign in to comment.