-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
250 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,44 @@ | ||
.venv | ||
# Testing, packaging, and documentation artifacts | ||
.coverage | ||
.coverage.* | ||
_build | ||
.DS_Store | ||
.vscode | ||
docs/_static/pypi.svg | ||
.tox | ||
__pycache__ | ||
|
||
# Packaging artifacts | ||
black.egg-info | ||
black.dist-info | ||
docs/_build/ | ||
docs/build/ | ||
build/ | ||
dist/ | ||
black.egg-info | ||
black.dist-info/ | ||
pip-wheel-metadata/ | ||
.eggs | ||
.eggs/ | ||
wheels/ | ||
|
||
src/_black_version.py | ||
.idea | ||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Virtual environments | ||
env | ||
venv | ||
.env | ||
.venv | ||
.nox | ||
.tox | ||
|
||
# Caches / temporary files | ||
.mypy_cache/ | ||
.dmypy.json | ||
*.swp | ||
.hypothesis/ | ||
venv/ | ||
.ipynb_checkpoints/ | ||
__pycache__/ | ||
|
||
# Black autogenerated files | ||
docs/_static/pypi.svg | ||
src/_black_version.py | ||
|
||
# Personal developer files | ||
.vscode/ | ||
.editorconfig | ||
.DS_Store | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import shutil | ||
from pathlib import Path | ||
from typing import Union | ||
|
||
import nox | ||
|
||
SUPPORTED_PYTHONS = ["3.6", "3.7", "3.8", "3.9", "3.10", "pypy3"] | ||
THIS_DIR = Path(__file__).parent | ||
TESTS_DIR = THIS_DIR / "tests" | ||
SCRIPTS_DIR = THIS_DIR / "scripts" | ||
|
||
# ============ # | ||
# Utilities | ||
# ============ # | ||
|
||
|
||
def get_flag(session: nox.Session, flag: str) -> bool: | ||
if flag in session.posargs: | ||
index = session.posargs.index(flag) | ||
del session.posargs[index] | ||
return True | ||
|
||
return False | ||
|
||
|
||
def wipe(session: nox.Session, path: Union[str, Path]) -> None: | ||
if isinstance(path, str): | ||
path = Path.cwd() / path | ||
if not path.exists(): | ||
return | ||
|
||
normalized = path.relative_to(Path.cwd()) | ||
if path.is_file(): | ||
session.log(f"Deleting '{normalized}' file") | ||
path.unlink() | ||
elif path.is_dir(): | ||
session.log(f"Deleting '{normalized}' directory") | ||
shutil.rmtree(path) | ||
|
||
|
||
# ============ # | ||
# Sessions | ||
# ============ # | ||
|
||
|
||
@nox.session() | ||
def lint(session: nox.Session) -> None: | ||
session.install("pre-commit>=2.9.2") | ||
session.run("pre-commit", "run", "--all-files", "--show-diff-on-failure") | ||
|
||
|
||
@nox.session(python=SUPPORTED_PYTHONS) | ||
def tests(session: nox.Session) -> None: | ||
coverage = not get_flag(session, "--no-cov") | ||
parallelize = not get_flag(session, "--no-xdist") | ||
|
||
session.install("-r", str(TESTS_DIR / "requirements.txt")) | ||
session.install(".[d]") | ||
base = ["pytest", str(TESTS_DIR), "-Wall", "--strict-config", "--strict-markers"] | ||
if coverage: | ||
session.run("coverage", "erase") | ||
base.extend(("--cov", "--cov-append")) | ||
if parallelize: | ||
base.extend(("--numprocesses", "auto")) | ||
|
||
session.run("python", "-m", "pip", "uninstall", "ipython", "-y") | ||
session.run(*base, "--run-optional=no_jupyter", *session.posargs) | ||
session.install(".[jupyter]") | ||
session.run(*base, "--run-optional=jupyter", "-m", "jupyter", *session.posargs) | ||
if coverage: | ||
session.run("coverage", "report") | ||
|
||
|
||
@nox.session() | ||
def docs(session: nox.Session) -> None: | ||
session.install("-e", ".[d]") | ||
session.cd("docs") | ||
wipe(session, "_build") | ||
session.install("-r", "requirements.txt") | ||
session.run("sphinx-build", ".", "_build", "-E", "-W", "-a", "--keep-going") | ||
|
||
|
||
@nox.session(name="docs-live") | ||
def docs_live(session: nox.Session) -> None: | ||
session.install("-e", ".[d]") | ||
session.cd("docs") | ||
wipe(session, "_build") | ||
session.install("-r", "requirements.txt", "sphinx-autobuild") | ||
session.run( | ||
"sphinx-autobuild", ".", "_build", "--ignore", "**/pypi.svg", *session.posargs | ||
) | ||
|
||
|
||
@nox.session() | ||
def fuzz(session: nox.Session) -> None: | ||
session.install("-r", "test_requirements.txt", "hypothesmith") | ||
session.install(".") | ||
session.run("coverage", "erase") | ||
session.run("coverage", "run", str(SCRIPTS_DIR / "fuzz.py")) | ||
session.run("coverage", "report") |
File renamed without changes.
Oops, something went wrong.