nohtyprm / MrPython

A simplified programming environment for Python (3.x) - based on IDLE
https://nohtyprm.github.io/MrPython/
Other
28 stars 34 forks source link

None sans Optional devrait provoquer une erreur #182

Open fgallaire opened 1 year ago

fgallaire commented 1 year ago

not None est évalué comme True, et lorsque None est renvoyé de manière implicite par Python et non de manière explicite dans un return, MrPython ne relève pas le problème de typage. Cela pose un problème pour les tests des fonctions booléennes :

def test() -> bool:
    """"""
    if 1 > 2:
        return True

assert not test()
assert test() == False

Un retour implicite de None sans Optional devrait provoquer une erreur.

fredokun commented 1 year ago

this one is tricky ... because the actual python interpreter is running the programs, not an instrumented one. A partial static analysis could help (in fact, a program graph analysis was planned at some point)