Skip to content

Commit

Permalink
don't crash when the package version is unknown
Browse files Browse the repository at this point in the history
when running the module directly from command line
without a python package, importlib doesn't know
the package version and this causes freetar to crash.

this commit assumes "development" as the version
if a version is not available, instead of crashing
  • Loading branch information
dexterlb authored and kmille committed Nov 22, 2024
1 parent 0f41dd5 commit 9239f34
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion freetar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@


def get_version():
return importlib.metadata.version(__package__)
try:
return importlib.metadata.version(__package__)
except importlib.metadata.PackageNotFoundError:
return 'development'


class FreetarError(Exception):
Expand Down

0 comments on commit 9239f34

Please sign in to comment.