pittcsc / PittAPI

An API to easily get data from the University of Pittsburgh
https://pittapi.pittcsc.org
GNU General Public License v2.0
108 stars 33 forks source link

Introduce static type checking into the API #45

Open RitwikGupta opened 7 years ago

RitwikGupta commented 7 years ago

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/

Jdsleppy commented 6 years ago

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 !

RitwikGupta commented 6 years ago

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.

Jdsleppy commented 6 years ago

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

tianyizheng02 commented 3 months ago

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