0

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

wizmer
  • 881
  • 1
  • 8
  • 23

2 Answers2

3

You're looking for a type checker, not a syntax checker. Here's one attempt to make one: http://mypy-lang.org/

Patrick Haugh
  • 59,226
  • 13
  • 88
  • 96
1

You need a type checker, not a syntax checker. github.com/python/mypy

Artem Sychov
  • 142
  • 1
  • 3
  • 15