Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 allow running numtype-test with uv run --project #22

Merged
merged 3 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"evenBetterToml.formatter.indentString": " ",
"evenBetterToml.formatter.indentTables": true,
"evenBetterToml.formatter.trailingNewline": true,
"mypy-type-checker.path": ["uv", "run", "--directory=test", "static", "bmp"]
"mypy-type-checker.path": ["uv", "run", "--project=test", "static", "bmp"]
}
14 changes: 11 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ classifiers = [
"Typing :: Typed",
]
requires-python = ">=3.10"
packages = [{include = "src/numpy-stubs" }]
dependencies = []


[project.optional-dependencies]
numpy = ["numpy>=2.2.2,<2.3"]

Expand Down Expand Up @@ -68,8 +70,14 @@ packages = ["src/numpy-stubs"]

[tool.mypy]
python_version = "3.10"
strict = true
mypy_path = "src"

pretty = false
show_error_context = false
show_error_code_links = false
show_traceback = false

strict = true
disable_bytearray_promotion = true
disable_memoryview_promotion = true
enable_error_code = ["ignore-without-code", "truthy-bool"]
Expand All @@ -93,7 +101,7 @@ include = [
"tool",
]
ignore = [".venv", "test/.venv"]
stubPath = "src"
stubPath = "."
pythonPlatform = "All"
pythonVersion = "3.10"
typeCheckingMode = "standard" # TODO(jorenham): set to "all"
Expand Down Expand Up @@ -124,7 +132,7 @@ strictGenericNarrowing = true


[tool.ruff]
src = ["src", "test", "tool"]
src = ["src/numpy-stubs", "test", "tool"]
extend-exclude = [".git", ".mypy_cache", ".tox", ".venv"]
force-exclude = true
# https://typing.readthedocs.io/en/latest/guides/writing_stubs.html#maximum-line-length
Expand Down
19 changes: 18 additions & 1 deletion test/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
# numtype-test
# NumType testing

Mypy and basedmypy will only recognize the `src/numpy-stubs` if `numtype` is installed in an
isolated project, and it cannot be editable.
The private `numtype-test` project in this directory provides entrypoints that will run basedmypy
and basedpyright.

To run basedmypy (`bmp` for short) on the static tests, run

```bash
uv run static <bmp|bpr|all> [OPTIONS]
```

Here, `bmp` runs (based)`mypy`, `bpr` runs `basedpyright`, and `all` runs both.
If no options are provided, it defaults to `static/`.

To run this form the root `numtype` directory, you can pass an additional `--project=test` flag
to the `uv run` command (i.e. before `static`).
10 changes: 3 additions & 7 deletions test/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,13 @@ def _static_bmp(args: list[str], /) -> int:
return _call_static(
args,
"mypy",
"--explicit-package-bases",
"--hide-error-context",
"--hide-error-code-links",
"--no-pretty",
"--tb",
"--config-file=../pyproject.toml",
"--config-file",
str(PROJECT_PATH / "pyproject.toml"),
)


def _static_bpr(args: list[str], /) -> int:
return _call_static(args, "basedpyright", "--project=../")
return _call_static(args, "basedpyright", "--project", str(PROJECT_PATH))


def static(args: list[str] | None = None, /) -> int:
Expand Down
12 changes: 9 additions & 3 deletions test/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@ requires-python = ">=3.10"
dependencies = [
"numtype",
"basedmypy[faster-cache]>=2.9.1",
# "mypy[faster-cache]>=1.14.1",
"basedpyright>=1.26.0",
]

[project.scripts]
static = "main:static"

[tool.uv.sources]
numtype = {path = ".."}
[tool.uv]
reinstall-package = ["numtype"]

[tool.uv.pip]
strict = true

[tool.uv.sources]
numtype = {path = ".."}

[tool.hatch.build]
packages = ["."]
Loading