Skip to content

Commit

Permalink
feat: Return early if poetry command raises CommandSkippedError
Browse files Browse the repository at this point in the history
  • Loading branch information
cjolowicz committed Jun 11, 2021
1 parent 97c21c5 commit 9f689b9
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/nox_poetry/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from packaging.requirements import InvalidRequirement
from packaging.requirements import Requirement

from nox_poetry.poetry import CommandSkippedError
from nox_poetry.poetry import DistributionFormat
from nox_poetry.poetry import Poetry

Expand Down Expand Up @@ -120,12 +121,18 @@ def install(self, *args: str, **kwargs: Any) -> None:
kwargs: Keyword-arguments for ``session.install``. These are the same
as those for :meth:`nox.sessions.Session.run`.
"""
if not self._install_enabled():
return

from nox_poetry.core import Session_install

args_extras = [_split_extras(arg) for arg in args]

if "." in [arg for arg, _ in args_extras]:
package = self.build_package()
try:
package = self.build_package()
except CommandSkippedError:
return

def rewrite(arg: str, extras: Optional[str]) -> str:
if arg != ".":
Expand All @@ -141,7 +148,11 @@ def rewrite(arg: str, extras: Optional[str]) -> str:

self.session.run_always("pip", "uninstall", "--yes", package, silent=True)

requirements = self.export_requirements()
try:
requirements = self.export_requirements()
except CommandSkippedError:
return

Session_install(self.session, f"--constraint={requirements}", *args, **kwargs)

def installroot(
Expand All @@ -165,10 +176,16 @@ def installroot(
distribution_format: The distribution format, either wheel or sdist.
extras: Extras to install for the package.
"""
if not self._install_enabled():
return

from nox_poetry.core import Session_install

package = self.build_package(distribution_format=distribution_format)
requirements = self.export_requirements()
try:
package = self.build_package(distribution_format=distribution_format)
requirements = self.export_requirements()
except CommandSkippedError:
return

self.session.run_always("pip", "uninstall", "--yes", package, silent=True)

Expand Down

0 comments on commit 9f689b9

Please sign in to comment.