mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
check_consistent.py: ignore .gitignored files (#8804)
This commit is contained in:
@@ -15,7 +15,7 @@ import yaml
|
||||
from packaging.requirements import Requirement
|
||||
from packaging.specifiers import SpecifierSet
|
||||
from packaging.version import Version
|
||||
from utils import VERSIONS_RE, get_all_testcase_directories, strip_comments
|
||||
from utils import VERSIONS_RE, get_all_testcase_directories, get_gitignore_spec, spec_matches_path, strip_comments
|
||||
|
||||
metadata_keys = {"version", "requires", "extra_description", "obsolete_since", "no_longer_updated", "tool"}
|
||||
tool_keys = {"stubtest": {"skip", "apt_dependencies", "extras", "ignore_missing_stub"}}
|
||||
@@ -26,8 +26,11 @@ def assert_consistent_filetypes(directory: Path, *, kind: str, allowed: set[str]
|
||||
"""Check that given directory contains only valid Python files of a certain kind."""
|
||||
allowed_paths = {Path(f) for f in allowed}
|
||||
contents = list(directory.iterdir())
|
||||
gitignore_spec = get_gitignore_spec()
|
||||
while contents:
|
||||
entry = contents.pop()
|
||||
if spec_matches_path(gitignore_spec, entry):
|
||||
continue
|
||||
if entry.relative_to(directory) in allowed_paths:
|
||||
# Note if a subdirectory is allowed, we will not check its contents
|
||||
continue
|
||||
@@ -45,7 +48,10 @@ def check_stdlib() -> None:
|
||||
|
||||
|
||||
def check_stubs() -> None:
|
||||
gitignore_spec = get_gitignore_spec()
|
||||
for dist in Path("stubs").iterdir():
|
||||
if spec_matches_path(gitignore_spec, dist):
|
||||
continue
|
||||
assert dist.is_dir(), f"Only directories allowed in stubs, got {dist}"
|
||||
|
||||
valid_dist_name = "^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$" # courtesy of PEP 426
|
||||
|
||||
Reference in New Issue
Block a user