PittAPI icon indicating copy to clipboard operation
PittAPI copied to clipboard

Introduce static type checking into the API

Open RitwikGupta opened this issue 8 years ago • 4 comments

MyPy is a terrific project that lets us introduce static typing into parts of our code. Since there are certain parts of the code which follow a specific type, use MyPy to type check those portions.

MyPy: http://mypy-lang.org/

  • [x] Identify parts of the code that can be type checked (all private functions)
  • [x] Add static typing to them

RitwikGupta avatar Feb 13 '17 05:02 RitwikGupta

Hi, I'd like to pick up this issue. I'll look at #74 as an example.

As a next step, I would recommend using tox to wrap up testing, type checking, and linting into one simple, portable command: tox !

Jdsleppy avatar Oct 05 '17 01:10 Jdsleppy

Awesome! Thanks @Jdsleppy. And tox is something I'm looking at, but we're waiting on a PR to be completed to make the tests hermetic first.

RitwikGupta avatar Oct 05 '17 01:10 RitwikGupta

I opened a PR to type annotate about half of the code base. I see somebody worked on this in the meantime, so there were pretty nasty merge conflicts and duplication of work. I still think my changes are valuable because they tend to specify the types a little further in places where Any is used. Also, it adds annotations to library.py.

There is also a bugfix for a test in the PR.

https://github.com/Pitt-CSC/PittAPI/pull/82

Jdsleppy avatar Oct 05 '17 22:10 Jdsleppy

I'm reopening this issue because I don't think it was ever actually completed:

  1. There are some parts of the code that still aren't type-hinted
  2. mypy was never added to the repo's tooling
  3. Now that we're using pre-commit, we can easily introduce and (and more importantly enforce) static type checking

tianyizheng02 avatar Jun 12 '24 10:06 tianyizheng02