From f6a997de7dc50c60c2c5f6c242d14ffd18d8b6ec Mon Sep 17 00:00:00 2001 From: Justin Su Date: Sat, 1 Jun 2024 06:16:45 -0400 Subject: [PATCH] Add mypy to pre-commit config TODO: Switch back to PEP 695 type alias when supported by mypy (https://github.com/python/mypy/issues/15238) --- .pre-commit-config.yaml | 7 +++++++ main.py | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 61926ae..ccc3630 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,3 +10,10 @@ repos: - id: ruff args: [--fix] - id: ruff-format + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.10.0 + hooks: + - id: mypy + args: [--disable-error-code=import-untyped] + additional_dependencies: + [anyio, attrs, httpx, loguru, python-dateutil, tenacity] diff --git a/main.py b/main.py index 82eeea4..a715673 100644 --- a/main.py +++ b/main.py @@ -6,7 +6,7 @@ from asyncio import CancelledError from collections.abc import Callable, Iterable, Sequence from itertools import product -from typing import Literal, Self +from typing import Literal, Self, TypeAlias import httpx from anyio import create_task_group, run, sleep @@ -28,7 +28,8 @@ from flights import Availability from utils import beep, httpx_client, pretty_printer -type DiffLine = tuple[Literal[" ", "+", "-"], Availability] +# TODO: Switch back to PEP 695 type alias when supported by mypy (https://github.com/python/mypy/issues/15238) +DiffLine: TypeAlias = tuple[Literal[" ", "+", "-"], Availability] @frozen