Skip to content

chore: stricter mypy - #2053

Merged
henryiii merged 3 commits into
pypa:mainfrom
henryiii:henryiii/chore/mypy
Oct 22, 2024
Merged

henryiii merged 3 commits into
pypa:mainfrom
henryiii:henryiii/chore/mypy

Conversation

@henryiii

@henryiii henryiii commented Oct 21, 2024 •

Copy link
Copy Markdown
Contributor

I was looking at updating #1873 (and I realized it would be better to wait till after #1912) and I noticed we weren't very sensitive to updating things like util.call -> utils.cmd.call in our tests; I'd expect mypy to be able to detect all these without wasting time to run things. I also noticed this in #2048, where the tests weren't noticing the change to enable. These improvements should get proper mypy "coverage" of our tests. We still don't have 100% typing for arguments, but things like not allowing untyped function calls should require helper functions fully typed.

  • chore: improve mypy (setuptools, pytest added, simpler strict setting, dropped unreachable since it depends on platform)
  • chore(types): type functions in tests
  • chore(types): No partial types in tests

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
@henryiii
henryiii force-pushed the henryiii/chore/mypy branch from 86280bf to c18f9df Compare October 22, 2024 04:45

@Czaki Czaki left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Comment thread .pre-commit-config.yaml
- nox
- packaging
- pygithub
- pytest

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does having so many non pinned dependencies do not make pre-commit mypy fragile?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little (though pytest isn't too bad). Though generally if something changes we just adapt to the change.

Pre-commit doesn't have a way to pin these. Maybe eventually uv will.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-commit doesn't have a way to pin these. Maybe eventually uv will.

What did you mean by uv will? pre-commit.ci do not allow to pass any constraints.

The only possible way that I see is to have own CI job to bump constraints.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean if uv adds multiple independent locked environments (and tasks), we could use that to move this check to uv.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in napari (https://github.com/napari/napari) we use uv to compile a constraints file and call it from tox.

Maybe the same approach could be used here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this becomes too much of a problem, we could probably do something (setting it up with nox would be easy). But for now it's fine, and long term we might end up moving from mypy to red-knot anyway.

@henryiii
henryiii merged commit b986027 into pypa:main Oct 22, 2024
@henryiii
henryiii deleted the henryiii/chore/mypy branch October 22, 2024 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants