Skip to content

Commit a2fce81

Browse files
committed
Add qa.ty domain for Astral's ty type checker
Fast Python type checker (10-100x faster than mypy). Registers with CHECK_TARGETS and TYPECHECK_TARGETS.
1 parent baef7f0 commit a2fce81

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 2.0.2
4+
5+
- Feature: Add `qa.ty` domain for Astral's ty type checker.
6+
ty is an extremely fast Python type checker (10-100x faster than mypy).
7+
Registers with both CHECK_TARGETS and TYPECHECK_TARGETS for fast feedback.
8+
[jensens]
9+
310
## 2.0.1
411

512
- Enhancement: Use tables in the generated sphinx code for topic/domains.

src/mxmake/topics/qa/ty.mk

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#:[ty]
2+
#:title = ty
3+
#:description = Static type checking with ty (Astral's fast type checker).
4+
#:depends = core.packages
5+
#:
6+
#:[target.ty]
7+
#:description = Run ty type checker.
8+
#:
9+
#:[setting.TY_SRC]
10+
#:description = Source folder for type checking.
11+
#:default = src
12+
#:
13+
#:[setting.TY_PYTHON_VERSION]
14+
#:description = Target Python version for type checking (e.g., 3.12).
15+
#: Leave empty to use default detection.
16+
#:default =
17+
#:
18+
#:[target.ty-dirty]
19+
#:description = Marks ty dirty.
20+
#:
21+
#:[target.ty-clean]
22+
#:description = Uninstall ty and removes cached data.
23+
24+
##############################################################################
25+
# ty
26+
##############################################################################
27+
28+
# Adjust TY_SRC to respect PROJECT_PATH_PYTHON if still at default
29+
ifeq ($(TY_SRC),src)
30+
TY_SRC:=$(PYTHON_PROJECT_PREFIX)src
31+
endif
32+
33+
# Build ty flags
34+
TY_FLAGS:=
35+
ifneq ($(TY_PYTHON_VERSION),)
36+
TY_FLAGS+=--python-version $(TY_PYTHON_VERSION)
37+
endif
38+
39+
TY_TARGET:=$(SENTINEL_FOLDER)/ty.sentinel
40+
$(TY_TARGET): $(MXENV_TARGET)
41+
@echo "Install ty"
42+
@$(PYTHON_PACKAGE_COMMAND) install ty
43+
@touch $(TY_TARGET)
44+
45+
.PHONY: ty
46+
ty: $(PACKAGES_TARGET) $(TY_TARGET)
47+
@echo "Run ty"
48+
@ty check $(TY_FLAGS) $(TY_SRC)
49+
50+
.PHONY: ty-dirty
51+
ty-dirty:
52+
@rm -f $(TY_TARGET)
53+
54+
.PHONY: ty-clean
55+
ty-clean: ty-dirty
56+
@test -e $(MXENV_PYTHON) && $(MXENV_PYTHON) -m pip uninstall -y ty || :
57+
@rm -rf .ty
58+
59+
INSTALL_TARGETS+=$(TY_TARGET)
60+
CHECK_TARGETS+=ty
61+
TYPECHECK_TARGETS+=ty
62+
CLEAN_TARGETS+=ty-clean
63+
DIRTY_TARGETS+=ty-dirty

0 commit comments

Comments
 (0)