Skip to content

Commit c3b30ff

Browse files
committed
lint: use ty in linter
1 parent 2c70e1b commit c3b30ff

File tree

5 files changed

+11
-18
lines changed

5 files changed

+11
-18
lines changed

ci/lint/01_install.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ python3 --version
3131

3232
uv pip install --python /python_env \
3333
lief==0.16.6 \
34-
mypy==1.18.2 \
3534
pyzmq==27.1.0 \
3635
ruff==0.13.2 \
3736
vulture==2.14

ci/lint/container-entrypoint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export LC_ALL=C
1111
git config --global --add safe.directory /bitcoin
1212

1313
export PATH="/python_env/bin:${PATH}"
14+
export VIRTUAL_ENV="/python_env"
1415

1516
if [ -z "$1" ]; then
1617
bash -ic "./ci/lint/06_script.sh"

ci/lint_imagefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ENV DEBIAN_FRONTEND=noninteractive
1010
ENV LC_ALL=C.UTF-8
1111

1212
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
13+
COPY --from=ghcr.io/astral-sh/ty:0.0.12 /ty /bin/
1314

1415
COPY ./ci/retry/retry /ci_retry
1516
COPY ./.python-version /.python-version

test/lint/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ or `--help`:
4646
| Lint test | Dependency |
4747
|-----------|:----------:|
4848
| [`lint-python.py`](/test/lint/lint-python.py) | [lief](https://github.com/lief-project/LIEF)
49-
| [`lint-python.py`](/test/lint/lint-python.py) | [mypy](https://github.com/python/mypy)
49+
| [`lint-python.py`](/test/lint/lint-python.py) | [ty](https://github.com/astral-sh/ty)
5050
| [`lint-python.py`](/test/lint/lint-python.py) | [pyzmq](https://github.com/zeromq/pyzmq)
5151
| [`lint-python-dead-code.py`](/test/lint/lint-python-dead-code.py) | [vulture](https://github.com/jendrikseipp/vulture)
5252
| [`lint-shell.py`](/test/lint/lint-shell.py) | [ShellCheck](https://github.com/koalaman/shellcheck)

test/lint/lint-python.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,15 @@
55
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
66

77
"""
8-
Check for specified mypy warnings in python files.
8+
Check for type errors in python files using ty.
99
"""
1010

11-
import os
12-
from pathlib import Path
11+
import shutil
1312
import subprocess
1413

1514
from importlib.metadata import metadata, PackageNotFoundError
1615

17-
# Customize mypy cache dir via environment variable
18-
cache_dir = Path(__file__).parent.parent / ".mypy_cache"
19-
os.environ["MYPY_CACHE_DIR"] = str(cache_dir)
20-
21-
DEPS = ['lief', 'mypy', 'pyzmq']
22-
23-
# Only .py files in test/functional and contrib/devtools have type annotations
24-
# enforced.
25-
MYPY_FILES_ARGS = ['git', 'ls-files', 'test/functional/*.py', 'contrib/devtools/*.py']
16+
DEPS = ['lief', 'pyzmq']
2617

2718

2819
def check_dependencies():
@@ -33,15 +24,16 @@ def check_dependencies():
3324
print(f"Skipping Python linting since {dep} is not installed.")
3425
exit(0)
3526

27+
if not shutil.which('ty'):
28+
print("Skipping Python linting since ty is not installed.")
29+
exit(0)
30+
3631

3732
def main():
3833
check_dependencies()
3934

40-
mypy_files = subprocess.check_output(MYPY_FILES_ARGS, text=True).splitlines()
41-
mypy_args = ['mypy', '--show-error-codes'] + mypy_files
42-
4335
try:
44-
subprocess.check_call(mypy_args)
36+
subprocess.check_call(['ty', 'check'])
4537
except subprocess.CalledProcessError:
4638
exit(1)
4739

0 commit comments

Comments
 (0)