diff --git a/personal_python_ast_optimizer/parser/skipper.py b/personal_python_ast_optimizer/parser/skipper.py index aff7a1b..1806920 100644 --- a/personal_python_ast_optimizer/parser/skipper.py +++ b/personal_python_ast_optimizer/parser/skipper.py @@ -820,6 +820,10 @@ def _ast_constants_operation( # noqa: C901, PLR0912 result = left_value > right_value # type: ignore case ast.GtE(): result = left_value >= right_value # type: ignore + case ast.Is(): + result = left_value is right_value + case ast.IsNot(): + result = left_value is not right_value case _: raise ValueError(f"Invalid operation: {operation.__class__.__name__}") diff --git a/tests/parser/test_constant_folding.py b/tests/parser/test_constant_folding.py index b0ee165..4b1685b 100644 --- a/tests/parser/test_constant_folding.py +++ b/tests/parser/test_constant_folding.py @@ -11,6 +11,8 @@ BeforeAndAfter("a=64|1", "a=65"), BeforeAndAfter("a=7&3", "a=3"), BeforeAndAfter("a=3^6", "a=5"), + BeforeAndAfter("a='a' is 'b'", "a=False"), + BeforeAndAfter("a='a' is not 'b'", "a=True"), ] diff --git a/version.txt b/version.txt index cd1d2e9..8b22a32 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -8.0.1 +8.0.2