|
|
|
|
|
by stefanhoelzl
1780 days ago
|
|
mypy accepts much broader types then the concept I was proposing.
Lets take this example: def foo(bar: Optional[float]) -> Optional[float]:
return bar
def test_foo():
assert foo(5) == 5
It has 100% code coverage and mypy will accept it.What I proposed will complain in this case, that you never tested `foo` with `None` or `float` as input parameters and that it never has seen `foo` returning `None` or `float`. So even with 100% code coverage and mypy not complaining 'type coverage' could give you some hints that
a) your tests are not extensive enough
or
b) your annotated types are too broad |
|
What you propose will certainly solve the issue when dealing with unannotated code, though.