Skip to content

Conversation

@rohitrhmn1
Copy link

Fix missing typing_extensions dependency

This PR updates pyproject.toml and uv.lock to explicitly include typing_extensions as a dependency.

Changes

  • Added typing_extensions to project dependencies in pyproject.toml
  • Updated uv.lock to reflect the new dependency

Motivation

The typing_extensions package was being used in the codebase but not explicitly declared as a dependency, which could lead to import errors in certain environments where it's not already installed as a transitive dependency.

This ensures the package will work reliably across all Python versions and installation scenarios.

"Topic :: Software Development :: Libraries",
]
dependencies = [
"typing-extensions",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency is very often conditional (on python version), to make use of features that are backported from the typing module in the most recent python version. Is this the case for this project?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, in the latest versions of python-ulid, this package is imported somewhere and is not mentioned in the dependencies. Adding this in the package will solve the import issues.

For the sake of features that are backported, this project can mark minimum python version and use features for the recently available versions of python. Removing certain usages of this package inside the project will fix the problem.

@james-oldfield-inex
Copy link

To satisfy @merwok 's very reasonable request for this to be version dependent, we would need line 16 in __init__.py to be changed from:

from typing_extensions import Self

to:

import sys
if sys.version_info >= (3, 11):
    from typing import Self
else:
    from typing_extensions import Self

It seems that the only thing imported from typing_extensions is Self and that was added in Python 3.11.

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.

3 participants