From ad96829bfa8fd4879fccf8b0275efbf466145656 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sat, 5 Oct 2024 14:37:27 +0100 Subject: [PATCH] Remove linters from requirements-tests.txt (#12725) --- .pre-commit-config.yaml | 10 +++++----- requirements-tests.txt | 13 ++++--------- scripts/create_baseline_stubs.py | 5 +++-- tests/check_typeshed_structure.py | 2 +- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 43686f51d..c6a810b02 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 # must match requirements-tests.txt + rev: v4.6.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -27,16 +27,16 @@ repos: - "--unsafe-fixes" files: '.*test_cases/.+\.py$' - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.8.0 # must match requirements-tests.txt + rev: 24.8.0 hooks: - id: black - repo: https://github.com/pycqa/flake8 - rev: 7.1.1 # must match requirements-tests.txt + rev: 7.1.1 hooks: - id: flake8 additional_dependencies: - - "flake8-noqa==1.4.0" # must match requirements-tests.txt - - "flake8-pyi==24.6.0" # must match requirements-tests.txt + - "flake8-noqa==1.4.0" + - "flake8-pyi==24.6.0" types: [file] types_or: [python, pyi] - repo: meta diff --git a/requirements-tests.txt b/requirements-tests.txt index 2f4d236e7..8e0d7d9ae 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -1,16 +1,9 @@ -# Type checkers and other linters that we test our stubs against. These should always -# be pinned to a specific version to make failure reproducible. See also the -# "tool.typeshed" section in pyproject.toml for additional type checkers. -black==24.8.0 # must match .pre-commit-config.yaml -flake8==7.1.1 # must match .pre-commit-config.yaml -flake8-noqa==1.4.0 # must match .pre-commit-config.yaml -flake8-pyi==24.6.0 # must match .pre-commit-config.yaml +# Type checkers that we test our stubs against. These should always +# be pinned to a specific version to make failure reproducible. mypy==1.11.2 -pre-commit-hooks==4.6.0 # must match .pre-commit-config.yaml pyright==1.1.383 # pytype can be installed on Windows, but requires building wheels, let's not do that on the CI pytype==2024.9.13; platform_system != "Windows" and python_version < "3.13" -ruff==0.6.8 # must match .pre-commit-config.yaml # Libraries used by our various scripts. aiohttp==3.10.8 @@ -21,6 +14,8 @@ mypy-protobuf==3.6.0 packaging==24.1 pathspec>=0.11.1 pre-commit +# Required by create_baseline_stubs.py. Must match .pre-commit-config.yaml. +ruff==0.6.8 stubdefaulter==0.1.0 termcolor>=2.3 tomli==2.0.1 diff --git a/scripts/create_baseline_stubs.py b/scripts/create_baseline_stubs.py index 69b04a056..69f5d2b30 100755 --- a/scripts/create_baseline_stubs.py +++ b/scripts/create_baseline_stubs.py @@ -12,7 +12,8 @@ from __future__ import annotations import argparse import asyncio -import os +import glob +import os.path import re import subprocess import sys @@ -60,7 +61,7 @@ def run_stubdefaulter(stub_dir: str) -> None: def run_black(stub_dir: str) -> None: print(f"Running Black: black {stub_dir}") - subprocess.run(["black", stub_dir]) + subprocess.run(["pre-commit", "run", "black", "--files", *glob.iglob(f"{stub_dir}/**/*.pyi")]) def run_ruff(stub_dir: str) -> None: diff --git a/tests/check_typeshed_structure.py b/tests/check_typeshed_structure.py index eea636680..88db8d669 100755 --- a/tests/check_typeshed_structure.py +++ b/tests/check_typeshed_structure.py @@ -30,7 +30,7 @@ extension_descriptions = {".pyi": "stub", ".py": ".py"} # These type checkers and linters must have exact versions in the requirements file to ensure # consistent CI runs. -linters = {"black", "flake8", "flake8-noqa", "flake8-pyi", "mypy", "pyright", "pytype", "ruff"} +linters = {"mypy", "pyright", "pytype", "ruff"} def assert_consistent_filetypes(