mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
stubsabot: Skip over empty __init__.py files when determining if all Python files are covered by py.typed markers (#11634)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
@@ -177,10 +177,31 @@ def all_py_files_in_source_are_in_py_typed_dirs(source: zipfile.ZipFile | tarfil
|
||||
all_python_files: list[Path] = []
|
||||
py_file_suffixes = {".py", ".pyi"}
|
||||
|
||||
# Obtain an iterator over all files in the zipfile/tarfile.
|
||||
# Filter out empty __init__.py files: this reduces false negatives
|
||||
# in cases like this:
|
||||
#
|
||||
# repo_root/
|
||||
# ├─ src/
|
||||
# | ├─ pkg/
|
||||
# | | ├─ __init__.py <-- This file is empty
|
||||
# | | ├─ subpkg/
|
||||
# | | | ├─ __init__.py
|
||||
# | | | ├─ libraryfile.py
|
||||
# | | | ├─ libraryfile2.py
|
||||
# | | | ├─ py.typed
|
||||
if isinstance(source, zipfile.ZipFile):
|
||||
path_iter = (Path(zip_info.filename) for zip_info in source.infolist() if not zip_info.is_dir())
|
||||
path_iter = (
|
||||
Path(zip_info.filename)
|
||||
for zip_info in source.infolist()
|
||||
if ((not zip_info.is_dir()) and not (Path(zip_info.filename).name == "__init__.py" and zip_info.file_size == 0))
|
||||
)
|
||||
else:
|
||||
path_iter = (Path(tar_info.path) for tar_info in source if tar_info.isfile())
|
||||
path_iter = (
|
||||
Path(tar_info.path)
|
||||
for tar_info in source
|
||||
if (tar_info.isfile() and not (Path(tar_info.name).name == "__init__.py" and tar_info.size == 0))
|
||||
)
|
||||
|
||||
for path in path_iter:
|
||||
if path.suffix in py_file_suffixes:
|
||||
|
||||
Reference in New Issue
Block a user