Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
felixdittrich92 committed Apr 14, 2024
1 parent 0586a2e commit cebbaff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
19 changes: 7 additions & 12 deletions doctr/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# Adapted from https://github.com/huggingface/transformers/blob/master/src/transformers/file_utils.py

import importlib.metadata
import importlib.util
import logging
import os
Expand All @@ -14,8 +15,6 @@
CLASS_NAME: str = "words"


import importlib.metadata as importlib_metadata

__all__ = ["is_tf_available", "is_torch_available", "requires_package", "CLASS_NAME"]

ENV_VARS_TRUE_VALUES = {"1", "ON", "YES", "TRUE"}
Expand All @@ -29,9 +28,9 @@
_torch_available = importlib.util.find_spec("torch") is not None
if _torch_available:
try:
_torch_version = importlib_metadata.version("torch")
_torch_version = importlib.metadata.version("torch")
logging.info(f"PyTorch version {_torch_version} available.")
except importlib_metadata.PackageNotFoundError: # pragma: no cover
except importlib.metadata.PackageNotFoundError: # pragma: no cover
_torch_available = False
else: # pragma: no cover
logging.info("Disabling PyTorch because USE_TF is set")
Expand All @@ -56,9 +55,9 @@
# For the metadata, we have to look for both tensorflow and tensorflow-cpu
for pkg in candidates:
try:
_tf_version = importlib_metadata.version(pkg)
_tf_version = importlib.metadata.version(pkg)
break
except importlib_metadata.PackageNotFoundError:
except importlib.metadata.PackageNotFoundError:
pass
_tf_available = _tf_version is not None
if _tf_available:
Expand Down Expand Up @@ -87,14 +86,10 @@ def requires_package(name: str, extra_message: Optional[str] = None) -> None: #
----
name: name of the package
extra_message: additional message to display if the package is not found
Returns:
-------
bool: whether the package is available
"""
try:
_ = importlib_metadata.version(name)
except importlib_metadata.PackageNotFoundError:
_ = importlib.metadata.version(name)
except importlib.metadata.PackageNotFoundError:
raise ValueError(
textwrap.dedent(f"""
You need {name} to use this functionality. Please install it with the following command:
Expand Down
2 changes: 1 addition & 1 deletion doctr/io/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def show(self, interactive: bool = True, preserve_aspect_ratio: bool = False, **
preserve_aspect_ratio: pass True if you passed True to the predictor
**kwargs: additional keyword arguments passed to the matplotlib.pyplot.show method
"""
requires_package("matplotlib" "`.show()` requires matplotlib & mplcursors installed")
requires_package("matplotlib", "`.show()` requires matplotlib & mplcursors installed")
requires_package("mplcursors")
import matplotlib.pyplot as plt

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ classifiers=[
]
dynamic = ["version"]
dependencies = [
"importlib_metadata",
# For proper typing, mypy needs numpy>=1.20.0 (cf. https://github.com/numpy/numpy/pull/16515)
# Additional typing support is brought by numpy>=1.22.4, but core build sticks to >=1.16.0
"numpy>=1.16.0,<2.0.0",
Expand Down

0 comments on commit cebbaff

Please sign in to comment.