mirror of
https://github.com/Unstructured-IO/unstructured.git
synced 2025-10-17 11:09:41 +00:00
Fix: Resolve several issues with the require dependencies decorator (#315)
Fix several issues re. the requires_dependencies decorator: * There was a missing space between the sentences. * Crucial brackets were missing in making the error message. * "pygithub" was used where "github" should have been used.
This commit is contained in:
parent
69661788cf
commit
1ccbc05b10
13
CHANGELOG.md
13
CHANGELOG.md
@ -1,9 +1,20 @@
|
||||
## 0.5.1-dev1
|
||||
|
||||
### Enhancements
|
||||
|
||||
### Features
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fix several issues with the `requires_dependencies` decorator, including the error message
|
||||
and how it was used.
|
||||
|
||||
## 0.5.0
|
||||
|
||||
### Enhancements
|
||||
|
||||
* Add `requires_dependencies` Python decorator to check dependencies are installed before
|
||||
instantiating a class or running a function
|
||||
instantiating a class or running a function
|
||||
|
||||
### Features
|
||||
|
||||
|
@ -1 +1 @@
|
||||
__version__ = "0.5.0" # pragma: no cover
|
||||
__version__ = "0.5.1-dev1" # pragma: no cover
|
||||
|
@ -125,7 +125,7 @@ class GitHubIngestDoc(BaseIngestDoc):
|
||||
print(f"Wrote {output_filename}")
|
||||
|
||||
|
||||
@requires_dependencies(["pygithub"], extras="github")
|
||||
@requires_dependencies(["github"], extras="github")
|
||||
class GitHubConnector(BaseConnector):
|
||||
def __init__(self, config: SimpleGitHubConfig):
|
||||
from github import Github
|
||||
|
@ -14,7 +14,10 @@ def read_from_jsonl(filename: str) -> List[Dict]:
|
||||
return [json.loads(line) for line in input_file]
|
||||
|
||||
|
||||
def requires_dependencies(dependencies: Union[str, List[str]], extras: Optional[str] = None):
|
||||
def requires_dependencies(
|
||||
dependencies: Union[str, List[str]],
|
||||
extras: Optional[str] = None,
|
||||
):
|
||||
if isinstance(dependencies, str):
|
||||
dependencies = [dependencies]
|
||||
|
||||
@ -29,10 +32,12 @@ def requires_dependencies(dependencies: Union[str, List[str]], extras: Optional[
|
||||
missing_deps.append(dep)
|
||||
if len(missing_deps) > 0:
|
||||
raise ImportError(
|
||||
f"Following dependencies are missing: {', '.join(missing_deps)}."
|
||||
+ f"Please install them using `pip install unstructured[{extras}]`."
|
||||
if extras
|
||||
else f"Please install them using `pip install {' '.join(missing_deps)}`.",
|
||||
f"Following dependencies are missing: {', '.join(missing_deps)}. "
|
||||
+ (
|
||||
f"Please install them using `pip install unstructured[{extras}]`."
|
||||
if extras
|
||||
else f"Please install them using `pip install {' '.join(missing_deps)}`."
|
||||
),
|
||||
)
|
||||
return func(*args, **kwargs)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user