Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.bumpversion]
allow_dirty = true
current_version = "0.184.1"
current_version = "0.184.2"

[[tool.bumpversion.files]]
filename = "pyproject.toml"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
name = "dycw-utilities"
readme = "README.md"
requires-python = ">= 3.12"
version = "0.184.1"
version = "0.184.2"

[project.entry-points.pytest11]
pytest-randomly = "utilities.pytest_plugins.pytest_randomly"
Expand Down
10 changes: 10 additions & 0 deletions src/tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ def test_bump_minor(self, *, version: Version2) -> None:
assert bumped.minor == version.minor + 1
assert bumped.suffix is None

@given(version=version2s(), patch=integers(min_value=0))
def test_version3(self, *, version: Version2, patch: int) -> None:
new = version.version3(patch=patch).version2
assert new == version

@given(version=version2s(), suffix=text_ascii(min_size=1) | none())
def test_with_suffix(self, *, version: Version2, suffix: str | None) -> None:
new = version.with_suffix(suffix=suffix)
Expand Down Expand Up @@ -184,6 +189,11 @@ def test_with_suffix(self, *, version: Version3, suffix: str | None) -> None:
assert new.patch == version.patch
assert new.suffix == suffix

@given(version=version3s())
def test_version2(self, *, version: Version3) -> None:
new = version.version2.version3(patch=version.patch)
assert new == version

@given(version=version3s())
def test_error_order(self, *, version: Version3) -> None:
with raises(TypeError):
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/__init__.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/utilities/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def bump_minor(self) -> Self:
"""Bump the minor component."""
return type(self)(self.major, self.minor + 1)

def version3(self, *, patch: int = 0) -> Version3:
"""Convert to a Version3 object."""
return Version3(self.major, self.minor, patch, suffix=self.suffix)

def with_suffix(self, *, suffix: str | None = None) -> Self:
"""Replace the suffix."""
return replace(self, suffix=suffix)
Expand Down Expand Up @@ -212,6 +216,11 @@ def bump_patch(self) -> Self:
"""Bump the patch component."""
return type(self)(self.major, self.minor, self.patch + 1)

@property
def version2(self) -> Version2:
"""Return the major/minor components only."""
return Version2(self.major, self.minor, suffix=self.suffix)

def with_suffix(self, *, suffix: str | None = None) -> Self:
"""Replace the suffix."""
return replace(self, suffix=suffix)
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading