Closed DimitriPapadopoulos closed 3 months ago
I don't understand the MyPy errors in CI:
I cannot reproduce them locally:
$ python -m mypy --pretty --show-error-context src
Success: no issues found in 21 source files
$
$ mypy --version
mypy 1.11.1 (compiled: yes)
$
Perhaps related to pinned-down versions of dependencies?
typecheck: fastjsonschema==2.20.0,importlib_resources==6.4.0,mypy==1.11.1,mypy-extensions==1.0.0,packaging==24.1,pip==24.1,setuptools==70.1.0,tomli==2.0.1,trove-classifiers==2024.7.2,typing_extensions==4.12.2,validate-pyproject @ file:///tmp/cirrus-ci-build/dist/validate_pyproject-0.18.post1.dev14%2Bgc585ce5-py3-none-any.whl#sha256=6c3d97a42127e4c1af7f88fcf3b52101a7b3a433b7c32c04ef81f74588857fec,wheel==0.43.0
Thank you very much!
So with this pre-commit
will autofix unused type: ignore
annotations, right?
except prettier, no plans to use nodejs in the CI for a Python project
If you know a good markdown linter or formatter alternative, happy to add it in the list of known list.
So with this pre-commit will autofix unused type: ignore annotations, right?
No, you need something that reads python files for that. There are several options, but I'm personally waiting to see what the Ruff team produces. They are working on a type checker; last I heard it was going to be part of Ruff (and the prototype is part of Ruff), though I'm curious to see if they stick with that - Ruff famously doesn't require or use any dependencies, but a type checker does need dependencies and stub files.
If you know a good markdown linter or formatter alternative, happy to add it in the list of known list.
I haven't tested mdformat yet so I cannot voucher for it, but it comes from the executable books folk, which usually do nice stuff.
So with this pre-commit will autofix unused type: ignore annotations, right?
No, you need something that reads python files for that. There are several options, but I'm personally waiting to see what the Ruff team produces. They are working on a type checker; last I heard it was going to be part of Ruff (and the prototype is part of Ruff), though I'm curious to see if they stick with that - Ruff famously doesn't require or use any dependencies, but a type checker does need dependencies and stub files.
This PR modifies the MyPy options so that MyPy catches unused type: ignore annotations when run. However, I don't see pre-commit running MyPy; it would probably involve adding this hook: https://github.com/pre-commit/mirrors-mypy. On the other hand, one of the GitHub CI jobs does run MyPy — maybe through tox, I don't know how it's done.
I'm a bit worried about mdformat. It's not been touched in months. It seems to be worked on by the author of tomli, who's not make a public commit since April. It does have plugins for lots of things, but the plugin system isn't configurable; this is particularly bad when some plugins change the target (what happens if mdformat-gfm and mdformat-rtd are both installed?). Happy to add it to the list of supported formatters, but I'm probably not going to propose it as an alternative just yet.
I know people at executable books, so might ask around.
Follow-up of https://github.com/abravalheri/validate-pyproject/pull/187#issuecomment-2273640670.