Conversation
This occurred because mypy respects the testpaths/ setting of pytest.
This is viable insofar as TOMLDocument does inherit from dict internally, and covers the parts of interface that are used here. Ref: `https://github.com/python-poetry/tomlkit/issues/326`
ClassVar solution had an unexpected and breaking interaction with internals of dataclasses / custom sqlalchemy usage
This lead to various mypy errors because search function returns DatasetRecord, not Datasets Once corrected, an old search path revealed additional errors due to unimplemented `asdict` on the corrected class
* Call init method on exact class, not potential subclass * Don't reuse variable names because the old ones have inferred types
|
Thanks for the thorough PR! You are correct for the I ran the tests locally and now that mypy runs on the full code, it complains about a few missing type stubs, could you add them to the PR to make it complete ? Running |
|
Thanks for the review! Fun fact: those types are installed in the existing config under pyproject.toml I notice that the codebase is in the process of moving over to uv. I'll make the changes here for just these two things, but it might be worth reviewing that section of pyproject.toml to see if any other dependencies need to be carried over. |
|
Oh right, I ran pytest through uv. I'll get the |
(I've passed a note about this to the person managing the broader rye -> uv switch)
|
Updated this PR with the dependencies needed to get mypy working in uv environments. I'll consider your changes to be the final source of truth. I'm changing it here only so that my code will pass as-written, even if the switch to uv lands first. |
|
I merged yours before other changes, so I'll only bother myself with potential conflicts :) |
|
Purpose
This project includes type annotations. However,
pytest-mypyonly inspects files specified in the pytesttestpathsconfiguration (per pyproject.toml). (see discussion) This caused mypy to skip project code when run in CI (it was only linting test files).If run directly (
mypy esgpull/,pytest ., etc), ~30 type errors were returned.This PR fixes mypy to run when intended, and produces clean error output.
Summary of changes
This PR has been broken down into conceptually related commits, and in cases where errors are ignored, commit messages link directly to underlying rationale.
AFAICT, the correct return type for search functions is
DatasetRecordrather thanDataset, and this annotation does seem to resolve many of the warnings. Let me know if that is incorrect.As this is my first PR to this repo, I'm happy to revise on request. I like to have a clean slate for tests before I start larger edits :)