Skip to content

fix(deps): declare typing-extensions as runtime dependency#112

Open
straightchlorine wants to merge 1 commit into
qTipTip:masterfrom
straightchlorine:fix/declare-typing-extensions-dep
Open

fix(deps): declare typing-extensions as runtime dependency#112
straightchlorine wants to merge 1 commit into
qTipTip:masterfrom
straightchlorine:fix/declare-typing-extensions-dep

Conversation

@straightchlorine
Copy link
Copy Markdown

Problem

Pylette/src/extractors/k_means.py:3 and median_cut.py:3 both import from typing_extensions import override, unconditionally, but typing-extensions was never listed in [project.dependencies]. Present only through the dev tooling, so import doesn't fail on CI.

On a clean install:

File ".../Pylette/src/extractors/k_means.py", line 3, in <module>
    from typing_extensions import override
ModuleNotFoundError: No module named 'typing_extensions'

Reproduce (3.12)

$ uv venv --python 3.12 /tmp/pylette-repro
Using CPython 3.12.13
Creating virtual environment at: /tmp/pylette-repro
Activate with: source /tmp/pylette-repro/bin/activate
$ uv pip list
Using Python 3.12.13 environment at: /tmp/pylette-repro
$ uv pip install pylette==5.1.2
Using Python 3.12.13 environment at: /tmp/pylette-repro
Resolved 20 packages in 293ms
░░░░░░░░░░░░░░░░░░░░ [0/20] Installing wheels...                                                                                                                                               warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance.
         If the cache and target directories are on different filesystems, hardlinking may not be supported.
         If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning.
Installed 20 packages in 81ms
 + annotated-doc==0.0.4
 + certifi==2026.5.20
 + charset-normalizer==3.4.7
 + idna==3.17
 + joblib==1.5.3
 + markdown-it-py==4.2.0
 + mdurl==0.1.2
 + numpy==2.4.6
 + opencv-python==4.13.0.92
 + pillow==12.2.0
 + pygments==2.20.0
 + pylette==5.1.2
 + requests==2.34.2
 + rich==15.0.0
 + scikit-learn==1.8.0
 + scipy==1.17.1
 + shellingham==1.5.4
 + threadpoolctl==3.6.0
 + typer==0.26.3
 + urllib3==2.7.0
$ uv run python -c "import Pylette"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pylette-repro/lib/python3.12/site-packages/Pylette/__init__.py", line 3, in <module>
    from Pylette.src.color_extraction import batch_extract_colors, extract_colors
  File "/tmp/pylette-repro/lib/python3.12/site-packages/Pylette/src/color_extraction.py", line 12, in <module>
    from Pylette.src.extractors.k_means import k_means_extraction
  File "/tmp/pylette-repro/lib/python3.12/site-packages/Pylette/src/extractors/k_means.py", line 3, in <module>
    from typing_extensions import override
ModuleNotFoundError: No module named 'typing_extensions'
$ uv pip list
Using Python 3.12.13 environment at: /tmp/pylette-repro
Package            Version
------------------ ---------
annotated-doc      0.0.4
certifi            2026.5.20
charset-normalizer 3.4.7
idna               3.17
joblib             1.5.3
markdown-it-py     4.2.0
mdurl              0.1.2
numpy              2.4.6
opencv-python      4.13.0.92
pillow             12.2.0
pygments           2.20.0
pylette            5.1.2
requests           2.34.2
rich               15.0.0
scikit-learn       1.8.0
scipy              1.17.1
shellingham        1.5.4
threadpoolctl      3.6.0
typer              0.26.3
urllib3            2.7.0

Both the installation and final uv pip list confirm that package is absent.

Fix

Declaring it unconditionally fixes the issue. Confirmed with typing-extensions==4.14.1 and typing-extensions==4.15.0.

Alternative: guard the import

Versions 3.12+ have typing.override in stdlib, while carrying no runtime dep. To take advantage:

  • Guard the import in both situations:
import sys
if sys.version_info >= (3, 12):
    from typing import override
else:
    from typing_extensions import override
  • Mark the dependency, so it installs only when needed:
    typing-extensions>=4.4.0; python_version < '3.12'

The k-means and median-cut extractors import `override` unconditionally
(Pylette/src/extractors/k_means.py:3, median_cut.py:3), but
typing-extensions itself was never listed in [project.dependencies].

It was present through the dev tooling - on a clean install it breaks:

  ModuleNotFoundError: No module named 'typing_extensions'

Adding typing-extensions>=4.4.0 and regenerating uv.lock fixes issue.
Verified with `uv run pytest` and `python smoke_test.py`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant