Open KDruzhkin opened 2 months ago
Good question, we can document this. In general MyPy and the type stubs should all be in [tool.uv.dev-dependencies]
.
So, mypy
is different from most other tools: it does not work well in isolation.
To be precise, if you want mypy
to follow imports:
[tool.mypy]
follow_imports = "normal"
... then uv tool run mypy
is not the way to go.
Yeah this is explicitly noted at https://docs.astral.sh/uv/concepts/tools/#relationship-to-uv-run — do we need to provide more context somewhere?
Yeah this is explicitly noted at https://docs.astral.sh/uv/concepts/tools/#relationship-to-uv-run — do we need to provide more context somewhere?
For any other tool, I would say, no.
But mypy
is not a tool among many, it is the tool for type checking, and it deserves a section of its own.
We do literally mention mypy
there though. I'm not quite sure a section that says "mypy is a dev dependency" makes sense for the project documentation. Maybe we could do an integration guide for it.
Hmm…
It would be nice if the tools section started with something like:
“… there are two general categories of tools: 1) tools which work in isolation, e.g. ruff
, and 2) tools which require access the development environment, e.g. mypy
, pytest
. For the first category uv
includes a dedicated interface…”
Yes, the docs say just so, but they say it at the end of the section, under the subtle “Relationship to uv run”.
Anyway, thanks for your fantastic work on ruff
and uv
!
That makes sense, I think. I will look into that.
Type stubs can be provided in separate packages. For example, a package
foo
has a companion packagetypes-foo
orfoo-stubs
.With poetry, a typical pyproject.toml file looks like this:
So, with poetry, the development virtual environment contains both
mypy
and the stub packages (used bymypy
to check the project).How should I handle stub packages with
uv
? Do they belong in the tool environment formypy
? If yes, how do I put them there?