-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make typing-extensions
a test only dependency
#248
Comments
I agree with that sentiment. Adding a runtime dependency that is never for anything at runtime, and used for one type annotation object, feels wrong. As dependencies go, |
If anyone uses the types downstream and typing-extensions is missing, this adds a hidden undeclared dependency. There's a pretty good chance something else depends on typing-extensions, but you technically are broken if a user don't have it. (Not sure this even has py.typed, but this is a bug I've seen for libraries). IMO, any backport dependency should be treated as a 0-cost dependency. If someone complains about it, they can upgrade their Python and it goes away. As long as 3.8, 3.10, or 3.11+ doesn't require the dep, I'd say it's totally fine to depend on it on older versions. Same is true for tomllib, exceptiongroup, or any other backport. The older versions eventually won't matter. This happened with dataclasses, and now code prevously using it got to drop the dep and now has code that looks like it was designed for 3.7+. Maybe it's even less than 0-cost. FYI, I usually have a module like https://github.com/scikit-build/scikit-build-core/blob/main/src/scikit_build_core/_compat/typing.py for types that can come from multiple places, and it would be pretty trivial for a small number of types to guard them with TYPE_CHECKING, so it could be done this way to ensure easy cleanup in the future if you really want to. |
We don't have a Python API, so how is this possible? |
That's what I meant by:
And that's why I also said it could be done if you really wanted too. |
I had a closer look: this was already a dependency, but now it's a much stronger one. EDIT: tl;dr this is certainly not a zero cost dependency There is zero usage of static typing downstream, plus extra dependencies have a small overhead at runtime (downloads, build time). So I think @dnicolodi's proposal is the right one - best to ensure we don't have this dependency at all except for meson-python development purposes. |
This argument is more compelling in projects like Meson where type annotations that are never used for anything at runtime are defined/imported in IMO it also has beneficial effects to annotate functions with
but 🤷 |
I have to say I do like this policy. I'd be +1 on adopting it in meson-python. |
Implemented in #255. |
In #231 I need to make use to of
typing
definitions added only in Python 3.10, thus makingtyping-extensions
a requirement for most of the supported Python version. It is quite annoying to have an extra dependency only for type checking. I think the dependency should be made a test only dependency.The text was updated successfully, but these errors were encountered: