Skip to content

Commit 9e81a6e

Browse files
committed
pre-commit: Add ty for Python type hints
1 parent 1bd049c commit 9e81a6e

287 files changed

Lines changed: 526 additions & 865 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# https://beta.ruff.rs
2-
name: ruff
2+
name: ruff_and_ty
33
on:
44
push:
55
branches:
@@ -8,9 +8,11 @@ on:
88
branches:
99
- master
1010
jobs:
11-
ruff:
11+
ruff_and_ty:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v7
1515
- uses: astral-sh/setup-uv@v7
16-
- run: uvx ruff check --output-format=github .
16+
- run: uvx ruff check --output-format=github
17+
- run: uv sync --group=test
18+
- run: uv run --with=ty ty check --output-format=github

.pre-commit-config.yaml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ci:
22
autoupdate_schedule: monthly
33
# uv-lock resolves dependencies from PyPI, but pre-commit.ci runs hooks with no
44
# network access, so it fails there. Skip it on pre-commit.ci; it still runs locally.
5-
skip: [uv-lock]
5+
skip: [ty, uv-lock]
66

77
repos:
88
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -28,16 +28,27 @@ repos:
2828
additional_dependencies:
2929
- tomli
3030

31+
- repo: https://github.com/tox-dev/pyproject-fmt
32+
rev: v2.29.3
33+
hooks:
34+
- id: pyproject-fmt
35+
3136
- repo: https://github.com/astral-sh/ruff-pre-commit
3237
rev: v0.16.5
3338
hooks:
3439
- id: ruff-check
3540
- id: ruff-format
3641

37-
- repo: https://github.com/tox-dev/pyproject-fmt
38-
rev: v2.28.1
42+
- repo: https://github.com/astral-sh/ty-pre-commit
43+
rev: v0.0.78
3944
hooks:
40-
- id: pyproject-fmt
45+
- id: ty
46+
args: [--python, python3]
47+
48+
- repo: https://github.com/astral-sh/uv-pre-commit
49+
rev: 0.12.9
50+
hooks:
51+
- id: uv-lock
4152

4253
- repo: local
4354
hooks:
@@ -47,26 +58,11 @@ repos:
4758
language: script
4859
pass_filenames: false
4960

50-
- repo: https://github.com/astral-sh/uv-pre-commit
51-
rev: 0.12.7
52-
hooks:
53-
- id: uv-lock
54-
5561
- repo: https://github.com/abravalheri/validate-pyproject
5662
rev: "0.26"
5763
hooks:
5864
- id: validate-pyproject
5965

60-
# - repo: https://github.com/pre-commit/mirrors-mypy
61-
# rev: v1.20.0
62-
# hooks:
63-
# - id: mypy
64-
# args:
65-
# - --explicit-package-bases
66-
# - --ignore-missing-imports
67-
# - --install-types
68-
# - --non-interactive
69-
7066
- repo: https://github.com/pre-commit/mirrors-prettier
7167
rev: v4.0.0-alpha.8
7268
hooks:

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pre-commit run --all-files --show-diff-on-failure
7777

7878
We want your work to be readable by others; therefore, we encourage you to note the following:
7979

80-
- Please write in Python 3.13+. For instance: `print()` is a function in Python 3 so `print "Hello"` will *not* work but `print("Hello")` will.
80+
- Please write in free-threaded Python 3.14t+. For instance: `print()` is a function in Python 3 so `print "Hello"` will *not* work but `print("Hello")` will.
8181
- Please focus hard on the naming of functions, classes, and variables. Help your reader by using __descriptive names__ that can help you to remove redundant comments.
8282
- Single letter variable names are *old school* so please avoid them unless their life only spans a few lines.
8383
- Expand acronyms because `gcd()` is hard to understand but `greatest_common_divisor()` is not.

audio_filters/equal_loudness_filter.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
from json import loads
42
from pathlib import Path
53

audio_filters/iir_filter.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31

42
class IIRFilter:
53
r"""

audio_filters/show_response.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://en.wikipedia.org/wiki/Frequency_response
55
"""
66

7-
from __future__ import annotations
8-
97
from abc import abstractmethod
108
from math import pi
119
from typing import Protocol

backtracking/all_combinations.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
Time complexity: O(C(n,k)) which is O(n choose k) = O((n!/(k! * (n - k)!))),
66
"""
77

8-
from __future__ import annotations
9-
108
from itertools import combinations
119

1210

backtracking/all_permutations.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
where n denotes the length of the given sequence.
77
"""
88

9-
from __future__ import annotations
10-
119

1210
def generate_all_permutations(sequence: list[int | str]) -> None:
1311
create_state_space_tree(sequence, [], 0, [0 for i in range(len(sequence))])

backtracking/all_subsequences.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
where n denotes the length of the given sequence.
77
"""
88

9-
from __future__ import annotations
10-
119
from typing import Any
1210

1311

backtracking/knight_tour.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Knight Tour Intro: https://www.youtube.com/watch?v=ab_dY3dZFHM
22

3-
from __future__ import annotations
4-
53

64
def get_valid_pos(position: tuple[int, int], n: int) -> list[tuple[int, int]]:
75
"""

0 commit comments

Comments
 (0)