mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-07 20:54:29 +08:00
Add test to import all modules to check validity of stubs (#56)
* add import_all.test builder * fix errors * fix typechecking errors * fix migrations typechecking
This commit is contained in:
29
scripts/build_import_all_test.py
Normal file
29
scripts/build_import_all_test.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
|
||||
STUBS_ROOT = Path(__file__).parent.parent / 'django-stubs'
|
||||
|
||||
|
||||
def build_package_name(path: str) -> str:
|
||||
return '.'.join(['django'] + list(Path(path).relative_to(STUBS_ROOT).with_suffix('').parts))
|
||||
|
||||
|
||||
packages: List[str] = []
|
||||
for dirpath, dirnames, filenames in os.walk(STUBS_ROOT):
|
||||
if not dirnames:
|
||||
package = build_package_name(dirpath)
|
||||
packages.append(package)
|
||||
|
||||
for filename in filenames:
|
||||
if filename != '__init__.pyi':
|
||||
package = build_package_name(os.path.join(dirpath, filename))
|
||||
packages.append(package)
|
||||
|
||||
test_lines: List[str] = []
|
||||
for package in packages:
|
||||
test_lines.append('import ' + package)
|
||||
|
||||
test_contents = '\n'.join(test_lines)
|
||||
print(test_contents)
|
||||
Reference in New Issue
Block a user