Skip to content

session

frequenz.repo.config.nox.session ¤

Predefined nox sessions.

This module defines the predefined nox sessions that are used by the default.

Functions¤

frequenz.repo.config.nox.session.ci_checks_max(session) ¤

Run all checks with max dependencies in a single session.

This is faster than running the checks separately, so it is suitable for CI.

This does NOT run pytest_min, so that needs to be run separately as well.

PARAMETER DESCRIPTION
session

the nox session.

TYPE: nox.Session

Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/frequenz/repo/config/nox/session.py
@nox.session
def ci_checks_max(session: nox.Session) -> None:
    """Run all checks with max dependencies in a single session.

    This is faster than running the checks separately, so it is suitable for CI.

    This does NOT run pytest_min, so that needs to be run separately as well.

    Args:
        session: the nox session.
    """
    session.install("-e", ".[dev]")

    formatting(session, False)
    mypy(session, False)
    pylint(session, False)
    docstrings(session, False)
    pytest_max(session, False)

frequenz.repo.config.nox.session.docstrings(session, install_deps=True) ¤

Check docstring tone with pydocstyle and param descriptions with darglint.

PARAMETER DESCRIPTION
session

the nox session.

TYPE: nox.Session

install_deps

True if dependencies should be installed.

TYPE: bool DEFAULT: True

Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/frequenz/repo/config/nox/session.py
@nox.session
def docstrings(session: nox.Session, install_deps: bool = True) -> None:
    """Check docstring tone with pydocstyle and param descriptions with darglint.

    Args:
        session: the nox session.
        install_deps: True if dependencies should be installed.
    """
    if install_deps:
        session.install("-e", ".[dev-docstrings]")

    conf = _config.get()
    session.run("pydocstyle", *conf.opts.pydocstyle, *conf.path_args(session))

    # Darglint checks that function argument and return values are documented.
    # This is needed only for the `src` dir, so we exclude the other top level
    # dirs that contain code, unless some paths were specified by argument, in
    # which case we use those untouched.
    darglint_paths = session.posargs or filter(
        # pylint: disable=fixme
        # TODO: Make these exclusions configurable
        lambda path: not (path.startswith("tests") or path.startswith("benchmarks")),
        conf.path_args(session),
    )
    session.run("darglint", *conf.opts.darglint, *darglint_paths)

frequenz.repo.config.nox.session.formatting(session, install_deps=True) ¤

Check code formatting with black and isort.

PARAMETER DESCRIPTION
session

the nox session.

TYPE: nox.Session

install_deps

True if dependencies should be installed.

TYPE: bool DEFAULT: True

Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/frequenz/repo/config/nox/session.py
@nox.session
def formatting(session: nox.Session, install_deps: bool = True) -> None:
    """Check code formatting with black and isort.

    Args:
        session: the nox session.
        install_deps: True if dependencies should be installed.
    """
    if install_deps:
        session.install("-e", ".[dev-formatting]")

    conf = _config.get()
    session.run("black", *conf.opts.black, *conf.path_args(session))
    session.run("isort", *conf.opts.isort, *conf.path_args(session))

frequenz.repo.config.nox.session.mypy(session, install_deps=True) ¤

Check type hints with mypy.

PARAMETER DESCRIPTION
session

the nox session.

TYPE: nox.Session

install_deps

True if dependencies should be installed.

TYPE: bool DEFAULT: True

Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/frequenz/repo/config/nox/session.py
@nox.session
def mypy(session: nox.Session, install_deps: bool = True) -> None:
    """Check type hints with mypy.

    Args:
        session: the nox session.
        install_deps: True if dependencies should be installed.
    """
    if install_deps:
        # install the package itself as editable, so that it is possible to do
        # fast local tests with `nox -R -e mypy`.
        session.install("-e", ".[dev-mypy]")

    conf = _config.get()
    pkg_args = _util.flatten(("-p", p) for p in conf.package_args(session))
    session.run("mypy", *conf.opts.mypy, *pkg_args)

frequenz.repo.config.nox.session.pylint(session, install_deps=True) ¤

Check for code smells with pylint.

PARAMETER DESCRIPTION
session

the nox session.

TYPE: nox.Session

install_deps

True if dependencies should be installed.

TYPE: bool DEFAULT: True

Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/frequenz/repo/config/nox/session.py
@nox.session
def pylint(session: nox.Session, install_deps: bool = True) -> None:
    """Check for code smells with pylint.

    Args:
        session: the nox session.
        install_deps: True if dependencies should be installed.
    """
    if install_deps:
        # install the package itself as editable, so that it is possible to do
        # fast local tests with `nox -R -e pylint`.
        session.install("-e", ".[dev-pylint]")

    conf = _config.get()
    session.run("pylint", *conf.opts.pylint, *conf.path_args(session))

frequenz.repo.config.nox.session.pytest_max(session, install_deps=True) ¤

Test the code against max dependency versions with pytest.

PARAMETER DESCRIPTION
session

the nox session.

TYPE: nox.Session

install_deps

True if dependencies should be installed.

TYPE: bool DEFAULT: True

Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/frequenz/repo/config/nox/session.py
@nox.session
def pytest_max(session: nox.Session, install_deps: bool = True) -> None:
    """Test the code against max dependency versions with pytest.

    Args:
        session: the nox session.
        install_deps: True if dependencies should be installed.
    """
    if install_deps:
        # install the package itself as editable, so that it is possible to do
        # fast local tests with `nox -R -e pytest_max`.
        session.install("-e", ".[dev-pytest]")

    _pytest_impl(session, "max")

frequenz.repo.config.nox.session.pytest_min(session, install_deps=True) ¤

Test the code against min dependency versions with pytest.

PARAMETER DESCRIPTION
session

the nox session.

TYPE: nox.Session

install_deps

True if dependencies should be installed.

TYPE: bool DEFAULT: True

Source code in /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/frequenz/repo/config/nox/session.py
@nox.session
def pytest_min(session: nox.Session, install_deps: bool = True) -> None:
    """Test the code against min dependency versions with pytest.

    Args:
        session: the nox session.
        install_deps: True if dependencies should be installed.
    """
    if install_deps:
        # install the package itself as editable, so that it is possible to do
        # fast local tests with `nox -R -e pytest_min`.
        session.install("-e", ".[dev-pytest]", *_util.min_dependencies())

    _pytest_impl(session, "min")