wizmer
wizmer

Reputation: 930

Python syntax checkers that test edge cases

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

Answers (2)

Artem Sychov
Artem Sychov

Reputation: 163

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

Upvotes: 1

Patrick Haugh
Patrick Haugh

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

Related Questions