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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add and fix type annotations for type checking with mypy #810

Open
jcreinhold opened this issue Jan 30, 2022 · 1 comment
Open

Add and fix type annotations for type checking with mypy #810

jcreinhold opened this issue Jan 30, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@jcreinhold
Copy link
Contributor

馃殌 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:

  1. Make a mypy feature branch
  2. Define the least strict base types the project requires
  3. Fix the mypy issues in one function
  4. Commit the changes
  5. Repeat 3-4 until no more mypy errors
  6. 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.

@jcreinhold jcreinhold added the enhancement New feature or request label Jan 30, 2022
@fepegar fepegar mentioned this issue Jun 26, 2022
9 tasks
@fepegar
Copy link
Owner

fepegar commented Dec 3, 2023

Hey, @jcreinhold. Are you still thinking of tackling this? Seems like a heroic feat :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants