Commit 14d47c84 authored by Jakob Albert's avatar Jakob Albert
Browse files

Extended template

parent 718499c0
[darglint]
strictness = short
[flake8]
select = ANN, B, B9, BLK, C, D, DAR, E, F, I, S, W
ignore = ANN101, ANN102, E203, E501, W503
max-complexity = 10
max-line-length = 88
applications-import-names = fib_calc
docstring-convention = google
import-order-style = google
per-file-ignores = tests/*:S101,ANN
/htmlcov/
/.coverage
/docs/_build/
__pycache__
/dist/
"""Sphinx configuration."""
project = "fib-calc"
author = "Jakob Albert"
copyright = f"2021, {author}"
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx_autodoc_typehints",
"sphinx_rtd_theme",
]
html_theme = "sphinx_rtd_theme"
Fibonacci Calculator
====================
.. contents::
:local:
:backlinks: none
cli
---
.. automodule:: fib_calc.cli
:members:
fib
---
.. automodule:: fib_calc.fib
:members:
[mypy]
[mypy-nox.*,pytest]
ignore_missing_imports = True
......@@ -6,7 +6,9 @@ from typing import Any
import nox
from nox.sessions import Session
locations = "src", "tests", "noxfile.py"
locations = "src", "tests", "noxfile.py", "docs/conf.py"
nox.options.sessions = "lint", "mypy", "tests", "typeguard"
package = "fib_calc"
def install_with_constraints(session: Session, *args: str, **kwargs: Any) -> None:
......@@ -36,10 +38,78 @@ def black(session: Session) -> None:
session.run("black", *args)
@nox.session()
def docs(session: Session) -> None:
"""Build the documentation."""
session.run("poetry", "install", "--no-dev", external=True)
install_with_constraints(
session, "sphinx", "sphinx-autodoc-typehints", "sphinx-rtd-theme"
)
session.run("sphinx-build", "docs", "docs/_build")
@nox.session()
def lint(session: Session) -> None:
"""Lint using flake8."""
args = session.posargs or locations
install_with_constraints(
session,
"flake8",
"flake8-annotations",
"flake8-bandit",
"flake8-black",
"flake8-bugbear",
"flake8-docstrings",
"flake8-import-order",
"darglint",
)
session.run("flake8", *args)
@nox.session()
def mypy(session: Session) -> None:
"""Type-check using mypy."""
args = session.posargs or locations
install_with_constraints(session, "mypy")
session.run("mypy", *args)
@nox.session()
def safety(session: Session) -> None:
"""Scan dependencies for insecure packages."""
requirements = tempfile.NamedTemporaryFile(delete=False)
session.run(
"poetry",
"export",
"--dev",
"--format=requirements.txt",
"--without-hashes",
f"--output={requirements.name}",
external=True,
)
install_with_constraints(session, "safety")
session.run("safety", "check", f"--file={requirements.name}", "--full-report")
requirements.close()
os.unlink(requirements.name)
@nox.session()
def tests(session: Session) -> None:
"""Run the test suite."""
args = session.posargs or []
args = session.posargs or ["--cov"]
session.run("poetry", "install", "--no-dev", external=True)
install_with_constraints(session, "pytest")
install_with_constraints(
session, "coverage[toml]", "pytest", "pytest-cov", "pytest-mock"
)
session.run("pytest", *args)
@nox.session()
def typeguard(session: Session) -> None:
"""Runtime type checking using Typeguard."""
args = session.posargs or ["-m", "not e2e"]
session.run("poetry", "install", "--no-dev", external=True)
install_with_constraints(session, "pytest", "pytest-mock", "typeguard")
session.run("pytest", f"--typeguard-packages={package}", *args)
This diff is collapsed.
......@@ -10,6 +10,23 @@ python = "^3.9"
[tool.poetry.dev-dependencies]
pytest = "^5.2"
black = "^21.9b0"
flake8 = "^3.9.2"
flake8-annotations = "^2.6.2"
flake8-black = "^0.2.3"
flake8-bandit = "^2.1.2"
flake8-bugbear = "^21.9.1"
flake8-docstrings = "^1.6.0"
flake8-import-order = "^0.18.1"
darglint = "^1.8.0"
coverage = "^5.5"
pytest-cov = "^2.12.1"
pytest-mock = "^3.6.1"
mypy = "^0.910"
typeguard = "^2.12.1"
safety = "^1.10.3"
Sphinx = "^4.2.0"
sphinx-autodoc-typehints = "^1.12.0"
sphinx-rtd-theme = "^1.0.0"
[tool.poetry.scripts]
cli = "fib_calc.cli:cli"
......@@ -17,3 +34,10 @@ cli = "fib_calc.cli:cli"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.coverage.paths]
source = ["src", "*/site-packages"]
[tool.coverage.run]
branch = true
source = ["fib_calc"]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment