Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pydeequ/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
"""Placeholder docstrings"""
__version__ = "1.2.0"
from importlib.metadata import version

__version__ = version("pydeequ")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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() raises importlib.metadata.PackageNotFoundError (a subclass of ModuleNotFoundError) when the distribution is not found. A developer cloning the repo and running python -c 'import pydeequ' without installing the package will get an unhandled exception at import time.


from pyspark.sql import SparkSession

Expand Down
8 changes: 8 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from importlib.metadata import version

import pydeequ


def test_package_version_is_exposed():
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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__.py line 17: __version__ = version("pydeequ"). In tests/test_version.py line 7-8: assert pydeequ.__version__ == version("pydeequ"). Both sides call the same function with the same argument, so the assertion is x == x.

assert pydeequ.__version__ == version("pydeequ")
Loading