Skip to content

Commit

Permalink
Fix pyright warning in useragent
Browse files Browse the repository at this point in the history
  • Loading branch information
mattt committed Sep 16, 2024
1 parent 883eb97 commit 5e81238
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions python/cog/server/useragent.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import sys


def _get_version() -> str:
try:
try:
from importlib.metadata import ( # pylint: disable=import-outside-toplevel
version,
if sys.version_info >= (3, 8):
from importlib.metadata import (
version, # pylint: disable=import-outside-toplevel
)
except ImportError:
pass
else:

return version("cog")
import pkg_resources # pylint: disable=import-outside-toplevel
else:
import pkg_resources # pylint: disable=import-outside-toplevel

return pkg_resources.get_distribution("cog").version
return pkg_resources.get_distribution("cog").version
except Exception: # pylint: disable=broad-exception-caught
return "unknown"

Expand Down

0 comments on commit 5e81238

Please sign in to comment.