mdanalysis icon indicating copy to clipboard operation
mdanalysis copied to clipboard

Adding Type Hints for MDAnalysis

Open umak1106 opened this issue 3 years ago • 3 comments

Is your feature request related to a problem?

MDAnalysis library currently lacks type hints which would help in providing better documentation and help catch errors easily .

Describe the solution you'd like

Proving type hints and annotations for all modules of the library . Usage of mypy for type checking .

umak1106 avatar May 31 '22 15:05 umak1106

#3463 #2450 are the previous issues regarding this .

umak1106 avatar Jun 02 '22 04:06 umak1106

Thank you @umak1106 for opening this issue.

There are 3 main objectives with the type hinting of the library:

  • detect errors in the library code before they are merged;
  • detect errors in downstream code;
  • help with the documentation

One extra benefit of going through the code to add type hinting is that we may identify inconsistencies in the library.

The first thing to do is to make sure that types are checked for each pull request. This means mypy and pyright must be run in CI. At first, they must run without blocking the PR as they will fail until the type hinting is advanced enough; later, the job that run these tool must be made to clock a PR if types are not correct.

  • [ ] #3698
  • [ ] #3699

Once mypy and pyright run in CI, we need to start annotating the code. Then, most things will depend on the output of both mypy and pyright.

jbarnoud avatar Jun 03 '22 07:06 jbarnoud

Thank you @umak1106 for opening this issue.

There are 3 main objectives with the type hinting of the library:

  • detect errors in the library code before they are merged;
  • detect errors in downstream code;
  • help with the documentation

One extra benefit of going through the code to add type hinting is that we may identify inconsistencies in the library.

The first thing to do is to make sure that types are checked for each pull request. This means mypy and pyright must be run in CI. At first, they must run without blocking the PR as they will fail until the type hinting is advanced enough; later, the job that run these tool must be made to clock a PR if types are not correct.

  • [ ] run mypy and pyright in CI
  • [ ] make mypy and pyright in CI blocking

Once mypy and pyright run in CI, we need to start annotating the code. Then, most things will depend on the output of both mypy and pyright.

ok mentor .

umak1106 avatar Jun 03 '22 07:06 umak1106