Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8c6c7ac
Script to run all checks locally
Avasam Sep 27, 2022
da2191e
missing return types
Avasam Sep 27, 2022
e3d293f
Apply suggestions from code review
Avasam Sep 27, 2022
9a0757c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 27, 2022
850d7fa
summary
Avasam Sep 27, 2022
9f92d0f
Merge branch 'run-all-checks-single-script' of https://github.com/Ava…
Avasam Sep 27, 2022
60f3f86
skip pyright if no npx
Avasam Sep 27, 2022
6b0544d
mypy type ignore
Avasam Sep 27, 2022
dc9d4eb
"Skipping" message
Avasam Sep 27, 2022
0241da0
mypy false positive
Avasam Sep 27, 2022
6ad47a3
rename
Avasam Sep 27, 2022
994173a
explicit CompletedProcess type because mypy
Avasam Sep 27, 2022
69c8bd8
Merge branch 'master' into run-all-checks-single-script
AlexWaygood Sep 28, 2022
36aaf68
mention in readme
Avasam Sep 28, 2022
80bc8c7
Apply suggestions from code review
Avasam Sep 28, 2022
430f855
Merge branch 'run-all-checks-single-script' of https://github.com/Ava…
Avasam Sep 28, 2022
169ad68
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 28, 2022
7aa69d3
annotations
Avasam Sep 28, 2022
901a4ad
Merge branch 'run-all-checks-single-script' of https://github.com/Ava…
Avasam Sep 28, 2022
f02191e
obsolete comment
Avasam Sep 28, 2022
31a3c10
PR comments
Avasam Sep 29, 2022
22b6cc9
Merge branch 'master' of https://github.com/python/typeshed into run-…
Avasam Sep 29, 2022
4ff0c8d
Merge branch 'master' of https://github.com/python/typeshed into run-…
Avasam Oct 1, 2022
77a3c9b
Set python version and better output
Avasam Oct 1, 2022
e8e1c43
Typed main
Avasam Oct 1, 2022
024e696
mention venv bug
Avasam Oct 2, 2022
3ceb0d3
output update
Avasam Oct 2, 2022
f9f3154
revert debug change
Avasam Oct 2, 2022
fad18bf
Update tests/README.md
Avasam Oct 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions scripts/create_baseline_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,10 @@ def main() -> None:

print("\nDone!\n\nSuggested next steps:")
print(f" 1. Manually review the generated stubs in {stub_dir}")
print(f' 2. Run "MYPYPATH={stub_dir} python3 -m mypy.stubtest {package}" to check the stubs against runtime')
print(f' 3. Run "mypy {stub_dir}" to check for errors')
print(f' 4. Run "black {stub_dir}" and "isort {stub_dir}" (if you\'ve made code changes)')
print(f' 5. Run "flake8 {stub_dir}" to check for e.g. unused imports')
print(" 6. Commit the changes on a new branch and create a typeshed PR")
print(" 2. See CONTRIBUTING.md for all the best practices and tips to improve your stub")
print(' 3. Run autofixes and tests locally using "python3 -m ./scripts/run_all_checks.py"')
print(" See tests/README.md to run individual tests")
print(" 4. Commit the changes on a new branch and create a typeshed PR (don't force-push!)")


if __name__ == "__main__":
Expand Down
63 changes: 63 additions & 0 deletions scripts/run_all_checks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import json
import re
import subprocess
import sys

# Popular Flake8 extensions not used in Typeshed that cause errors
_extend_ignore = "CCE,N8,Q"

_STRICTER_CONFIG_FILE = "pyrightconfig.stricter.json"


def _parse_jsonc(json_text: str) -> str:
parsed_json_text = re.sub(r"^\s*?//.*?\n", "", json_text, flags=re.RegexFlag.MULTILINE)
parsed_json_text = re.sub(r",([\n\s]*?[\}\]])", r"\1", parsed_json_text)
return parsed_json_text


def _get_strict_params(stub_path: str) -> list[str]:
with open(_STRICTER_CONFIG_FILE) as file:
data = json.loads(_parse_jsonc(file.read()))
if stub_path in data["exclude"]:
return []
return ["-p", _STRICTER_CONFIG_FILE]


if __name__ == "__main__":
try:
path = sys.argv[1]
except IndexError:
print("Missing path argument in format <folder>/<stub>")
sys.exit(1)
path_tokens = path.replace("\\", "/").split("/")
assert len(path_tokens) == 2, "Path argument should be in format <folder>/<stub>"
folder, stub = path_tokens
assert folder in {"stdlib", "stubs"}, "Only the 'stdlib' and 'stubs' folders are supported"

subprocess.run(["python3", "-m", "black", path])
subprocess.run(["python3", "-m", "isort", path])
subprocess.run(["python3", "-m", "flake8", path, "--extend-ignore", _extend_ignore])

subprocess.run(["python3", "tests/check_consistent.py"])
subprocess.run(["python3", "tests/check_new_syntax.py"])

subprocess.run(["python3", "tests/pyright_test.py", path] + _get_strict_params(path))

# FIXME: Fails to see requires
mypy_result = subprocess.run(["python3", "tests/mypy_test.py", path])

# TODO: Run in WSL if available
if sys.platform != "win32":
subprocess.run(["python3", "tests/pytype_test.py", path])

if folder == "stdlib":
subprocess.run(["python3", "tests/regr_test.py", "stdlib"])
else:
subprocess.run(["python3", "tests/regr_test.py", stub])

# If mypy failed, this will fail without any helpful error
if mypy_result.returncode == 0:
if folder == "stdlib":
subprocess.run(["python3", "tests/stubtest_stdlib.py", stub])
else:
subprocess.run(["python3", "tests/stubtest_third_party.py", stub])