Skip to content

Commit

Permalink
Add pyright to pre-commit config
Browse files Browse the repository at this point in the history
Also configure reorder-python-imports to add annotations import
everywhere.
  • Loading branch information
fsouza committed May 29, 2023
1 parent 8b87237 commit eef3819
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ repos:
- id: reorder-python-imports
args:
- --py38-plus
- --add-import
- from __future__ import annotations

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.269
Expand Down Expand Up @@ -46,3 +48,8 @@ repos:
rev: v0.13
hooks:
- id: validate-pyproject

- repo: https://github.com/fsouza/mirrors-pyright
rev: v1.1.310
hooks:
- id: pyright
2 changes: 2 additions & 0 deletions test_autoflake.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python
"""Test suite for autoflake."""
from __future__ import annotations

import contextlib
import functools
import io
Expand Down
2 changes: 2 additions & 0 deletions test_fuzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
done by doing a syntax check after the autoflake run. The number of
Pyflakes warnings is also confirmed to always improve.
"""
from __future__ import annotations

import argparse
import os
import shlex
Expand Down
13 changes: 9 additions & 4 deletions test_fuzz_pypi.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/usr/bin/env python
"""Fuzz test against the latest packages on PyPI."""
from __future__ import annotations

import os
import subprocess
import sys
import tarfile
import zipfile
from typing import Iterable

import test_fuzz

Expand All @@ -15,7 +18,7 @@
)


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


def download_package(name, output_directory):
def download_package(name: str, output_directory: str) -> None:
"""Download package to output_directory.
Raise CalledProcessError on failure.
Expand All @@ -38,7 +41,7 @@ def download_package(name, output_directory):
)


def extract_package(path, output_directory):
def extract_package(path: str, output_directory: str) -> bool:
"""Extract package at path."""
if path.lower().endswith(".tar.gz"):
try:
Expand All @@ -60,7 +63,7 @@ def extract_package(path, output_directory):
return False


def main():
def main() -> int:
"""Run main."""
try:
os.mkdir(TMP_DIR)
Expand Down Expand Up @@ -138,6 +141,8 @@ def main():
file=sys.stderr,
)

return 0


if __name__ == "__main__":
try:
Expand Down

0 comments on commit eef3819

Please sign in to comment.