Skip to content

Commit

Permalink
fix: support == as pinned
Browse files Browse the repository at this point in the history
  • Loading branch information
KotlinIsland committed Feb 10, 2023
1 parent 81176a0 commit 4f6d119
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/poetry_plugin_up/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def is_bumpable(

constraint = dependency.pretty_constraint
if not latest:
if constraint[0].isdigit():
if is_pinned(constraint):
# pinned
return False
if constraint[0] == "*":
Expand All @@ -182,7 +182,7 @@ def is_bumpable(
return False

if not pinned:
if constraint[0].isdigit():
if is_pinned(constraint):
# pinned
return False

Expand Down Expand Up @@ -218,3 +218,8 @@ def bump_version_in_pyproject_content(
section[dependency.pretty_name] = new_version
elif "version" in section.get(dependency.pretty_name, {}):
section[dependency.pretty_name]["version"] = new_version


def is_pinned(version: str) -> bool:
"""Returns if `version` is an exact version."""
return version[0].isdigit() or version[:2] == "=="
25 changes: 25 additions & 0 deletions tests/unit/test_unit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from poetry.core.packages.dependency import Dependency
from tomlkit import parse

from src.poetry_plugin_up.command import is_pinned
from tests.helpers import TestUpCommand


Expand Down Expand Up @@ -387,6 +388,30 @@ def test_is_bumpable_is_true_when_version_pinned_and_latest_and_pinned(
assert is_bumpable is True


def test_is_pinned() -> None:
assert is_pinned("1.1.1")
assert is_pinned("==1.1.1")
assert not is_pinned("^1.1.1")
assert not is_pinned(">=1.1.1")
assert not is_pinned("~1.1.1")


def test_is_bumpable_is_false_when_version_pinned_with_with_equals_and_latest(
up_cmd_tester: TestUpCommand,
) -> None:
dependency = Dependency(
name="foo",
constraint="==1.2.3",
)
is_bumpable = up_cmd_tester.is_bumpable(
dependency=dependency,
only_packages=[],
latest=True,
pinned=False,
)
assert is_bumpable is False


def test_is_bumpable_is_true_when_version_wildcard_and_latest(
up_cmd_tester: TestUpCommand,
) -> None:
Expand Down

0 comments on commit 4f6d119

Please sign in to comment.