mirror of
https://github.com/explosion/spaCy.git
synced 2025-04-22 18:12:00 +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:
|
||||
dist = importlib_metadata.distribution(model)
|
||||
data = json.loads(dist.read_text("direct_url.json"))
|
||||
return data["url"]
|
||||
except importlib_metadata.PackageNotFoundError:
|
||||
# no such package
|
||||
return None
|
||||
except Exception:
|
||||
# something else, like no file or invalid JSON
|
||||
text = dist.read_text("direct_url.json")
|
||||
if isinstance(text, str):
|
||||
data = json.loads(text)
|
||||
return data["url"]
|
||||
finally:
|
||||
return None
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user