FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: retain the typing Union compatibility import · gitpython-developers/GitPython@1d10bdc · GitHub

Repository navigation

Commit 1d10bdc

Browse files
authored andcommitted
fix: retain the typing Union compatibility import
Demisto SDK imports `Union` from `git` while registering validators. Released GitPython exposes `typing.Union`; removing that incidental export prevents its unchanged root test conftest and CLI command registration from importing. Retain the explicit alias without changing wildcard exports or adding Git behavior. This unblocks the existing caller while preserving the narrower package namespace elsewhere. The import regression failed before this change. All 35 downstream compatibility cases pass on CLI and Gix. Ruff lint/format, mypy for `git/__init__.py`, and `git diff --check` pass. Released GitPython 3.2.1 was force-installed and verified in site-packages for the downstream baseline.
1 parent 1074925 commit 1d10bdc

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎doc/source/changes.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ Git executable and safety
5151
API changes
5252
-----------
5353

54+
* Explicit ``from git import Union`` imports remain available for Demisto SDK's
55+
validator registration, retaining the historical ``typing.Union`` alias.
5456
* Editable/source imports expose the release version in ``git.__version__``,
5557
matching built distributions. Salt's GitPython provider checks can parse the
5658
version instead of rejecting the unstamped ``"git"`` build placeholder.

‎git/__init__.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
__version__ = (_Path(__file__).resolve().parents[1] / "VERSION").read_text(encoding="utf-8").strip()
8989

9090
from typing import Optional as _Optional
91+
from typing import Union as Union # Compatibility for downstream explicit imports.
9192

9293
from git.util import to_hex_sha
9394

‎test/test_downstream_compatibility.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Public GitPython queries used by released downstream projects."""
22

33
from pathlib import Path
4+
from typing import Union
45
from importlib.metadata import version
56

67
import pytest
@@ -15,6 +16,12 @@ def test_public_version_supports_downstream_provider_checks():
1516
assert git.__version__ == version("GitPython")
1617

1718

19+
def test_legacy_typing_union_import_supports_downstream_registration():
20+
from git import Union as GitUnion
21+
22+
assert GitUnion is Union
23+
24+
1825
@pytest.mark.parametrize("object_format", ["sha1", "sha256"])
1926
@pytest.mark.parametrize("ref_format", ["files", "reftable"])
2027
def test_repo_accepts_explicit_literal_path_selection(object_format, ref_format, monkeypatch):

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL