mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-05 04:13:05 +03:00
Fix types/handling, simplify catch-all return
This commit is contained in:
parent
e106e502bb
commit
fa04172830
|
@ -138,13 +138,11 @@ def info_installed_model_url(model: str) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
dist = importlib_metadata.distribution(model)
|
dist = importlib_metadata.distribution(model)
|
||||||
data = json.loads(dist.read_text("direct_url.json"))
|
text = dist.read_text("direct_url.json")
|
||||||
return data["url"]
|
if isinstance(text, str):
|
||||||
except importlib_metadata.PackageNotFoundError:
|
data = json.loads(text)
|
||||||
# no such package
|
return data["url"]
|
||||||
return None
|
finally:
|
||||||
except Exception:
|
|
||||||
# something else, like no file or invalid JSON
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user