Closed qarkai closed 1 week ago
Since type annotations are only used by mypy, maybe we should make these statements conditional on typing.TYPE_CHECKING
as well? In any case, I think an explicit if
statement (e.g. on the running Python version) would be preferable over catching an ImportError
.
(Disclaimer: I'm not a maintainer, I'm just providing some feedback.)
Ruff outputs runtime-import-in-type-checking-block (TCH004) warning if from typing_extensions import
is in type-checking block. Not sure why.
I suspect Ruff special-cases imports in type-checking blocks, only allowing things from modules it knows about. It definitely looks like they support some imports in type-checking blocks: it's mentioned here for example.
Hi! Thanks for the PR. What is the benefit of doing this rather than what we already have? Python 3.8 is currently our minimum supported version.
Hi! Thanks for the PR. What is the benefit of doing this rather than what we already have? Python 3.8 is currently our minimum supported version.
Use built-in module in modern Python. Reduce dependencies, make life easier for downstream maintainers. Simplify upgrading to newer Python versions in the future, i.e. when minimum supported version is Python 3.11 typing_extensions could be removed completely.
Those benefits would only happen when we have Python 3.10 as the minimally supported version version though, wouldn't it? There'd be no difference until we reach that point, since it will still be on the dependency list regardless.
Nope, if distro has Python >= 3.11 maintainer would be able to drop typing_extensions
dependency for the next beets release with this patch even if the minimal supported version is still 3.8.
It's in typing_extensions = { version = "*", python = "<=3.10" }
line.
Description
Use
typing_extensions
only for Python <= 3.10.Self
was added in Python 3.11.TypeAlias
was added in Python 3.10.To Do