mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-14 07:47:09 +08:00
wip 1
This commit is contained in:
@@ -5,15 +5,10 @@ from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
from typing import Pattern
|
||||
|
||||
from git import Repo
|
||||
from mypy import build
|
||||
from mypy.main import process_options
|
||||
|
||||
# Django branch to typecheck against
|
||||
DJANGO_BRANCH = 'stable/2.1.x'
|
||||
|
||||
# Specific commit in the Django repository to check against
|
||||
DJANGO_COMMIT_SHA = '03219b5f709dcd5b0bfacd963508625557ec1ef0'
|
||||
from scripts.git_sources import PROJECT_DIRECTORY, REPO_DIRECTORY, update_django_sources_repo
|
||||
|
||||
# Some errors occur for the test suite itself, and cannot be addressed via django-stubs. They should be ignored
|
||||
# using this constant.
|
||||
@@ -159,25 +154,16 @@ def check_with_mypy(abs_path: Path, config_file_path: Path) -> int:
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
project_directory = Path(__file__).parent.parent
|
||||
mypy_config_file = (project_directory / 'scripts' / 'mypy.ini').absolute()
|
||||
repo_directory = project_directory / 'django-sources'
|
||||
tests_root = repo_directory / 'tests'
|
||||
mypy_tests_config_file = (PROJECT_DIRECTORY / 'scripts' / 'mypy.ini').absolute()
|
||||
tests_root = REPO_DIRECTORY / 'tests'
|
||||
global_rc = 0
|
||||
|
||||
# clone Django repository, if it does not exist
|
||||
if not repo_directory.exists():
|
||||
repo = Repo.clone_from('https://github.com/django/django.git', repo_directory)
|
||||
else:
|
||||
repo = Repo(repo_directory)
|
||||
repo.remotes['origin'].pull(DJANGO_BRANCH)
|
||||
|
||||
repo.git.checkout(DJANGO_COMMIT_SHA)
|
||||
update_django_sources_repo()
|
||||
for dirname in TESTS_DIRS:
|
||||
abs_path = (project_directory / tests_root / dirname).absolute()
|
||||
abs_path = (PROJECT_DIRECTORY / tests_root / dirname).absolute()
|
||||
print(f'Checking {abs_path.as_uri()}')
|
||||
|
||||
rc = check_with_mypy(abs_path, mypy_config_file)
|
||||
rc = check_with_mypy(abs_path, mypy_tests_config_file)
|
||||
if rc != 0:
|
||||
global_rc = 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user