You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importcontextlibfromimportlib.metadataimportPackageNotFoundErrorwithcontextlib.suppress(PackageNotFoundError):
from ._versionimport__version__, __version_tuple__
and try: ... catch ImportError: pass should work just as well?
I see, usually it is not recommended to import a package without installing it, but we can switch to try-except if that is a use-case. I believe contextlib was used to follow suggestions from ruff. No strong opinions on polluting the namespace, but usually it is okay to have such imports in __init__.py (and not include them in __all__).
To be fair, it's been a while since I used package.__version__ now that importlib.metadata.version() is available out of the box. Perhaps the import isn't even necessary?
Describe the Bug
These add noise to the
glass
namespace:and
try: ... catch ImportError: pass
should work just as well?To Reproduce
Expected Behaviour
Not have
contextlib
andPackageNotFoundError
in theglass
namespace.Actual Behaviour
Have
contextlib
andPackageNotFoundError
in theglass
namespace.Version In Use
2024.3
Additional Context
The text was updated successfully, but these errors were encountered: