Пример #1
0
def docs_linkcheck(session: Session) -> None:
    """Check there are no dead links in the docs."""
    session.install(".[docs]")
    with tempfile.TemporaryDirectory() as tmp_dir:
        session.run(
            "sphinx-build",
            "-d",
            f"{tmp_dir}/docs_doctree",
            "docs",
            f"{tmp_dir}/docs_out",
            "--color",
            "-W",
            "-blinkcheck",
        )
Пример #2
0
def docs(session: Session) -> None:
    """Check that the docs build properly."""
    session.install(".[docs]")
    with tempfile.TemporaryDirectory() as tmp_dir:
        session.run(
            "sphinx-build",
            "-d",
            f"{tmp_dir}/docs_doctree",
            "docs",
            f"{tmp_dir}/docs_out",
            "--color",
            "-W",
            "-bhtml",
        )
Пример #3
0
def safety(session: Session) -> None:
    """Run safety against the installed environment."""
    session.install(".")
    # Update what comes packaged in the venv
    session.run_always("pip", "install", "-U", "pip", "setuptools", "wheel")
    session.install("safety")
    session.run("python", "-m", "safety", "check")
Пример #4
0
def install(session: nox.sessions.Session, *args: str, **kwargs: Any) -> None:
    """Install packages into a Nox session using Poetry.

    .. deprecated:: 0.8
       Use :func:`session` instead.
    """  # noqa: D
    _deprecate("install", "session.install")
    Session(session).install(*args, **kwargs)
Пример #5
0
def export_requirements(session: nox.sessions.Session) -> Path:
    """Export a requirements file from Poetry.

    .. deprecated:: 0.8
       Use :func:`session` instead.
    """  # noqa: D
    _deprecate("export_requirements", "session.poetry.export_requirements")
    return Session(session).poetry.export_requirements()
Пример #6
0
def build_package(session: nox.sessions.Session, *,
                  distribution_format: str) -> str:
    """Build a distribution archive for the package.  # noqa: DAR

    .. deprecated:: 0.8
       Use :func:`session` instead.
    """
    _deprecate("build_package", "session.poetry.build_package")
    return Session(session).poetry.build_package(
        distribution_format=distribution_format)
Пример #7
0
def pylint(session: Session) -> None:
    """Run pylint."""
    session.install(".[docs,tests]")
    session.install("pylint")
    session.install(*IMPORTED_DEV_REQUIREMENTS)
    session.run(
        "python",
        "-m",
        "pylint",
        "src/",
        "tests/",
        "tasks.py",
        "noxfile.py",
    )
Пример #8
0
def installroot(
        session: nox.sessions.Session,
        *,  # noqa: DAR
        distribution_format: str,
        extras: Iterable[str] = (),
) -> None:
    """Install the root package into a Nox session using Poetry.

    .. deprecated:: 0.8
       Use :func:`session` instead.
    """
    _deprecate("installroot", "session.poetry.installroot")
    Session(session).poetry.installroot(
        distribution_format=distribution_format, extras=extras)
Пример #9
0
def test(session: Session) -> None:
    """Run the unit tests."""
    # Remove the coverage file if it exists
    coverage_file = Path(".coverage")
    if coverage_file.exists():
        coverage_file.unlink()

    session.install(".[tests]")
    session.run("coverage", "run", "-p", "--branch", "-m", "pytest")
    session.notify("coverage")
Пример #10
0
def mypy(session: Session) -> None:
    """Run mypy."""
    session.install(".[docs,tests]", *IMPORTED_DEV_REQUIREMENTS)
    # Can't typecheck tasks.py until the following is fixed:
    # https://github.com/pyinvoke/invoke/issues/357
    session.install("mypy")
    session.run(
        "python",
        "-m",
        "mypy",
        "--non-interactive",
        "--install-types",
        "--scripts-are-modules",
        "src/",
        "tests/",
        "noxfile.py",
    )
Пример #11
0
def lint(session: Session):
    session.install("flake8", "black", "isort", "safety", "pytest", ".")
    session.run("flake8")
    session.run("black", ".", "--check")
    session.run("isort", ".", "--check-only")
    requirements_file = session.poetry.export_requirements()
    session.run("safety", "check", "-r", str(requirements_file))
    session.run("pytest")
Пример #12
0
def pre_commit(session: Session) -> None:
    """Run pre-commit against all files."""
    session.install("pre-commit")
    session.run("python", "-m", "pre_commit", "run", "--all-files",
                "--show-diff-on-failure")
Пример #13
0
def coverage(session: Session) -> None:
    """Generate combined coverage metrics."""
    session.install("coverage[toml]")
    session.run("coverage", "combine")
    session.run("coverage", "report")
Пример #14
0
def build(session: Session) -> None:
    """Check that the package builds properly."""
    session.install("build", "twine")
    with TemporaryDirectory() as tmp_dir:
        session.run("python", "-m", "build", "--outdir", tmp_dir, ".")
        session.run("python", "-m", "twine", "check", tmp_dir + "/*")