Skip to content

Commit eef3819

Browse files
committed
Add pyright to pre-commit config
Also configure reorder-python-imports to add annotations import everywhere.
1 parent 8b87237 commit eef3819

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ repos:
1717
- id: reorder-python-imports
1818
args:
1919
- --py38-plus
20+
- --add-import
21+
- from __future__ import annotations
2022

2123
- repo: https://github.com/charliermarsh/ruff-pre-commit
2224
rev: v0.0.269
@@ -46,3 +48,8 @@ repos:
4648
rev: v0.13
4749
hooks:
4850
- id: validate-pyproject
51+
52+
- repo: https://github.com/fsouza/mirrors-pyright
53+
rev: v1.1.310
54+
hooks:
55+
- id: pyright

test_autoflake.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env python
22
"""Test suite for autoflake."""
3+
from __future__ import annotations
4+
35
import contextlib
46
import functools
57
import io

test_fuzz.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
done by doing a syntax check after the autoflake run. The number of
66
Pyflakes warnings is also confirmed to always improve.
77
"""
8+
from __future__ import annotations
9+
810
import argparse
911
import os
1012
import shlex

test_fuzz_pypi.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#!/usr/bin/env python
22
"""Fuzz test against the latest packages on PyPI."""
3+
from __future__ import annotations
4+
35
import os
46
import subprocess
57
import sys
68
import tarfile
79
import zipfile
10+
from typing import Iterable
811

912
import test_fuzz
1013

@@ -15,7 +18,7 @@
1518
)
1619

1720

18-
def latest_packages(last_hours):
21+
def latest_packages(last_hours: int) -> Iterable[str]:
1922
"""Return names of latest released packages on PyPI."""
2023
process = subprocess.Popen(
2124
["yolk", f"--latest-releases={last_hours}"],
@@ -27,7 +30,7 @@ def latest_packages(last_hours):
2730
yield line.split()[0]
2831

2932

30-
def download_package(name, output_directory):
33+
def download_package(name: str, output_directory: str) -> None:
3134
"""Download package to output_directory.
3235
3336
Raise CalledProcessError on failure.
@@ -38,7 +41,7 @@ def download_package(name, output_directory):
3841
)
3942

4043

41-
def extract_package(path, output_directory):
44+
def extract_package(path: str, output_directory: str) -> bool:
4245
"""Extract package at path."""
4346
if path.lower().endswith(".tar.gz"):
4447
try:
@@ -60,7 +63,7 @@ def extract_package(path, output_directory):
6063
return False
6164

6265

63-
def main():
66+
def main() -> int:
6467
"""Run main."""
6568
try:
6669
os.mkdir(TMP_DIR)
@@ -138,6 +141,8 @@ def main():
138141
file=sys.stderr,
139142
)
140143

144+
return 0
145+
141146

142147
if __name__ == "__main__":
143148
try:

0 commit comments

Comments
 (0)