Skip to content

Commit 433f053

Browse files
committed
Revert changes to pdl/__init__.py
Signed-off-by: Louis Mandel <[email protected]>
1 parent c5a34f8 commit 433f053

File tree

1 file changed

+4
-29
lines changed

1 file changed

+4
-29
lines changed

src/pdl/__init__.py

+4-29
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,6 @@
11
from importlib.metadata import PackageNotFoundError, version
22

3-
from ._version import __version__ as hardcoded_version
4-
5-
6-
def _get_distribution_version(distribution_name: str) -> str:
7-
"""
8-
This function attempts to retrieve the version of PDL package using
9-
importlib.metadata.
10-
11-
When the package is not installed, importlib will raise a PackageNotFoundError.
12-
In this case, we fallback to the hardcoded version.
13-
14-
When the package is installed, but the distribution name does not match,
15-
importlib will return the version of the package that is installed.
16-
"""
17-
try:
18-
return version(distribution_name)
19-
except PackageNotFoundError:
20-
# This is a fallback for when the package is not recognized by importlib.metadata.
21-
# This can happen when the package is not installed.
22-
return (
23-
hardcoded_version
24-
if distribution_name == "pdl"
25-
else _get_distribution_version(
26-
"pdl" # This is a fallback to maintain the previous behavior.
27-
)
28-
)
29-
30-
31-
__version__ = _get_distribution_version("prompt-declaration-language")
3+
try:
4+
__version__ = version("pdl")
5+
except PackageNotFoundError:
6+
pass

0 commit comments

Comments
 (0)