common-python-tasks 0.0.1__tar.gz → 0.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (16) hide show
  1. {common_python_tasks-0.0.1 → common_python_tasks-0.0.2}/PKG-INFO +4 -4
  2. {common_python_tasks-0.0.1 → common_python_tasks-0.0.2}/README.md +1 -1
  3. {common_python_tasks-0.0.1 → common_python_tasks-0.0.2}/pyproject.toml +4 -4
  4. {common_python_tasks-0.0.1 → common_python_tasks-0.0.2}/src/common_python_tasks/__init__.py +3 -1
  5. common_python_tasks-0.0.2/src/common_python_tasks/data/.pytest_cache/.gitignore +2 -0
  6. common_python_tasks-0.0.2/src/common_python_tasks/data/.pytest_cache/CACHEDIR.TAG +4 -0
  7. common_python_tasks-0.0.2/src/common_python_tasks/data/.pytest_cache/README.md +8 -0
  8. common_python_tasks-0.0.2/src/common_python_tasks/data/.pytest_cache/v/cache/nodeids +47 -0
  9. {common_python_tasks-0.0.1 → common_python_tasks-0.0.2}/src/common_python_tasks/tasks.py +36 -57
  10. {common_python_tasks-0.0.1 → common_python_tasks-0.0.2}/LICENSE +0 -0
  11. {common_python_tasks-0.0.1 → common_python_tasks-0.0.2}/src/common_python_tasks/data/.coveragerc +0 -0
  12. {common_python_tasks-0.0.1 → common_python_tasks-0.0.2}/src/common_python_tasks/data/.dockerignore +0 -0
  13. {common_python_tasks-0.0.1 → common_python_tasks-0.0.2}/src/common_python_tasks/data/.flake8 +0 -0
  14. {common_python_tasks-0.0.1 → common_python_tasks-0.0.2}/src/common_python_tasks/data/.isort.cfg +0 -0
  15. {common_python_tasks-0.0.1 → common_python_tasks-0.0.2}/src/common_python_tasks/data/Containerfile +0 -0
  16. {common_python_tasks-0.0.1 → common_python_tasks-0.0.2}/src/common_python_tasks/data/pytest.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: common-python-tasks
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: Opinionated Poe the Poet tasks for Python package development.
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -26,8 +26,8 @@ Requires-Dist: pytest (>=9.0.1,<10.0.0)
26
26
  Requires-Dist: pytest-cov (>=7.0.0,<8.0.0)
27
27
  Requires-Dist: tomlkit (>=0.13.3,<0.14.0)
28
28
  Project-URL: Homepage, http://github.com/ci-sourcerer/common-python-tasks
29
- Project-URL: issues, http://github.com/ci-sourcerer/common-python-tasks/issues
30
- Project-URL: source, http://github.com/ci-sourcerer/common-python-tasks
29
+ Project-URL: Issues, http://github.com/ci-sourcerer/common-python-tasks/issues
30
+ Project-URL: Source, http://github.com/ci-sourcerer/common-python-tasks.git
31
31
  Description-Content-Type: text/markdown
32
32
 
33
33
  # Common Python tasks
@@ -41,7 +41,7 @@ This package is a collection of (very) opinionated [Poe the Poet Python tasks](h
41
41
  You can add `common-python-tasks` to a new project by using the handy automated installation script.
42
42
 
43
43
  ```shell
44
- curl -sSL https://api.github.com/repos/ci-sourcerer/common-python-tasks/contents/scripts/add-common-python-tasks.sh | TAGS_TO_INCLUDE="format lint test" sh
44
+ curl -sSL https://api.github.com/repos/ci-sourcerer/common-python-tasks/contents/scripts/add-common-python-tasks.sh | jq -r '.content' | base64 -d | TAGS_TO_INCLUDE="format lint test" sh
45
45
  ```
46
46
 
47
47
  This will complete the following steps.
@@ -9,7 +9,7 @@ This package is a collection of (very) opinionated [Poe the Poet Python tasks](h
9
9
  You can add `common-python-tasks` to a new project by using the handy automated installation script.
10
10
 
11
11
  ```shell
12
- curl -sSL https://api.github.com/repos/ci-sourcerer/common-python-tasks/contents/scripts/add-common-python-tasks.sh | TAGS_TO_INCLUDE="format lint test" sh
12
+ curl -sSL https://api.github.com/repos/ci-sourcerer/common-python-tasks/contents/scripts/add-common-python-tasks.sh | jq -r '.content' | base64 -d | TAGS_TO_INCLUDE="format lint test" sh
13
13
  ```
14
14
 
15
15
  This will complete the following steps.
@@ -29,12 +29,12 @@ dependencies = [
29
29
  "tomlkit (>=0.13.3,<0.14.0)",
30
30
  ]
31
31
  dynamic = []
32
- version = "0.0.1"
32
+ version = "0.0.2"
33
33
 
34
34
  [project.urls]
35
- homepage = "http://github.com/ci-sourcerer/common-python-tasks"
36
- issues = "http://github.com/ci-sourcerer/common-python-tasks/issues"
37
- source = "http://github.com/ci-sourcerer/common-python-tasks"
35
+ Homepage = "http://github.com/ci-sourcerer/common-python-tasks"
36
+ Source = "http://github.com/ci-sourcerer/common-python-tasks.git"
37
+ Issues = "http://github.com/ci-sourcerer/common-python-tasks/issues"
38
38
 
39
39
  [tool.poe]
40
40
  include_script = "common_python_tasks:tasks(exclude_tags=['containers'])"
@@ -10,7 +10,9 @@ __version__ = "0.0.0"
10
10
  __all__ = ["TaskCollection"]
11
11
 
12
12
 
13
- def tasks(include_tags: Sequence[str] = tuple(), exclude_tags: Sequence[str] = tuple()):
13
+ def tasks(
14
+ include_tags: "Sequence[str]" = tuple(), exclude_tags: "Sequence[str]" = tuple()
15
+ ):
14
16
  from .tasks import tasks
15
17
 
16
18
  return tasks(include_tags=include_tags, exclude_tags=exclude_tags)
@@ -0,0 +1,2 @@
1
+ # Created by pytest automatically.
2
+ *
@@ -0,0 +1,4 @@
1
+ Signature: 8a477f597d28d172789f06886806bc55
2
+ # This file is a cache directory tag created by pytest.
3
+ # For information about cache directory tags, see:
4
+ # https://bford.info/cachedir/spec.html
@@ -0,0 +1,8 @@
1
+ # pytest cache directory #
2
+
3
+ This directory contains data from the pytest's cache plugin,
4
+ which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
5
+
6
+ **Do not** commit this to version control.
7
+
8
+ See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.
@@ -0,0 +1,47 @@
1
+ [
2
+ "tests/test_build_image.py::TestBuildImageLatestTag::test_latest_tag_when_no_future_tags",
3
+ "tests/test_build_image.py::TestBuildImageLatestTag::test_no_latest_tag_when_future_tags_exist",
4
+ "tests/test_build_image.py::TestDockerignoreHandling::test_dockerignore_content_from_builtin",
5
+ "tests/test_build_image.py::TestDockerignoreHandling::test_preserves_existing_dockerignore",
6
+ "tests/test_build_image.py::TestDockerignoreHandling::test_temporary_dockerignore_cleanup_on_error",
7
+ "tests/test_build_image.py::TestDockerignoreHandling::test_temporary_dockerignore_created_and_removed",
8
+ "tests/test_build_image.py::TestDockerignoreHandling::test_uses_builtin_dockerignore_when_missing",
9
+ "tests/test_utilities.py::TestBumpVersion::test_bump_major_no_tags",
10
+ "tests/test_utilities.py::TestBumpVersion::test_bump_major_with_existing_tag",
11
+ "tests/test_utilities.py::TestBumpVersion::test_bump_minor_no_tags",
12
+ "tests/test_utilities.py::TestBumpVersion::test_bump_minor_with_existing_tag",
13
+ "tests/test_utilities.py::TestBumpVersion::test_bump_patch_alpha_no_tags",
14
+ "tests/test_utilities.py::TestBumpVersion::test_bump_patch_no_tags",
15
+ "tests/test_utilities.py::TestBumpVersion::test_bump_patch_with_existing_tag",
16
+ "tests/test_utilities.py::TestBumpVersion::test_bump_with_alpha_stage",
17
+ "tests/test_utilities.py::TestBumpVersion::test_bump_with_beta_stage",
18
+ "tests/test_utilities.py::TestBumpVersion::test_bump_with_rc_stage",
19
+ "tests/test_utilities.py::TestBumpVersion::test_bump_with_short_stage_names",
20
+ "tests/test_utilities.py::TestBumpVersion::test_case_insensitive_component",
21
+ "tests/test_utilities.py::TestBumpVersion::test_case_insensitive_stage",
22
+ "tests/test_utilities.py::TestBumpVersion::test_dirty_repo_fails",
23
+ "tests/test_utilities.py::TestBumpVersion::test_dry_run_no_tags",
24
+ "tests/test_utilities.py::TestBumpVersion::test_dry_run_with_existing_tag",
25
+ "tests/test_utilities.py::TestBumpVersion::test_invalid_component_fails",
26
+ "tests/test_utilities.py::TestBumpVersion::test_invalid_stage_fails",
27
+ "tests/test_utilities.py::TestBumpVersion::test_tag_without_v_prefix",
28
+ "tests/test_utilities.py::TestHasTagsLaterInHistory::test_git_tag_command_fails",
29
+ "tests/test_utilities.py::TestHasTagsLaterInHistory::test_has_tags_later_in_history",
30
+ "tests/test_utilities.py::TestHasTagsLaterInHistory::test_no_tags_exist",
31
+ "tests/test_utilities.py::TestHasTagsLaterInHistory::test_no_tags_later_in_history",
32
+ "tests/test_utilities.py::test_fatal_logs_and_exits",
33
+ "tests/test_utilities.py::test_fatal_with_custom_exit_code",
34
+ "tests/test_utilities.py::test_format_all_fails_when_no_tools_installed",
35
+ "tests/test_utilities.py::test_format_all_uses_run_available_tools",
36
+ "tests/test_utilities.py::test_is_package_installed_caches_results",
37
+ "tests/test_utilities.py::test_is_package_installed_handles_dashes",
38
+ "tests/test_utilities.py::test_is_package_installed_when_installed",
39
+ "tests/test_utilities.py::test_is_package_installed_when_not_installed",
40
+ "tests/test_utilities.py::test_lint_all_fails_when_no_tools_installed",
41
+ "tests/test_utilities.py::test_lint_all_uses_run_available_tools",
42
+ "tests/test_utilities.py::test_require_package_fails_when_not_installed",
43
+ "tests/test_utilities.py::test_require_package_succeeds_when_installed",
44
+ "tests/test_utilities.py::test_run_available_tools_fails_when_none_installed",
45
+ "tests/test_utilities.py::test_run_available_tools_runs_all_when_all_installed",
46
+ "tests/test_utilities.py::test_run_available_tools_runs_installed_tools"
47
+ ]
@@ -740,84 +740,63 @@ def bump_version(
740
740
  component: str = "patch",
741
741
  *,
742
742
  stage: str | None = None,
743
+ dry_run: bool = False,
743
744
  ) -> None:
744
745
  """Bump the project version.
745
746
 
746
747
  Args:
747
- component: The version component to bump: "major", "minor", or "patch".".
748
+ component: The version component to bump: "major", "minor", or "patch".
748
749
  stage: Optional pre-release stage to apply: "alpha", "beta", or "rc".
750
+ dry_run: If True, print what would happen without making changes.
749
751
  """
750
- from dunamai import Style, Version
752
+ from dunamai import Version
751
753
 
752
754
  component = component.lower()
753
755
  stage = stage.lower() if stage is not None else None
754
756
 
755
- # Check if repository is dirty
756
- if _run_command(
757
- ["git", "status", "--porcelain"], capture_output=True
758
- ).stdout.strip():
757
+ valid_components = {"major": 0, "minor": 1, "patch": 2}
758
+ if component not in valid_components:
759
+ _fatal(f'Invalid component "{component}". Must be one of: major, minor, patch')
760
+ bump_index: "Literal[0, 1, 2]" = valid_components[component]
761
+
762
+ if stage is not None and stage not in {"alpha", "a", "beta", "b", "rc"}:
763
+ _fatal(f'Invalid stage "{stage}". Must be one of: alpha, beta, rc')
764
+
765
+ if _get_dirty_files():
759
766
  _fatal(
760
- "Repository has uncommitted changes. Please commit or stash changes before bumping version."
767
+ "Repository has uncommitted changes. "
768
+ "Please commit or stash changes before bumping version."
761
769
  )
762
770
 
763
- # Try to get the latest tag; default to v0.0.0 if none exist
764
- last_tag_result = _run_command(
771
+ # Get the latest version tag
772
+ tag_result = _run_command(
765
773
  ["git", "describe", "--tags", "--abbrev=0"],
766
774
  capture_output=True,
767
775
  acceptable_returncodes={0, 128},
768
776
  )
769
- last_tag = (
770
- last_tag_result.stdout.strip() if last_tag_result.returncode == 0 else "v0.0.0"
771
- )
772
777
 
773
- # Check if current version equals the last tag, refuse to bump if so
774
- current_version = _get_version()
775
- # Normalize last tag by stripping leading 'v' if present
776
- normalized_last_tag = last_tag[1:] if last_tag.startswith("v") else last_tag
777
- if current_version == normalized_last_tag and last_tag != "v0.0.0":
778
- _fatal(
779
- "There have been no changes since the last version tag; cannot bump version as it would not change."
780
- )
778
+ if tag_result.returncode == 0 and tag_result.stdout.strip():
779
+ version_str = tag_result.stdout.strip().lstrip("v")
780
+ else:
781
+ version_str = "0.0.0"
781
782
 
782
- possible_components = ("major", "minor", "patch")
783
- if component not in possible_components:
784
- _fatal(
785
- f'Invalid component "{component}". Must be one of: {"\n".join(possible_components)}'
786
- )
787
- component_index: "Literal[0, 1, 2]" = possible_components.index(component)
788
-
789
- prerelease_options = {
790
- "a": "alpha",
791
- "alpha": "alpha",
792
- "b": "beta",
793
- "beta": "beta",
794
- "rc": "rc",
795
- }
796
- normalized_stage = None
783
+ bumped = Version.parse(version_str).bump(bump_index)
784
+
785
+ # Apply pre-release stage if specified
797
786
  if stage is not None:
798
- if stage not in prerelease_options:
799
- _fatal(f'Invalid stage "{stage}". Must be one of: alpha, beta, rc')
800
- normalized_stage = prerelease_options[stage]
801
-
802
- # Bump version using dunamai
803
- if last_tag == "v0.0.0":
804
- # No real tags yet; bump from 0.0.0
805
- base_version = Version.parse("0.0.0")
806
- new_version = base_version.bump(component_index)
787
+ # Normalize stage name
788
+ bumped.stage = {"a": "alpha", "b": "beta"}.get(stage, stage)
789
+ bumped.revision = 1
790
+
791
+ # Format the new version string
792
+ new_version = bumped.serialize()
793
+
794
+ if dry_run:
795
+ LOGGER.info("Dry run: would bump version to %s", new_version)
807
796
  else:
808
- new_version = Version.from_git().bump(component_index)
809
-
810
- if normalized_stage is not None:
811
- if new_version.stage != normalized_stage:
812
- new_version.stage = normalized_stage
813
- new_version.revision = 1
814
- elif new_version.revision is None:
815
- new_version.revision = 1
816
-
817
- # Serialize without dirty flag for clean release tags
818
- serialized = new_version.serialize(style=Style.Pep440)
819
- LOGGER.info("Bumping version to %s", serialized)
820
- _run_command(["git", "tag", f"v{serialized}"])
797
+ new_tag = f"v{new_version}"
798
+ LOGGER.info("Bumping version to %s", new_version)
799
+ _run_command(["git", "tag", new_tag])
821
800
 
822
801
 
823
802
  def _build(