Reputation: 930
Are there syntax checkers able to detect broken code based on edge cases. An example:
def run():
for j in [0, 1]:
if j == 0:
yield j
else:
yield None
for i in run():
print i * 2
This code is broken because None * 2
does not make sense. Are there tools to detect this kind of error ?
Thank you
Upvotes: 0
Views: 279
Reputation: 163
You need a type checker, not a syntax checker. github.com/python/mypy
Upvotes: 1
Reputation: 60974
You're looking for a type checker, not a syntax checker. Here's one attempt to make one: http://mypy-lang.org/
Upvotes: 3