mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-07-20 07:00:29 +08:00
Enable Ruff PLW (Pylint Warning) (#13749)
This commit is contained in:
+2
-2
@@ -277,7 +277,7 @@ def run_mypy(
|
||||
mypy_command = [python_path, "-m", "mypy", *mypy_args]
|
||||
if args.verbose:
|
||||
print(colored(f"running {' '.join(mypy_command)}", "blue"))
|
||||
result = subprocess.run(mypy_command, capture_output=True, text=True, env=env_vars)
|
||||
result = subprocess.run(mypy_command, capture_output=True, text=True, env=env_vars, check=False)
|
||||
if result.returncode:
|
||||
print_error(f"failure (exit code {result.returncode})\n")
|
||||
if result.stdout:
|
||||
@@ -286,7 +286,7 @@ def run_mypy(
|
||||
print_error(result.stderr)
|
||||
if non_types_dependencies and args.verbose:
|
||||
print("Ran with the following environment:")
|
||||
subprocess.run(["uv", "pip", "freeze"], env={**os.environ, "VIRTUAL_ENV": str(venv_dir)})
|
||||
subprocess.run(["uv", "pip", "freeze"], env={**os.environ, "VIRTUAL_ENV": str(venv_dir)}, check=False)
|
||||
print()
|
||||
else:
|
||||
print_success_msg()
|
||||
|
||||
@@ -24,7 +24,7 @@ def main() -> None:
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
subprocess.run([npx, "--version"])
|
||||
subprocess.run([npx, "--version"], check=False)
|
||||
except OSError:
|
||||
print("error running npx; is Node.js installed?", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
@@ -40,7 +40,7 @@ def main() -> None:
|
||||
command = [npx, f"pyright@{pyright_version}"] + sys.argv[1:]
|
||||
print_command(command)
|
||||
|
||||
ret = subprocess.run(command).returncode
|
||||
ret = subprocess.run(command, check=False).returncode
|
||||
sys.exit(ret)
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -224,7 +224,7 @@ def run_testcases(
|
||||
msg += f"{description}: MYPYPATH not set"
|
||||
msg += "\n"
|
||||
verbose_log(msg)
|
||||
return subprocess.run(mypy_command, capture_output=True, text=True, env=env_vars)
|
||||
return subprocess.run(mypy_command, capture_output=True, text=True, env=env_vars, check=False)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
||||
+9
-7
@@ -76,10 +76,10 @@ def main() -> None:
|
||||
pytype_result: subprocess.CompletedProcess[bytes] | None = None
|
||||
|
||||
print("\nRunning pre-commit...")
|
||||
pre_commit_result = subprocess.run(["pre-commit", "run", "--files", *Path(path).rglob("*")])
|
||||
pre_commit_result = subprocess.run(["pre-commit", "run", "--files", *Path(path).rglob("*")], check=False)
|
||||
|
||||
print("\nRunning check_typeshed_structure.py...")
|
||||
check_structure_result = subprocess.run([sys.executable, "tests/check_typeshed_structure.py"])
|
||||
check_structure_result = subprocess.run([sys.executable, "tests/check_typeshed_structure.py"], check=False)
|
||||
|
||||
strict_params = _get_strict_params(path)
|
||||
print(f"\nRunning Pyright ({'stricter' if strict_params else 'base' } configs) for Python {python_version}...")
|
||||
@@ -87,6 +87,7 @@ def main() -> None:
|
||||
[sys.executable, "tests/pyright_test.py", path, "--pythonversion", python_version, *strict_params],
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
if re.match(_NPX_ERROR_PATTERN, pyright_result.stderr):
|
||||
print(_NPX_ERROR_MESSAGE)
|
||||
@@ -98,16 +99,16 @@ def main() -> None:
|
||||
pyright_skipped = False
|
||||
|
||||
print(f"\nRunning mypy for Python {python_version}...")
|
||||
mypy_result = subprocess.run([sys.executable, "tests/mypy_test.py", path, "--python-version", python_version])
|
||||
mypy_result = subprocess.run([sys.executable, "tests/mypy_test.py", path, "--python-version", python_version], check=False)
|
||||
# If mypy failed, stubtest will fail without any helpful error
|
||||
if mypy_result.returncode == 0:
|
||||
if folder == "stdlib":
|
||||
print("\nRunning stubtest...")
|
||||
stubtest_result = subprocess.run([sys.executable, "tests/stubtest_stdlib.py", stub])
|
||||
stubtest_result = subprocess.run([sys.executable, "tests/stubtest_stdlib.py", stub], check=False)
|
||||
else:
|
||||
if run_stubtest:
|
||||
print("\nRunning stubtest...")
|
||||
stubtest_result = subprocess.run([sys.executable, "tests/stubtest_third_party.py", stub])
|
||||
stubtest_result = subprocess.run([sys.executable, "tests/stubtest_third_party.py", stub], check=False)
|
||||
else:
|
||||
print(
|
||||
colored(
|
||||
@@ -122,7 +123,7 @@ def main() -> None:
|
||||
|
||||
if find_spec("pytype"):
|
||||
print("\nRunning pytype...")
|
||||
pytype_result = subprocess.run([sys.executable, "tests/pytype_test.py", path])
|
||||
pytype_result = subprocess.run([sys.executable, "tests/pytype_test.py", path], check=False)
|
||||
else:
|
||||
print(
|
||||
colored(
|
||||
@@ -149,7 +150,7 @@ def main() -> None:
|
||||
"-p",
|
||||
_TESTCASES_CONFIG_FILE,
|
||||
]
|
||||
pyright_testcases_result = subprocess.run(command, stderr=subprocess.PIPE, text=True)
|
||||
pyright_testcases_result = subprocess.run(command, stderr=subprocess.PIPE, text=True, check=False)
|
||||
if re.match(_NPX_ERROR_PATTERN, pyright_testcases_result.stderr):
|
||||
print(_NPX_ERROR_MESSAGE)
|
||||
pyright_testcases_returncode = 0
|
||||
@@ -164,6 +165,7 @@ def main() -> None:
|
||||
[sys.executable, "tests/regr_test.py", "stdlib" if folder == "stdlib" else stub, "--python-version", python_version],
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
# No test means they all ran successfully (0 out of 0). Not all 3rd-party stubs have regression tests.
|
||||
if "No test cases found" in regr_test_result.stderr:
|
||||
|
||||
@@ -147,11 +147,11 @@ def run_stubtest(
|
||||
|
||||
print_divider()
|
||||
print("Python version: ", end="", flush=True)
|
||||
ret = subprocess.run([sys.executable, "-VV"], capture_output=True)
|
||||
ret = subprocess.run([sys.executable, "-VV"], capture_output=True, check=False)
|
||||
print_command_output(ret)
|
||||
|
||||
print("\nRan with the following environment:")
|
||||
ret = subprocess.run([pip_exe, "freeze", "--all"], capture_output=True)
|
||||
ret = subprocess.run([pip_exe, "freeze", "--all"], capture_output=True, check=False)
|
||||
print_command_output(ret)
|
||||
if keep_tmp_dir:
|
||||
print("Path to virtual environment:", venv_dir, flush=True)
|
||||
@@ -163,7 +163,7 @@ def run_stubtest(
|
||||
print()
|
||||
else:
|
||||
print(f"Re-running stubtest with --generate-allowlist.\nAdd the following to {main_allowlist_path}:")
|
||||
ret = subprocess.run([*stubtest_cmd, "--generate-allowlist"], env=stubtest_env, capture_output=True)
|
||||
ret = subprocess.run([*stubtest_cmd, "--generate-allowlist"], env=stubtest_env, capture_output=True, check=False)
|
||||
print_command_output(ret)
|
||||
|
||||
print_divider()
|
||||
|
||||
@@ -72,7 +72,7 @@ def run_mypy_as_subprocess(directory: str, platform: str, version: str) -> Retur
|
||||
"--custom-typeshed-dir",
|
||||
".",
|
||||
]
|
||||
result = subprocess.run(command, capture_output=True, text=True)
|
||||
result = subprocess.run(command, capture_output=True, text=True, check=False)
|
||||
if result.stderr:
|
||||
print_error(result.stderr)
|
||||
if result.stdout:
|
||||
|
||||
Reference in New Issue
Block a user