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

chore: stricter mypy #2053

Merged
merged 3 commits into from
Oct 22, 2024
Merged

chore: stricter mypy #2053

merged 3 commits into from
Oct 22, 2024

Conversation

henryiii
Copy link
Contributor

@henryiii henryiii commented Oct 21, 2024

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

Copy link
Contributor

@Czaki Czaki left a comment

Choose a reason for hiding this comment

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

Looks good

@@ -32,6 +32,7 @@ repos:
- nox
- packaging
- pygithub
- pytest
Copy link
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
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
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
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
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
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
24 of 25 checks passed
@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