Cleanup: quiet warnings from mypy & ruff

This commit is contained in:
Campbell Barton
2024-06-01 22:27:05 +10:00
parent e686d1b38a
commit 42c4678707
2 changed files with 7 additions and 6 deletions

View File

@@ -634,8 +634,10 @@ def pkg_manifest_archive_url_abs_from_remote_url(remote_url: str, archive_url: s
def pkg_is_legacy_addon(filepath: str) -> bool:
from .cli.blender_ext import pkg_is_legacy_addon
return pkg_is_legacy_addon(filepath)
from .cli.blender_ext import pkg_is_legacy_addon as pkg_is_legacy_addon_extern
result = pkg_is_legacy_addon_extern(filepath)
assert isinstance(result, bool)
return result
def pkg_repo_cache_clear(local_dir: str) -> None:

View File

@@ -667,7 +667,7 @@ def pkg_is_legacy_addon(filepath: str) -> bool:
try:
zip_fh_context = zipfile.ZipFile(filepath, mode="r")
except BaseException as ex:
except Exception:
return False
with contextlib.closing(zip_fh_context) as zip_fh:
@@ -675,8 +675,7 @@ def pkg_is_legacy_addon(filepath: str) -> bool:
if pkg_zipfile_detect_subdir_or_none(zip_fh) is not None:
return False
# If any python file contains bl_info it's legacy.
base_dir = None
# If any Python file contains bl_info it's legacy.
for filename in zip_fh_context.NameToInfo.keys():
if filename.startswith("."):
continue
@@ -684,7 +683,7 @@ def pkg_is_legacy_addon(filepath: str) -> bool:
continue
try:
file_content = zip_fh.read(filename)
except:
except Exception:
file_content = None
if file_content and file_content.find(b"bl_info"):
return True