Skip to content

Commit

Permalink
refactor: Use importlib.metadata instead of pkg_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Oct 10, 2023
1 parent 64bb761 commit e259a40
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/aria2p/utils.py
Expand Up @@ -7,11 +7,10 @@

import signal
import textwrap
from importlib import metadata
from pathlib import Path
from typing import TYPE_CHECKING, Any

import pkg_resources
import toml
from appdirs import user_config_dir
from loguru import logger

Expand Down Expand Up @@ -167,10 +166,9 @@ def get_version() -> str:
The current `aria2p` version.
"""
try:
distribution = pkg_resources.get_distribution("aria2p")
except pkg_resources.DistributionNotFound:
return metadata.version("aria2p")
except metadata.PackageNotFoundError:
return "0.0.0"
return distribution.version


def load_configuration() -> dict[str, Any]:
Expand Down

0 comments on commit e259a40

Please sign in to comment.