mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-21 11:21:19 +08:00
Use Ruff for from __future__ import annotations checks (#10910)
This commit is contained in:
9
.github/workflows/tests.yml
vendored
9
.github/workflows/tests.yml
vendored
@@ -45,6 +45,15 @@ jobs:
|
||||
python-version: "3.11"
|
||||
- run: ./tests/check_new_syntax.py
|
||||
|
||||
ruff:
|
||||
name: Lint with Ruff
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: chartboost/ruff-action@v1
|
||||
with:
|
||||
version: "0.1.0" # must match .pre-commit-config.yaml and requirements-test.txt
|
||||
|
||||
flake8:
|
||||
name: Lint with Flake8
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -20,10 +20,10 @@ repos:
|
||||
- id: isort
|
||||
name: isort (python)
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.1.0 # must match requirements-tests.txt
|
||||
rev: v0.1.0 # must match requirements-tests.txt and tests.yml
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: [--exit-non-zero-on-fix]
|
||||
args: [--exit-non-zero-on-fix, --fix-only]
|
||||
- repo: https://github.com/pycqa/flake8
|
||||
rev: 6.1.0 # must match requirements-tests.txt
|
||||
hooks:
|
||||
|
||||
@@ -60,15 +60,17 @@ known_first_party = ["parse_metadata", "utils"]
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 130
|
||||
# Oldest supported Python version
|
||||
target-version = "py37"
|
||||
fix = true
|
||||
exclude = [
|
||||
# We're only interested in autofixes for our stubs
|
||||
"*.py",
|
||||
# Ignore generated protobuf stubs
|
||||
"*_pb2.pyi",
|
||||
# virtual environment, cache directories, etc.:
|
||||
# virtual environment
|
||||
".env",
|
||||
".venv",
|
||||
"env",
|
||||
# cache directories, etc.:
|
||||
".git",
|
||||
".mypy_cache",
|
||||
".pytype",
|
||||
@@ -80,6 +82,7 @@ exclude = [
|
||||
# only enable rules that are relevant to stubs
|
||||
select = [
|
||||
"F401", # Remove unused imports
|
||||
"FA", # flake8-future-annotations
|
||||
"PYI009", # use `...`, not `pass`, in empty class bodies
|
||||
"PYI010", # function bodies must be empty
|
||||
"PYI012", # class bodies must not contain `pass`
|
||||
|
||||
@@ -10,7 +10,7 @@ isort==5.12.0 # must match .pre-commit-config.yaml
|
||||
mypy==1.6.1
|
||||
pre-commit-hooks==4.5.0 # must match .pre-commit-config.yaml
|
||||
pytype==2023.10.17; platform_system != "Windows" and python_version < "3.12"
|
||||
ruff==0.1.0 # must match .pre-commit-config.yaml
|
||||
ruff==0.1.0 # must match .pre-commit-config.yaml and tests.yml
|
||||
|
||||
# Libraries used by our various scripts.
|
||||
aiohttp==3.8.5; python_version < "3.12" # aiohttp can't be installed on 3.12 yet
|
||||
|
||||
@@ -83,9 +83,6 @@ def check_test_cases() -> None:
|
||||
bad_test_case_filename = 'Files in a `test_cases` directory must have names starting with "check_"; got "{}"'
|
||||
for file in testcase_dir.rglob("*.py"):
|
||||
assert file.stem.startswith("check_"), bad_test_case_filename.format(file)
|
||||
with open(file, encoding="UTF-8") as f:
|
||||
lines = {line.strip() for line in f}
|
||||
assert "from __future__ import annotations" in lines, "Test-case files should use modern typing syntax where possible"
|
||||
|
||||
|
||||
def check_no_symlinks() -> None:
|
||||
|
||||
Reference in New Issue
Block a user