Use package metadata for pydeequ version#267
Conversation
| __version__ = "1.2.0" | ||
| from importlib.metadata import version | ||
|
|
||
| __version__ = version("pydeequ") |
There was a problem hiding this comment.
EDGE_CASE: importlib.metadata.version("pydeequ") will raise PackageNotFoundError if the package is not installed in the environment (e.g., running from source checkout without pip install -e .). This makes the module completely unimportable in that scenario, whereas the previous hardcoded string always worked. Consider wrapping in a try/except to fall back gracefully.
Line 17:
__version__ = version("pydeequ")—importlib.metadata.version()raisesimportlib.metadata.PackageNotFoundError(a subclass ofModuleNotFoundError) when the distribution is not found. A developer cloning the repo and runningpython -c 'import pydeequ'without installing the package will get an unhandled exception at import time.
| import pydeequ | ||
|
|
||
|
|
||
| def test_package_version_is_exposed(): |
There was a problem hiding this comment.
DESIGN: The test is tautological — pydeequ.__version__ is defined as version("pydeequ") and the test asserts it equals version("pydeequ"). It can never fail unless the import itself fails. It doesn't guard against regressions (e.g., someone re-hardcoding the version). A more useful test would verify the version string matches a semver pattern or matches pyproject.toml.
In
pydeequ/__init__.pyline 17:__version__ = version("pydeequ"). Intests/test_version.pyline 7-8:assert pydeequ.__version__ == version("pydeequ"). Both sides call the same function with the same argument, so the assertion isx == x.
Issue #, if available:
Closes #239
Description of changes:
pydeequ.__version__from installed package metadata instead of a stale hardcoded stringpydeequ.__version__withimportlib.metadata.version(pydeequ)Validation:
git diff --check HEAD~1..HEADpydeequ/__init__.pyandtests/test_version.pyBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.