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

fix: retain the typing Optional compatibility import · gitpython-developers/GitPython@75ceb38 · GitHub

Repository navigation

Commit 75ceb38

Browse files
authored andcommitted
fix: retain the typing Optional compatibility import
MkDocs RSS Plugin 1.19.0 imports `Optional` from `git` while importing its actual utility module. Released GitPython 3.2.1 exposes `typing.Optional`, whereas the migrated package renamed that import and prevents the plugin from loading. Restore the explicit public alias and use it for the existing `refresh()` annotation. Wildcard exports and Git operations are unchanged. The new import regression fails before the fix. All 40 downstream compatibility cases pass on CLI and Gix; Ruff lint/format, mypy for `git/__init__.py`, and `git diff --check` pass. A forced released baseline proves the alias and actual plugin import in site-packages.
1 parent cdf3cff commit 75ceb38

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎doc/source/changes.rst‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ API changes
5555
restoring Kas's Git identity cleanup. Git performs each mutation and locks
5656
it independently; replacement is not one atomic transaction. Empty sections
5757
and ``add_section()`` remain unsupported, including Kas's SSH key setup.
58-
* Explicit ``from git import Union`` imports remain available for Demisto SDK's
59-
validator registration, retaining the historical ``typing.Union`` alias.
58+
* Explicit ``from git import Union`` and ``Optional`` imports remain available
59+
for Demisto SDK's validator registration and MkDocs RSS Plugin imports,
60+
retaining the historical ``typing`` aliases.
6061
* Editable/source imports expose the release version in ``git.__version__``,
6162
matching built distributions. Salt's GitPython provider checks can parse the
6263
version instead of rejecting the unstamped ``"git"`` build placeholder.

‎git/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787

8888
__version__ = (_Path(__file__).resolve().parents[1] / "VERSION").read_text(encoding="utf-8").strip()
8989

90-
from typing import Optional as _Optional
90+
from typing import Optional as Optional # Compatibility for downstream explicit imports.
9191
from typing import Union as Union # Compatibility for downstream explicit imports.
9292

9393
from git.util import to_hex_sha
@@ -182,7 +182,7 @@
182182
GIT_OK = None
183183

184184

185-
def refresh(path: _Optional[PathLike] = None) -> None:
185+
def refresh(path: Optional[PathLike] = None) -> None:
186186
"""Convenience method for setting the git executable path.
187187
188188
:param path:

‎test/test_downstream_compatibility.py‎

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

33
from pathlib import Path
4-
from typing import Union
4+
from typing import Optional, Union
55
from importlib.metadata import version
66

77
import pytest
@@ -22,6 +22,12 @@ def test_legacy_typing_union_import_supports_downstream_registration():
2222
assert GitUnion is Union
2323

2424

25+
def test_legacy_typing_optional_import_supports_downstream_plugin_import():
26+
from git import Optional as GitOptional
27+
28+
assert GitOptional is Optional
29+
30+
2531
@pytest.mark.parametrize("object_format", ["sha1", "sha256"])
2632
@pytest.mark.parametrize("ref_format", ["files", "reftable"])
2733
def test_config_section_assignment_restores_downstream_git_identity(object_format, ref_format):

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL