When tests finish, a report should be printed that shows the code
coverage of timm. This should give us a better idea where we should work
on test coverage.
I have tested this locally (on a subset of tests) and it worked.
Since the number of test dependencies was getting quite high, I created
a requirements-dev.txt and moved them there. GH action and
CONTRIBUTING.md are adjusted accordingly.
Furthermore, instead of extending the pytest invocation, I created a
pyproject.toml and added the coverage options there. For completeness, I
also added the black settings that come closest to the style of timm.
LMK if this is not desired.
For now, the coverage is only reported but not enforced. I.e. when a PR
is created that adds uncovered lines, CI will still succeed. We could
think about adding codecov or something like that, but it can be
annoying sometimes and the service was flaky for me in the past.
Description
Add type annotations to _registry.py so that they will pass mypy
--strict.
Comment
I was reading the code and felt that this module would be easier to
understand with type annotations. Therefore, I went ahead and added the
annotations.
The idea with this PR is to start small to see if we can align on _how_
to annotate types. I've seen people in the past disagree on how strictly
to annotate the code base, so before spending too much time on this, I
wanted to check if you agree, Ross.
Most of the added types should be straightforward. Some notes on the
non-trivial changes:
- I made no assumption about the fn passed to register_model, but maybe
the type could be stricter. Are all models nn.Modules?
- If I'm not mistaken, the type hint for get_arch_name was incorrect
- I had to add a # type: ignore to model.__all__ = ...
- I made some minor code changes to list_models to facilitate the
typing. I think the changes should not affect the logic of the function.
- I removed list from list(sorted(...)) because sorted returns always a
list.
* Some additions to the CONTRIBUTING guide
- how to run black if so desired
- install instructions for devs (following GH action)
- running tests
- minor fixups
If there is a guide on how to best add new models, it would be a good
idea to link it here, since I imagine this is what many contributors
would need most help with.
* [skip ci] empty commit to skip ci