Skip to content

Commit 1ccbc05

Browse files
authored
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.
1 parent 6966178 commit 1ccbc05

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
## 0.5.1-dev1
2+
3+
### Enhancements
4+
5+
### Features
6+
7+
### Fixes
8+
9+
* Fix several issues with the `requires_dependencies` decorator, including the error message
10+
and how it was used.
11+
112
## 0.5.0
213

314
### Enhancements
415

516
* Add `requires_dependencies` Python decorator to check dependencies are installed before
6-
instantiating a class or running a function
17+
instantiating a class or running a function
718

819
### Features
920

unstructured/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.5.0" # pragma: no cover
1+
__version__ = "0.5.1-dev1" # pragma: no cover

unstructured/ingest/connector/github.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def write_result(self):
125125
print(f"Wrote {output_filename}")
126126

127127

128-
@requires_dependencies(["pygithub"], extras="github")
128+
@requires_dependencies(["github"], extras="github")
129129
class GitHubConnector(BaseConnector):
130130
def __init__(self, config: SimpleGitHubConfig):
131131
from github import Github

unstructured/utils.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ def read_from_jsonl(filename: str) -> List[Dict]:
1414
return [json.loads(line) for line in input_file]
1515

1616

17-
def requires_dependencies(dependencies: Union[str, List[str]], extras: Optional[str] = None):
17+
def requires_dependencies(
18+
dependencies: Union[str, List[str]],
19+
extras: Optional[str] = None,
20+
):
1821
if isinstance(dependencies, str):
1922
dependencies = [dependencies]
2023

@@ -29,10 +32,12 @@ def wrapper(*args, **kwargs):
2932
missing_deps.append(dep)
3033
if len(missing_deps) > 0:
3134
raise ImportError(
32-
f"Following dependencies are missing: {', '.join(missing_deps)}."
33-
+ f"Please install them using `pip install unstructured[{extras}]`."
34-
if extras
35-
else f"Please install them using `pip install {' '.join(missing_deps)}`.",
35+
f"Following dependencies are missing: {', '.join(missing_deps)}. "
36+
+ (
37+
f"Please install them using `pip install unstructured[{extras}]`."
38+
if extras
39+
else f"Please install them using `pip install {' '.join(missing_deps)}`."
40+
),
3641
)
3742
return func(*args, **kwargs)
3843

0 commit comments

Comments
 (0)