diff options
| author | 2024-01-17 16:46:51 +0800 | |
|---|---|---|
| committer | 2024-01-17 16:46:51 +0800 | |
| commit | 5ad6f36c39d14c99c6d9f8f0d7db6653bd7d6e76 (patch) | |
| tree | 531890b68482366fe23ab533f68a9f4372e361ec | |
| parent | f9527f433eb2c1dba8c527098efb085688df8a0f (diff) | |
| download | ipm-5ad6f36c39d14c99c6d9f8f0d7db6653bd7d6e76.tar.gz ipm-5ad6f36c39d14c99c6d9f8f0d7db6653bd7d6e76.zip | |
refactor(api): Remove unnecessary else after guard condition (remove-unnecessary-else)
| -rw-r--r-- | src/ipm/api.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/ipm/api.py b/src/ipm/api.py index 3f2f847..faf7e0b 100644 --- a/src/ipm/api.py +++ b/src/ipm/api.py @@ -30,11 +30,10 @@ def install(uri: str, index: str = "", echo: bool = False) -> None: if os.path.isabs(uri): info(f"检定给定的 URI 地址[{uri}]为本地路径.", echo) - if uri.endswith(".ipk"): - info("安装中...", echo) - ipk = extract(Path(uri).resolve(), HOME, echo) - else: + if not uri.endswith(".ipk"): raise FileTypeMismatch("文件类型与预期[.ipk]不匹配.") + info("安装中...", echo) + ipk = extract(Path(uri).resolve(), HOME, echo) elif urlparser.is_valid_url(uri): filename = uri.rstrip("/").split("/")[-1] ipk = loader.load( |
