Add and fix type annotations in torchio so it passes inspection with mypy and so end users can trust that the type annotations reflects function, class instantiation, etc. arguments and outputs.
This is follow up issue to the PR #808 and issue #807.
Motivation
The current version of torchio (v0.18.72) is not properly type annotated (some functions are missing type annotations, some have overly restrictive types, some are outdated) and fails mypy inspection on many accounts.
mypy has caught a good number of errors in my code, and proper type annotations make development much easier in a modern IDE (IMO).
Pitch
Since making torchio work properly with mypy will change a good number of files (39 it looks like, although some of the errors might be fixed by fixing the type issue elsewhere), I'll do the following:
Make a mypy feature branch
Define the least strict base types the project requires
Fix the mypy issues in one function
Commit the changes
Repeat 3-4 until no more mypy errors
Submit a PR
I'll avoid changing any actual functionality, although there are likely to be be some bugs caught while going through the process. If I find a potential error, I'd just raise an issue instead of correcting it.
Alternatives
Alternatively, I could make a mypy-modulename feature branch and submit a PR for each module (e.g., at the level of torchio/data/image.py or torchio/data). It might get a bit tedious, but it'd avoid a giant PR; however, type annotations are very entangled, so I'm not sure how effective that workflow would be at eliminating errors from the project.
π Feature
Add and fix type annotations in torchio so it passes inspection with mypy and so end users can trust that the type annotations reflects function, class instantiation, etc. arguments and outputs.
This is follow up issue to the PR #808 and issue #807.
Motivation
The current version of torchio (v0.18.72) is not properly type annotated (some functions are missing type annotations, some have overly restrictive types, some are outdated) and fails mypy inspection on many accounts.
mypy has caught a good number of errors in my code, and proper type annotations make development much easier in a modern IDE (IMO).
Pitch
Since making torchio work properly with mypy will change a good number of files (39 it looks like, although some of the errors might be fixed by fixing the type issue elsewhere), I'll do the following:
I'll avoid changing any actual functionality, although there are likely to be be some bugs caught while going through the process. If I find a potential error, I'd just raise an issue instead of correcting it.
Alternatives
Alternatively, I could make a mypy-modulename feature branch and submit a PR for each module (e.g., at the level of torchio/data/image.py or torchio/data). It might get a bit tedious, but it'd avoid a giant PR; however, type annotations are very entangled, so I'm not sure how effective that workflow would be at eliminating errors from the project.