Skip to content

Commit fbc375d

Browse files
committed
Build: Declare typing-extensions as a core dependency
typing_extensions is imported unconditionally at module import time: `Self` in pyiceberg/typedef.py (a module imported transitively by nearly the whole package) and `override` in ten catalog and IO modules. Both are top-level runtime imports, not guarded by TYPE_CHECKING, and typing.Self / typing.override are only in the standard library on Python 3.11+ / 3.12+ while pyiceberg supports Python 3.10. However typing-extensions was declared only in the dev dependency group, so the distributed package under-declared a required import. It works today solely because pydantic pulls typing-extensions in transitively; if that transitive edge ever changes, `import pyiceberg` would fail with ModuleNotFoundError. Move it to [project.dependencies] with a floor of 4.4.0 (the release that added `override`; `Self` landed in 4.0.0). deptry (already a dev dependency) flags this as DEP004 at every import site. Regenerate uv.lock accordingly. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
1 parent 1a87aa3 commit fbc375d

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ dependencies = [
4343
"tenacity>=8.2.3",
4444
"pyroaring>=1.0.0",
4545
"cachetools>=5.5",
46-
"zstandard>=0.13.0"
46+
"zstandard>=0.13.0",
47+
"typing-extensions>=4.4.0" # Self/override are imported at runtime on Python < 3.12
4748
]
4849

4950
[project.urls]

tests/test_version.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,22 @@ def test_version_format() -> None:
2828
"This failure could be due to a recent version bump in the Pyiceberg library. "
2929
"Please ensure you have the latest version installed by rerunning `make install` command."
3030
)
31+
32+
33+
def test_typing_extensions_is_a_core_dependency() -> None:
34+
# typing_extensions is imported unconditionally at import time (e.g. Self in
35+
# pyiceberg/typedef.py, override in the catalog and IO modules), so it must be a
36+
# core runtime dependency rather than only a development one.
37+
from importlib import metadata
38+
39+
from packaging.requirements import Requirement
40+
from packaging.utils import canonicalize_name
41+
42+
requirements = [Requirement(requirement) for requirement in metadata.requires("pyiceberg") or []]
43+
# Core dependencies carry no environment marker; optional extras add "; extra == ...".
44+
core_dependencies = {canonicalize_name(requirement.name) for requirement in requirements if requirement.marker is None}
45+
46+
assert canonicalize_name("typing-extensions") in core_dependencies, (
47+
"typing-extensions must be declared in [project.dependencies] because it is imported at runtime; "
48+
"found only these core dependencies: " + ", ".join(sorted(core_dependencies))
49+
)

uv.lock

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)