Skip to content

Commit

Permalink
feat: Add deprecation warnings to core functions
Browse files Browse the repository at this point in the history
  • Loading branch information
cjolowicz committed Feb 4, 2021
1 parent 04adc68 commit c389504
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/nox_poetry/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()


Expand All @@ -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
)
Expand All @@ -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)


Expand All @@ -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
)
Expand Down Expand Up @@ -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]

0 comments on commit c389504

Please sign in to comment.