Skip to content

Commit e51808a

Browse files
committed
📦 create another uv project as workaround for mypy's project isolation issues
1 parent d8cc43a commit e51808a

File tree

4 files changed

+332
-0
lines changed

4 files changed

+332
-0
lines changed

‎test/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# numtype-test

‎test/main.py‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
"""Run basedmypy, so that uses `numpy-stubs` instead of numpy's own stubs."""
2+
3+
# ruff: noqa: T201, S603, S404, D103, DOC201
4+
5+
import subprocess
6+
import sys
7+
from pathlib import Path
8+
9+
PROJECT_PATH = Path(__file__).parent.parent.resolve()
10+
11+
12+
def _call_static(args: list[str], *base_cmd: str) -> int:
13+
if not args or all(arg.startswith("-") for arg in args): # noqa: SIM108
14+
cmd = [*base_cmd, *args, "static"]
15+
else:
16+
cmd = [*base_cmd, *args]
17+
18+
print(*cmd)
19+
return subprocess.call(cmd)
20+
21+
22+
def _static_bmp(args: list[str], /) -> int:
23+
return _call_static(
24+
args,
25+
"mypy",
26+
"--explicit-package-bases",
27+
"--hide-error-context",
28+
"--hide-error-code-links",
29+
"--no-pretty",
30+
"--tb",
31+
"--config-file=../pyproject.toml",
32+
)
33+
34+
35+
def _static_bpr(args: list[str], /) -> int:
36+
return _call_static(args, "basedpyright", "--project=../")
37+
38+
39+
def static(args: list[str] | None = None, /) -> int:
40+
if args is None:
41+
args = sys.argv[1:]
42+
if args:
43+
if args[0] == "all":
44+
return _static_bpr(args[1:]) or _static_bmp(args[1:])
45+
if args[0] == "bpr":
46+
return _static_bpr(args[1:])
47+
if args[0] == "bmp":
48+
return _static_bmp(args[1:])
49+
50+
print("Usage: uv run test static [<COMMAND> [OPTIONS]]")
51+
print()
52+
print("Commands:")
53+
print(" all", "Run all static tests", sep="\t")
54+
print(" bpr", "Run basedpyright", sep="\t")
55+
print(" bmp", "Run basedmypy", sep="\t")
56+
return 1
57+
58+
59+
def main(args: list[str] | None = None, /) -> int:
60+
if args is None:
61+
args = sys.argv[1:]
62+
if not args or args[0] != "static":
63+
print("Usage: uv run test <COMMAND>")
64+
print()
65+
print("Commands:")
66+
print(" static", "Static type-testing", sep="\t")
67+
return 1
68+
69+
return static(args[1:])
70+
71+
72+
if __name__ == "__main__":
73+
sys.exit(main(sys.argv[1:]))

‎test/pyproject.toml‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "numtype_test"
7+
version = "0.1.0"
8+
description = "NumType's testing app"
9+
readme = "README.md"
10+
requires-python = ">=3.10"
11+
dependencies = [
12+
"numtype",
13+
"basedmypy[faster-cache]>=2.9.1",
14+
"basedpyright>=1.26.0",
15+
]
16+
17+
[project.scripts]
18+
static = "main:static"
19+
20+
[tool.uv.sources]
21+
numtype = {path = ".." }
22+
23+
[tool.hatch.build]
24+
packages = ["."]

0 commit comments

Comments
 (0)