Blauschirm / wkvw2sipgate

Crawls the ekvw phone data and transfers it into sipgate
0 stars 0 forks source link

Use type annotations where appropriate and have them checked with mypy #7

Open nitzel opened 5 years ago

nitzel commented 5 years ago

MyPy is a static type checker for Python that will show us where we are passing incorrect types. It's also able to infer a lot of types so we don't have to annotate variables everywhere. It should be enough to type the parameters and maybe return values of all functions.

Install

https://github.com/python/mypy python3 -m pip install -U mypy

Run

mypy crawler.py (instead of python crawler.py)

What?

This is only to help avoid errors in development, we can later run the same code with python crawler.py as well.

How?

def add(a:int, b:int) -> int:
  c = a + b
  return c

print(add(5, '9'))
>> mypy file.py
file.py:5: error: Argument 2 to "add" has incompatible type "str"; expected "int"