adafruit / Adafruit_CircuitPython_DHT

CircuitPython support for DHT11 and DHT22 type temperature/humidity devices
MIT License
182 stars 64 forks source link

Add type hints #76

Closed tylercrumpton closed 2 years ago

tylercrumpton commented 2 years ago

Hiya! I've added type hints for this (fixes #74 ).

These changes clear all of the errors returned from mypy adafruit_dht.py --disallow-untyped-defs except for one:

adafruit_dht.py:149: error: Too many arguments for "__exit__" of "DigitalInOut"

I'd fix that one up as well, but I'm not actually sure what is causing it.

Thanks!

tylercrumpton commented 2 years ago

Ack, too much TypeScript in my brain. Let me fix those Union types.

tylercrumpton commented 2 years ago

I had to remove the variable type hints because mpy-cross didn't seem to like those. That means these errors will still pop up for mypy:

adafruit_dht.py:204: error: Incompatible types in assignment (expression has type "float", variable has type "int")
adafruit_dht.py:234: error: Incompatible types in assignment (expression has type "float", variable has type "int")
adafruit_dht.py:237: error: Incompatible types in assignment (expression has type "float", variable has type "int")
adafruit_dht.py:255: error: Incompatible types in assignment (expression has type "int", variable has type "None")
adafruit_dht.py:256: error: Incompatible types in assignment (expression has type "int", variable has type "None")