This PR enables the Python type checker to statically evaluate cast expressions on literal values.
To do so, it adds an Evaluator class which can evaluate custom Python AST expressions given some literal value.
That could have also been implemented using Python's own eval machinery, but I prefer to have control on how things are evaluated and what is available in the context.
Finally, cast expressions which have been fully evaluated statically do not generate runtime assertions as this would be redundant.
This PR enables the Python type checker to statically evaluate cast expressions on literal values.
To do so, it adds an `Evaluator` class which can evaluate custom Python AST expressions given some literal value.
That could have also been implemented using Python's own `eval` machinery, but I prefer to have control on how things are evaluated and what is available in the context.
Finally, cast expressions which have been fully evaluated statically do not generate runtime assertions as this would be redundant.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This PR enables the Python type checker to statically evaluate cast expressions on literal values.
To do so, it adds an
Evaluatorclass which can evaluate custom Python AST expressions given some literal value.That could have also been implemented using Python's own
evalmachinery, but I prefer to have control on how things are evaluated and what is available in the context.Finally, cast expressions which have been fully evaluated statically do not generate runtime assertions as this would be redundant.