diff --git a/aas_core_codegen/ast_dump.py b/aas_core_codegen/ast_dump.py new file mode 100644 index 000000000..8e9c31687 --- /dev/null +++ b/aas_core_codegen/ast_dump.py @@ -0,0 +1,270 @@ +# SPDX-FileCopyrightText: 2023 aas-core-codegen AUTHORS +# +# SPDX-License-Identifier: MIT + +""" +Render Python AST nodes for error messages. + +We do not use :py:func:`ast.dump` in error messages, since its output changes between +Python versions (*e.g.*, Python 3.13 omits ``ctx=Load()``, ``None`` values and +empty lists). Our error messages are recorded in the golden test data, so they need +to be stable. + +We render only the top level of a node as source code, and describe its children +briefly, so that the messages stay short and readable. +""" + +import ast +from typing import Final, Mapping, Optional, Type + +_SYMBOL_BY_OPERATOR_TYPE: Final[Mapping[Type[ast.AST], str]] = { + ast.Add: "+", + ast.And: "and", + ast.BitAnd: "&", + ast.BitOr: "|", + ast.BitXor: "^", + ast.Div: "/", + ast.Eq: "==", + ast.FloorDiv: "//", + ast.Gt: ">", + ast.GtE: ">=", + ast.In: "in", + ast.Invert: "~", + ast.Is: "is", + ast.IsNot: "is not", + ast.LShift: "<<", + ast.Lt: "<", + ast.LtE: "<=", + ast.MatMult: "@", + ast.Mod: "%", + ast.Mult: "*", + ast.Not: "not", + ast.NotEq: "!=", + ast.NotIn: "not in", + ast.Or: "or", + ast.Pow: "**", + ast.RShift: ">>", + ast.Sub: "-", + ast.UAdd: "+", + ast.USub: "-", +} + +_DESCRIPTION_BY_NODE_TYPE: Final[Mapping[Type[ast.AST], str]] = { + ast.AnnAssign: "annotated assignment", + ast.Assign: "assignment", + ast.Call: "call", + ast.Dict: "dict", + ast.DictComp: "dict comprehension", + ast.For: "for-loop", + ast.FormattedValue: "formatted value", + ast.GeneratorExp: "generator expression", + ast.If: "if-statement", + ast.IfExp: "conditional expression", + ast.JoinedStr: "f-string", + ast.Lambda: "lambda", + ast.List: "list", + ast.ListComp: "list comprehension", + ast.Return: "return statement", + ast.Set: "set", + ast.SetComp: "set comprehension", + ast.Starred: "starred expression", + ast.Subscript: "subscript", + ast.Tuple: "tuple", + ast.While: "while-loop", + ast.comprehension: "comprehension clause", + ast.keyword: "keyword argument", +} + + +def _describe(node: ast.AST) -> str: + """ + Describe the ``node`` in a couple of words, falling back to its type name. + + >>> _describe(ast.parse("a | b", mode="eval").body) + '|-operator' + + >>> _describe(ast.parse("a is not None", mode="eval").body) + 'is not-comparison' + + >>> _describe(ast.parse("-a", mode="eval").body) + 'unary --operator' + + >>> _describe(ast.parse("await a", mode="eval").body) + 'Await' + """ + if isinstance(node, (ast.BinOp, ast.BoolOp)): + return f"{_SYMBOL_BY_OPERATOR_TYPE[type(node.op)]}-operator" + + if isinstance(node, ast.UnaryOp): + return f"unary {_SYMBOL_BY_OPERATOR_TYPE[type(node.op)]}-operator" + + if isinstance(node, ast.Compare): + return f"{_SYMBOL_BY_OPERATOR_TYPE[type(node.ops[0])]}-comparison" + + return _DESCRIPTION_BY_NODE_TYPE.get(type(node), type(node).__name__) + + +def _dotted_name(node: ast.AST) -> Optional[str]: + """ + Render the ``node`` if it is a name or a chain of attributes on a name. + + >>> _dotted_name(ast.parse("self.x.y", mode="eval").body) + 'self.x.y' + + >>> _dotted_name(ast.parse("f().x", mode="eval").body) is None + True + """ + if isinstance(node, ast.Name): + return node.id + + if isinstance(node, ast.Attribute): + value = _dotted_name(node.value) + return None if value is None else f"{value}.{node.attr}" + + return None + + +def _dump_child(node: ast.AST) -> str: + """ + Render names, attribute chains and constants verbatim, and describe the rest. + + >>> _dump_child(ast.parse("self.f(g(x))", mode="eval").body) + '' + + >>> _dump_child(ast.parse("self.xs[0]", mode="eval").body) + '' + + >>> _dump_child(ast.parse("f().x", mode="eval").body) + '' + """ + dotted_name = _dotted_name(node) + if dotted_name is not None: + return dotted_name + + if isinstance(node, ast.Constant): + return repr(node.value) + + if isinstance(node, ast.Starred): + value = _dotted_name(node.value) + if value is not None: + return f"*{value}" + + elif isinstance(node, ast.Call): + func = _dotted_name(node.func) + if func is not None: + return f"" + + elif isinstance(node, ast.Subscript): + value = _dotted_name(node.value) + if value is not None: + return f"" + + elif isinstance(node, ast.Attribute): + return f"" + + return f"<{_describe(node)}>" + + +def dump(node: ast.AST) -> str: + """ + Render the Python AST ``node`` for error messages, stable across Python versions. + + We render only the top level of ``node`` as source code. The children are + rendered verbatim only if they are names, attribute chains or constants, and + described otherwise. + + >>> dump(ast.parse("self.Child", mode="eval").body) + 'self.Child' + + >>> dump(ast.parse("f(g(x), y.h(), *z, w=1)", mode="eval").body) + 'f(, , *z, w=1)' + + >>> dump(ast.parse("a | b | None", mode="eval").body) + '<|-operator> | None' + + >>> dump(ast.parse("x: Dict[str, int] = {}").body[0]) + 'x: = ' + + >>> dump(ast.parse("lambda: 1", mode="eval").body) + '' + """ + child = _dump_child + + if isinstance(node, ast.Expr): + return dump(node.value) + + if isinstance(node, ast.Attribute): + return f"{child(node.value)}.{node.attr}" + + if isinstance(node, ast.Call): + args = [child(arg) for arg in node.args] + args.extend( + ( + f"**{child(keyword.value)}" + if keyword.arg is None + else f"{keyword.arg}={child(keyword.value)}" + ) + for keyword in node.keywords + ) + return f"{child(node.func)}({', '.join(args)})" + + if isinstance(node, ast.Starred): + return f"*{child(node.value)}" + + if isinstance(node, ast.BinOp): + symbol = _SYMBOL_BY_OPERATOR_TYPE[type(node.op)] + return f"{child(node.left)} {symbol} {child(node.right)}" + + if isinstance(node, ast.UnaryOp): + symbol = _SYMBOL_BY_OPERATOR_TYPE[type(node.op)] + separator = " " if isinstance(node.op, ast.Not) else "" + return f"{symbol}{separator}{child(node.operand)}" + + if isinstance(node, ast.BoolOp): + symbol = _SYMBOL_BY_OPERATOR_TYPE[type(node.op)] + return f" {symbol} ".join(child(value) for value in node.values) + + if isinstance(node, ast.Compare): + parts = [child(node.left)] + for op, comparator in zip(node.ops, node.comparators, strict=True): + parts.append(_SYMBOL_BY_OPERATOR_TYPE[type(op)]) + parts.append(child(comparator)) + return " ".join(parts) + + if isinstance(node, ast.IfExp): + return f"{child(node.body)} if {child(node.test)} else {child(node.orelse)}" + + if isinstance(node, ast.Subscript): + if isinstance(node.slice, ast.Tuple): + return ( + f"{child(node.value)}" + f"[{', '.join(child(elt) for elt in node.slice.elts)}]" + ) + return f"{child(node.value)}[{child(node.slice)}]" + + if isinstance(node, (ast.Tuple, ast.List, ast.Set)): + elts = ", ".join(child(elt) for elt in node.elts) + if isinstance(node, ast.Tuple): + return f"({elts},)" if len(node.elts) == 1 else f"({elts})" + if isinstance(node, ast.List): + return f"[{elts}]" + return f"{{{elts}}}" + + if isinstance(node, ast.Dict): + items = ", ".join( + f"**{child(value)}" if key is None else f"{child(key)}: {child(value)}" + for key, value in zip(node.keys, node.values, strict=True) + ) + return f"{{{items}}}" + + if isinstance(node, ast.Assign): + return " = ".join(child(part) for part in [*node.targets, node.value]) + + if isinstance(node, ast.AnnAssign): + text = f"{child(node.target)}: {child(node.annotation)}" + return text if node.value is None else f"{text} = {child(node.value)}" + + if isinstance(node, ast.Return): + return "return" if node.value is None else f"return {child(node.value)}" + + return child(node) diff --git a/aas_core_codegen/intermediate/_translate.py b/aas_core_codegen/intermediate/_translate.py index 45809c1cb..00062f18a 100644 --- a/aas_core_codegen/intermediate/_translate.py +++ b/aas_core_codegen/intermediate/_translate.py @@ -32,7 +32,7 @@ import docutils.utils from icontract import require, ensure, snapshot -from aas_core_codegen import naming, parse +from aas_core_codegen import ast_dump, naming, parse from aas_core_codegen.common import ( Error, Identifier, @@ -2295,7 +2295,7 @@ def _to_constant_set_of_primitives( f"The literal at the index {i} of the constant set of " f"primitive values is expected to be a primitive literal. " f"However, we got: {atok.get_text(literal.node)}; " - f"in AST: {ast.dump(literal.node)}", + f"in AST: {ast_dump.dump(literal.node)}", ) ) continue @@ -3019,7 +3019,7 @@ def _fill_in_default_placeholder( return None, Error( default.parsed.node, f"The translation of the default value to the intermediate layer " - f"has not been implemented: {ast.dump(default.parsed.node)}", + f"has not been implemented: {ast_dump.dump(default.parsed.node)}", ) diff --git a/aas_core_codegen/intermediate/construction.py b/aas_core_codegen/intermediate/construction.py index d641e542f..a49c810c3 100644 --- a/aas_core_codegen/intermediate/construction.py +++ b/aas_core_codegen/intermediate/construction.py @@ -22,7 +22,7 @@ import asttokens from icontract import ensure, require, DBC -from aas_core_codegen import parse, stringify +from aas_core_codegen import ast_dump, parse, stringify from aas_core_codegen.common import ( Identifier, Error, @@ -462,7 +462,7 @@ def _understand_assignment( if_exp.orelse, f"The handling of this default value for " f"the property {target.attr!r} has not been implemented: " - f"{ast.dump(default_node)}", + f"{ast_dump.dump(default_node)}", ) else: assert isinstance(if_exp.test, ast.Compare) @@ -480,7 +480,7 @@ def _understand_assignment( return None, Error( assign, f"The handling of the constructor statement " - f"has not been implemented: {ast.dump(assign)}; " + f"has not been implemented: {ast_dump.dump(assign)}; " f"please notify the developers if you really need this feature", ) diff --git a/aas_core_codegen/parse/_rules.py b/aas_core_codegen/parse/_rules.py index f65e71d8f..fb9f3426a 100644 --- a/aas_core_codegen/parse/_rules.py +++ b/aas_core_codegen/parse/_rules.py @@ -20,7 +20,12 @@ from icontract import ensure -from aas_core_codegen.common import Identifier, Error, assert_never +from aas_core_codegen import ast_dump +from aas_core_codegen.common import ( + Identifier, + Error, + assert_never, +) from aas_core_codegen.parse import tree # noinspection PyTypeChecker @@ -129,7 +134,7 @@ def _parse_generator( return None, Error( target, f"Expected the target of the generator to be a name, " - f"but got: {ast.dump(target)}", + f"but got: {ast_dump.dump(target)}", ) our_variable, error = ast_node_to_our_node(target) @@ -227,7 +232,7 @@ def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error] return None, Error( node, f"Expected a generator expression in ``{node.func.id}``, " - f"but got: {ast.dump(node)}", + f"but got: {ast_dump.dump(node)}", ) generator_exp = node.args[0] @@ -249,7 +254,8 @@ def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error] generator = generator_exp.generators[0] if not isinstance(generator, ast.comprehension): return None, Error( - generator, f"Expected a comprehension, but got: {ast.dump(generator)}" + generator, + f"Expected a comprehension, but got: {ast_dump.dump(generator)}", ) our_generator, error = _parse_generator( @@ -334,7 +340,7 @@ def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error] node.args[1], f"Expected the second argument to ``isinstance`` to be either " f"a class name or a tuple of class names, " - f"but got: {ast.dump(node.args[1])}", + f"but got: {ast_dump.dump(node.args[1])}", ) classes: List[tree.Name] = [] @@ -343,7 +349,7 @@ def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error] return None, Error( class_node, f"Expected a class name in the second argument " - f"to ``isinstance``, but got: {ast.dump(class_node)}", + f"to ``isinstance``, but got: {ast_dump.dump(class_node)}", ) cls, error = ast_node_to_our_node(class_node) @@ -406,9 +412,10 @@ def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error] if error is not None: return None, error - assert isinstance( - member, tree.Member - ), f"Expected a member for {ast.dump(node.func)=}, but got: {member=}" + assert isinstance(member, tree.Member), ( + f"Expected a member for {ast_dump.dump(node.func)}, " + f"but got: {member=}" + ) return tree.MethodCall(member=member, args=args, original_node=node), None @@ -462,7 +469,7 @@ def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error] else: raise AssertionError( - "Unexpected execution path with node: {ast.dump(node)}" + f"Unexpected execution path with node: {ast_dump.dump(node)}" ) @@ -911,7 +918,7 @@ def transform(self, node: ast.AST) -> Tuple[Optional[tree.Node], Optional[Error] return None, Error( value_node, f"We do not know how to parse the Python ast.expr " - f"as part of the JoinedStr.values: {ast.dump(value_node)}; " + f"as part of the JoinedStr.values: {ast_dump.dump(value_node)}; " f"please notify the developers.", ) else: @@ -1653,5 +1660,5 @@ def ast_node_to_our_node(node: ast.AST) -> Tuple[Optional[tree.Node], Optional[E return None, Error( node, f"The code matched no pattern for transpilation " - f"at the parse stage: {ast.dump(node)}", + f"at the parse stage: {ast_dump.dump(node)}", ) diff --git a/aas_core_codegen/parse/_translate.py b/aas_core_codegen/parse/_translate.py index 567b4a384..1ede39093 100644 --- a/aas_core_codegen/parse/_translate.py +++ b/aas_core_codegen/parse/_translate.py @@ -33,6 +33,7 @@ from icontract import ensure, require +from aas_core_codegen import ast_dump from aas_core_codegen.common import ( Error, Identifier, @@ -393,7 +394,7 @@ def _ast_constant_string_to_description( text = constant.value assert isinstance( text, str - ), f"Expected a string constant node, but got: {ast.dump(constant)!r}" + ), f"Expected a string constant node, but got: {ast_dump.dump(constant)}" dedented = textwrap.dedent(text) @@ -629,7 +630,7 @@ def _parse_constant_set( values_arg_node, f"Expected the values of a constant set to be a list literal, " f"but got: {atok.get_text(values_arg_node)}; " - f"in AST: {ast.dump(values_arg_node)}", + f"in AST: {ast_dump.dump(values_arg_node)}", ) set_literals: List[SetLiteral] = [] @@ -640,7 +641,7 @@ def _parse_constant_set( f"Expected the values of a constant set to be all literals " f"(either an enumeration literal or a literal of a primitive type " f"such as str or int), but got at the index {i}: " - f"{atok.get_text(elt)}; in AST: {ast.dump(elt)}", + f"{atok.get_text(elt)}; in AST: {ast_dump.dump(elt)}", ) set_literals.append(SetLiteral(node=elt)) @@ -659,7 +660,7 @@ def _parse_constant_set( description_arg_node, f"Expected string literal as the ``description`` argument, " f"but got: {atok.get_text(description_arg_node)}; " - f"in AST: {ast.dump(description_arg_node)}", + f"in AST: {ast_dump.dump(description_arg_node)}", ) description, error = _ast_constant_string_to_description( @@ -685,7 +686,7 @@ def _parse_constant_set( superset_of_arg_node, f"Expected the ``superset_of`` of a constant set to be a list literal, " f"but got: {atok.get_text(superset_of_arg_node)}; " - f"in AST: {ast.dump(superset_of_arg_node)}", + f"in AST: {ast_dump.dump(superset_of_arg_node)}", ) for i, elt in enumerate(superset_of_arg_node.elts): @@ -695,7 +696,7 @@ def _parse_constant_set( f"Expected the elements of the ``superset_of`` of a constant set " f"to be a list of variables (referring to the other sets), " f"but got at index {i}: " - f"{atok.get_text(elt)}; in AST: {ast.dump(elt)}", + f"{atok.get_text(elt)}; in AST: {ast_dump.dump(elt)}", ) subsets.append(Identifier(elt.id)) @@ -1981,7 +1982,7 @@ def _class_decorator_to_serialization( Error( with_model_type_node, f"Expected the value for ``with_model_type`` parameter " - f"to be a constant, but got: {ast.dump(with_model_type_node)}", + f"to be a constant, but got: {ast_dump.dump(with_model_type_node)}", ), ) @@ -2126,7 +2127,7 @@ class inheriting from ``Enum``. return None, Error( decorator, f"Expected a name for a decorator function, " - f"but got: {ast.dump(decorator.func)}", + f"but got: {ast_dump.dump(decorator.func)}", ) if not isinstance(decorator.func.ctx, ast.Load): @@ -2150,7 +2151,7 @@ class inheriting from ``Enum``. return None, Error( decorator, f"Handling of a non-name or a non-call class decorator " - f"has not been implemented: {ast.dump(decorator)}", + f"has not been implemented: {ast_dump.dump(decorator)}", ) @@ -3898,7 +3899,7 @@ def _atok_to_symbol_table( Error( node, f"We do not know how to interpret " - f"the assignment node: {ast.dump(node)}", + f"the assignment node: {ast_dump.dump(node)}", ) ) continue @@ -3948,7 +3949,7 @@ def _atok_to_symbol_table( Error( node, f"We do not know how to parse a multi-target assignment: " - f"{atok.get_text(node)}; in AST: {ast.dump(node)}", + f"{atok.get_text(node)}; in AST: {ast_dump.dump(node)}", ) ) continue @@ -3969,7 +3970,8 @@ def _atok_to_symbol_table( if not matched: underlying_errors.append( Error( - node, f"We do not know how to parse the AST node: {ast.dump(node)}" + node, + f"We do not know how to parse the AST node: {ast_dump.dump(node)}", ) ) diff --git a/dev/test_data/intermediate/unexpected/method_definitions/non_constant_default/expected_error.txt b/dev/test_data/intermediate/unexpected/method_definitions/non_constant_default/expected_error.txt index 24c64dae6..27291ba83 100644 --- a/dev/test_data/intermediate/unexpected/method_definitions/non_constant_default/expected_error.txt +++ b/dev/test_data/intermediate/unexpected/method_definitions/non_constant_default/expected_error.txt @@ -1 +1 @@ -The translation of the default value to the intermediate layer has not been implemented: Call(func=Name(id='some_func', ctx=Load()), args=[], keywords=[]) \ No newline at end of file +The translation of the default value to the intermediate layer has not been implemented: some_func() \ No newline at end of file diff --git a/dev/test_data/parse/unexpected/annotated_assignment/with_pep_604_optional/expected_error.txt b/dev/test_data/parse/unexpected/annotated_assignment/with_pep_604_optional/expected_error.txt index 160c7e59c..e897d5f84 100644 --- a/dev/test_data/parse/unexpected/annotated_assignment/with_pep_604_optional/expected_error.txt +++ b/dev/test_data/parse/unexpected/annotated_assignment/with_pep_604_optional/expected_error.txt @@ -1 +1 @@ -The code matched no pattern for transpilation at the parse stage: BinOp(left=Name(id='int', ctx=Load()), op=BitOr(), right=Constant(value=None)) \ No newline at end of file +The code matched no pattern for transpilation at the parse stage: int | None \ No newline at end of file diff --git a/dev/test_data/parse/unexpected/class_decorators/non_name_decorator/expected_error.txt b/dev/test_data/parse/unexpected/class_decorators/non_name_decorator/expected_error.txt index 23aa1b84a..e284d8d5a 100644 --- a/dev/test_data/parse/unexpected/class_decorators/non_name_decorator/expected_error.txt +++ b/dev/test_data/parse/unexpected/class_decorators/non_name_decorator/expected_error.txt @@ -1 +1 @@ -Handling of a non-name or a non-call class decorator has not been implemented: Attribute(value=Name(id='some_module', ctx=Load()), attr='some_decorator', ctx=Load()) \ No newline at end of file +Handling of a non-name or a non-call class decorator has not been implemented: some_module.some_decorator \ No newline at end of file diff --git a/dev/test_data/parse/unexpected/for_statement/with_tuple_target/expected_error.txt b/dev/test_data/parse/unexpected/for_statement/with_tuple_target/expected_error.txt index 0d3582345..ece138321 100644 --- a/dev/test_data/parse/unexpected/for_statement/with_tuple_target/expected_error.txt +++ b/dev/test_data/parse/unexpected/for_statement/with_tuple_target/expected_error.txt @@ -1 +1 @@ -Expected the target of the generator to be a name, but got: Tuple(elts=[Name(id='number', ctx=Store()), Name(id='text', ctx=Store())], ctx=Store()) \ No newline at end of file +Expected the target of the generator to be a name, but got: (number, text) \ No newline at end of file diff --git a/dev/test_data/parse/unexpected/is_instance/member_as_class/expected_error.txt b/dev/test_data/parse/unexpected/is_instance/member_as_class/expected_error.txt index 1d432d464..b45142bf3 100644 --- a/dev/test_data/parse/unexpected/is_instance/member_as_class/expected_error.txt +++ b/dev/test_data/parse/unexpected/is_instance/member_as_class/expected_error.txt @@ -1 +1 @@ -Expected the second argument to ``isinstance`` to be either a class name or a tuple of class names, but got: Attribute(value=Name(id='self', ctx=Load()), attr='Child', ctx=Load()) \ No newline at end of file +Expected the second argument to ``isinstance`` to be either a class name or a tuple of class names, but got: self.Child \ No newline at end of file diff --git a/dev/test_data/parse/unexpected/is_instance/member_in_tuple/expected_error.txt b/dev/test_data/parse/unexpected/is_instance/member_in_tuple/expected_error.txt index 6d9f280d1..ec783c59d 100644 --- a/dev/test_data/parse/unexpected/is_instance/member_in_tuple/expected_error.txt +++ b/dev/test_data/parse/unexpected/is_instance/member_in_tuple/expected_error.txt @@ -1 +1 @@ -Expected a class name in the second argument to ``isinstance``, but got: Attribute(value=Name(id='self', ctx=Load()), attr='Another_child', ctx=Load()) \ No newline at end of file +Expected a class name in the second argument to ``isinstance``, but got: self.Another_child \ No newline at end of file diff --git a/dev/test_data/parse/unexpected/tuple/literal_with_starred_element/expected_error.txt b/dev/test_data/parse/unexpected/tuple/literal_with_starred_element/expected_error.txt index 768feb631..341a03d6a 100644 --- a/dev/test_data/parse/unexpected/tuple/literal_with_starred_element/expected_error.txt +++ b/dev/test_data/parse/unexpected/tuple/literal_with_starred_element/expected_error.txt @@ -1 +1 @@ -The code matched no pattern for transpilation at the parse stage: Starred(value=Name(id='values', ctx=Load()), ctx=Load()) \ No newline at end of file +The code matched no pattern for transpilation at the parse stage: *values \ No newline at end of file diff --git a/dev/tests/intermediate/test_constructor.py b/dev/tests/intermediate/test_constructor.py index 8c759209c..9eaaf3afb 100644 --- a/dev/tests/intermediate/test_constructor.py +++ b/dev/tests/intermediate/test_constructor.py @@ -2,7 +2,6 @@ # # SPDX-License-Identifier: MIT -import re import unittest from typing import Tuple, Optional, Sequence @@ -279,13 +278,11 @@ def __init__(self, a: int) -> None: _, error = understand_constructor_table(source=source) assert error is not None - error_str = tests.common.most_underlying_messages(error) - error_str = re.sub(r"Assign\(.*\); ", "Assign(...); ", error_str) - self.assertEqual( "The handling of the constructor statement has not been implemented: " - "Assign(...); please notify the developers if you really need this feature", - error_str, + "self.a = <+-operator>; " + "please notify the developers if you really need this feature", + tests.common.most_underlying_messages(error), ) def test_argument_and_property_name_differ(self) -> None: