diff --git a/src/nox_poetry/core.py b/src/nox_poetry/core.py index 4412737d..203eba44 100644 --- a/src/nox_poetry/core.py +++ b/src/nox_poetry/core.py @@ -3,9 +3,11 @@ .. deprecated:: 0.8 Use :func:`session` instead. """ +import warnings from pathlib import Path from typing import Any from typing import Iterable +from typing import Optional import nox.sessions @@ -16,12 +18,20 @@ Session_install = nox.sessions.Session.install +def _deprecate(name: str, replacement: Optional[str] = None) -> None: + message = f"nox_poetry.{name} is deprecated, use @nox_poetry.session instead" + if replacement is not None: + message += f" and invoke {replacement}" + warnings.warn(message, category=FutureWarning, stacklevel=2) + + 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() @@ -33,6 +43,7 @@ def build_package( .. deprecated:: 0.8 Use :func:`session` instead. """ + _deprecate("build_package", "session.poetry.build_package") return Session(session).poetry.build_package( distribution_format=distribution_format ) @@ -44,6 +55,7 @@ def install(session: nox.sessions.Session, *args: str, **kwargs: Any) -> None: .. deprecated:: 0.8 Use :func:`session` instead. """ # noqa: D + _deprecate("install", "session.install") Session(session).install(*args, **kwargs) @@ -58,6 +70,7 @@ def installroot( .. deprecated:: 0.8 Use :func:`session` instead. """ + _deprecate("installroot", "session.poetry.installroot") Session(session).poetry.installroot( distribution_format=distribution_format, extras=extras ) @@ -86,4 +99,5 @@ def patch( distribution_format: The distribution format to use when the ``"."`` argument is encountered in calls to ``session.install``. """ + _deprecate("patch") nox.sessions.Session.install = install # type: ignore[assignment]