diff --git a/.makim.yaml b/.makim.yaml index 28c8bf32..23e62eb3 100644 --- a/.makim.yaml +++ b/.makim.yaml @@ -38,7 +38,7 @@ groups: params: help: Specify parameters to be used for tests type: string - default: "-vv" + default: "-vv -n auto" backend: bash run: | pytest \ diff --git a/libs/astx-transpilers/src/astx_transpilers/python_string.py b/libs/astx-transpilers/src/astx_transpilers/python_string.py index 8f075490..f63723d0 100644 --- a/libs/astx-transpilers/src/astx_transpilers/python_string.py +++ b/libs/astx-transpilers/src/astx_transpilers/python_string.py @@ -277,7 +277,7 @@ def visit(self, node: astx.GeneratorExpr) -> str: @dispatch # type: ignore[no-redef] def visit(self, node: astx.Identifier) -> str: """Handle Identifier nodes.""" - return f"{node.value}" + return f"{node.name}" @dispatch # type: ignore[no-redef] def visit(self, node: astx.IfExpr) -> str: diff --git a/libs/astx-transpilers/src/astx_transpilers/python_to_ast.py b/libs/astx-transpilers/src/astx_transpilers/python_to_ast.py index 3b14a061..563b0459 100644 --- a/libs/astx-transpilers/src/astx_transpilers/python_to_ast.py +++ b/libs/astx-transpilers/src/astx_transpilers/python_to_ast.py @@ -347,8 +347,8 @@ def visit(self, node: astx.CatchHandlerStmt) -> ast.ExceptHandler: type_ = self.visit(node.types[0]) name = None if hasattr(node, "name") and node.name: - if hasattr(node.name, "value"): - name = node.name.value + if hasattr(node.name, "name"): + name = node.name.name elif isinstance(node.name, str): name = node.name else: @@ -867,9 +867,9 @@ def visit(self, node: astx.GeneratorExpr) -> ast.GeneratorExp: @dispatch # type: ignore[no-redef] def visit(self, node: astx.Identifier) -> ast.Name: """Handle Identifier nodes.""" - if not hasattr(node, "value"): + if not hasattr(node, "name"): return self._convert_using_unparse(node) - return ast.Name(id=str(node.value), ctx=ast.Load()) + return ast.Name(id=node.name, ctx=ast.Load()) @dispatch # type: ignore[no-redef] def visit(self, node: astx.IfExpr) -> ast.IfExp: diff --git a/libs/astx-transpilers/tests/test_python_string.py b/libs/astx-transpilers/tests/test_python_string.py index aaba1901..2dc8dceb 100644 --- a/libs/astx-transpilers/tests/test_python_string.py +++ b/libs/astx-transpilers/tests/test_python_string.py @@ -1188,8 +1188,8 @@ def test_transpiler_assignmentexpr() -> None: def test_transpiler_delete_stmt() -> None: """Test astx.DeleteStmt transpilation.""" # Create identifiers to be deleted - var1 = astx.Identifier(value="x") - var2 = astx.Identifier(value="y") + var1 = astx.Identifier(name="x") + var2 = astx.Identifier(name="y") # Create a DeleteStmt with multiple targets delete_stmt = astx.DeleteStmt(value=[var1, var2]) diff --git a/libs/astx-transpilers/tests/test_python_to_ast.py b/libs/astx-transpilers/tests/test_python_to_ast.py index fbce7064..e4e0a8db 100644 --- a/libs/astx-transpilers/tests/test_python_to_ast.py +++ b/libs/astx-transpilers/tests/test_python_to_ast.py @@ -492,7 +492,7 @@ def test_for_count_loop_stmt_simple(self) -> None: comparators=[astx.LiteralInt32(value=10)], ) update = astx.AugAssign( - target=astx.Identifier(value="i"), + target=astx.Identifier(name="i"), value=astx.LiteralInt32(value=1), op_code="+=", ) @@ -684,12 +684,12 @@ def setup_method(self) -> None: def test_catch_handler_stmt_simple(self) -> None: """Test astx.CatchHandlerStmt with exception type.""" - exception_type = astx.Identifier(value="Exception") + exception_type = astx.Identifier(name="Exception") body_stmt = astx.BreakStmt() body = astx.Block() body.append(body_stmt) node = astx.CatchHandlerStmt( - types=[exception_type], name=astx.Identifier(value="e"), body=body + types=[exception_type], name=astx.Identifier(name="e"), body=body ) result = self.transpiler.visit(node) assert isinstance(result, ast.ExceptHandler) @@ -701,8 +701,8 @@ def test_exception_handler_stmt_simple(self) -> None: body = astx.Block() body.append(body_stmt) handler = astx.CatchHandlerStmt( - types=[astx.Identifier(value="Exception")], - name=astx.Identifier(value="e"), + types=[astx.Identifier(name="Exception")], + name=astx.Identifier(name="e"), body=body, ) node = astx.ExceptionHandlerStmt(body=body, handlers=[handler]) @@ -1051,7 +1051,7 @@ def test_and_op_simple(self) -> None: def test_aug_assign_add(self) -> None: """Test astx.AugAssign with addition.""" - target = astx.Identifier(value="x") + target = astx.Identifier(name="x") value = astx.LiteralInt32(value=5) node = astx.AugAssign(target=target, value=value, op_code="+=") result = self.transpiler.visit(node) @@ -1226,7 +1226,7 @@ def test_block_simple(self) -> None: def test_delete_stmt_simple(self) -> None: """Test astx.DeleteStmt with variable.""" - target = astx.Identifier(value="x") + target = astx.Identifier(name="x") node = astx.DeleteStmt(value=[target]) result = self.transpiler.visit(node) assert isinstance(result, ast.Delete) @@ -1247,7 +1247,7 @@ def test_ellipsis_simple(self) -> None: def test_identifier_simple(self) -> None: """Test astx.Identifier with simple value.""" - node = astx.Identifier(value="my_id") + node = astx.Identifier(name="my_id") result = self.transpiler.visit(node) assert isinstance(result, ast.Name) assert result.id == "my_id" @@ -1412,7 +1412,7 @@ def setup_method(self) -> None: def test_assignment_expr_single_target(self) -> None: """Test astx.AssignmentExpr with single target.""" - target = astx.Identifier(value="x") + target = astx.Identifier(name="x") value = astx.LiteralInt32(value=42) node = astx.AssignmentExpr(targets=[target], value=value) result = self.transpiler.visit(node) diff --git a/libs/astx/src/astx/__init__.py b/libs/astx/src/astx/__init__.py index 0d5e5fe9..93d3fc5e 100644 --- a/libs/astx/src/astx/__init__.py +++ b/libs/astx/src/astx/__init__.py @@ -7,13 +7,13 @@ base, blocks, callables, + data, flows, literals, mixes, packages, symbol_table, types, - variables, ) from astx.base import ( AST, @@ -22,7 +22,6 @@ DataType, Expr, ExprType, - Identifier, OperatorType, ParenthesizedExpr, SourceLocation, @@ -60,6 +59,13 @@ ListComprehension, SetComprehension, ) +from astx.data import ( + DeleteStmt, + Identifier, + InlineVariableDeclaration, + Variable, + VariableDeclaration, +) from astx.exceptions import ( CatchHandlerStmt, ExceptionHandlerStmt, @@ -197,12 +203,6 @@ XnorOp, XorOp, ) -from astx.variables import ( - DeleteStmt, - InlineVariableDeclaration, - Variable, - VariableDeclaration, -) def get_version() -> str: @@ -375,6 +375,7 @@ def get_version() -> str: "base", "blocks", "callables", + "data", "datatypes", "flows", "get_version", @@ -383,7 +384,6 @@ def get_version() -> str: "packages", "symbol_table", "types", - "variables", ] diff --git a/libs/astx/src/astx/base.py b/libs/astx/src/astx/base.py index 04b36373..9d4efd08 100644 --- a/libs/astx/src/astx/base.py +++ b/libs/astx/src/astx/base.py @@ -386,29 +386,6 @@ class Expr(AST): nbytes: int = 0 -@public -@typechecked -class Identifier(Expr): - """AST class for identifiers.""" - - value: str - - def __init__( - self, - value: str, - loc: SourceLocation = NO_SOURCE_LOCATION, - parent: Optional[ASTNodes] = None, - ) -> None: - """Initialize the Identifier instance.""" - super().__init__(loc=loc, parent=parent) - self.value = value - - def get_struct(self, simplified: bool = False) -> ReprStruct: - """Return a structure that represents the Identifier object.""" - key = f"IDENTIFIER[{self.value}]" - return self._prepare_struct(key, self.value, simplified) - - @public @typechecked class ExprType(Expr): @@ -465,12 +442,11 @@ def __init__( loc: SourceLocation = NO_SOURCE_LOCATION, parent: Optional[ASTNodes] = None, ) -> None: - super().__init__(loc) + super().__init__(loc=loc, parent=parent) self.name = f"temp_{DataType._tmp_id}" DataType._tmp_id += 1 # set it as a generic data type self.type_: ExprType = ExprType() - self.parent = parent def __str__(self) -> str: """Return an string that represents the object.""" diff --git a/libs/astx/src/astx/callables.py b/libs/astx/src/astx/callables.py index 5dd01df1..99acaded 100644 --- a/libs/astx/src/astx/callables.py +++ b/libs/astx/src/astx/callables.py @@ -18,10 +18,10 @@ Undefined, ) from astx.blocks import Block +from astx.data import Variable from astx.modifiers import MutabilityKind, ScopeKind, VisibilityKind from astx.tools.typing import typechecked from astx.types import AnyType -from astx.variables import Variable UNDEFINED = Undefined() diff --git a/libs/astx/src/astx/classes.py b/libs/astx/src/astx/classes.py index 1e0aeb47..49372e24 100644 --- a/libs/astx/src/astx/classes.py +++ b/libs/astx/src/astx/classes.py @@ -20,9 +20,9 @@ ) from astx.blocks import Block from astx.callables import FunctionDef +from astx.data import VariableDeclaration from astx.modifiers import VisibilityKind from astx.tools.typing import typechecked -from astx.variables import VariableDeclaration @public diff --git a/libs/astx/src/astx/context_manager.py b/libs/astx/src/astx/context_manager.py index b28d5f18..2713f7d3 100644 --- a/libs/astx/src/astx/context_manager.py +++ b/libs/astx/src/astx/context_manager.py @@ -12,12 +12,12 @@ ASTNodes, DataTypesStruct, Expr, - Identifier, ReprStruct, SourceLocation, StatementType, ) from astx.blocks import Block +from astx.data import Identifier @public diff --git a/libs/astx/src/astx/variables.py b/libs/astx/src/astx/data.py similarity index 87% rename from libs/astx/src/astx/variables.py rename to libs/astx/src/astx/data.py index d4580797..094e0d47 100644 --- a/libs/astx/src/astx/variables.py +++ b/libs/astx/src/astx/data.py @@ -12,7 +12,6 @@ ASTNodes, DataType, Expr, - Identifier, ReprStruct, SourceLocation, StatementType, @@ -120,8 +119,8 @@ def get_struct(self, simplified: bool = False) -> ReprStruct: @public @typechecked -class Variable(DataTypeOps): - """AST class for the variable usage.""" +class Identifier(DataTypeOps): + """AST class for identifiers.""" name: str type_: DataType = AnyType() @@ -129,24 +128,40 @@ class Variable(DataTypeOps): def __init__( self, name: str, - type_: DataType = AnyType(), loc: SourceLocation = NO_SOURCE_LOCATION, parent: Optional[ASTNodes] = None, ) -> None: - """Initialize the Variable instance.""" + """Initialize the Identifier instance.""" super().__init__(loc=loc, parent=parent) self.name = name - self.type_ = type_ + # note: necessary for data operations + self.type_ = AnyType() def __str__(self) -> str: """Return a string that represents the object.""" - return f"Variable[{self.name}]" + return f"{self.__class__.__name__}[{self.name}]" def get_struct(self, simplified: bool = False) -> ReprStruct: - """Return the AST structure of the object.""" - key = f"Variable[{self.name}]" - value = self.name - return self._prepare_struct(key, value, simplified) + """Return a structure that represents the Identifier object.""" + key = f"{self.__class__.__name__.upper()}[{self.name}]" + return self._prepare_struct(key, self.name, simplified) + + +@public +@typechecked +class Variable(Identifier): + """AST class for the variable usage.""" + + def __init__( + self, + name: str, + type_: DataType = AnyType(), + loc: SourceLocation = NO_SOURCE_LOCATION, + parent: Optional[ASTNodes] = None, + ) -> None: + """Initialize the Variable instance.""" + super().__init__(name=name, loc=loc, parent=parent) + self.type_ = type_ class DeleteStmt(StatementType): diff --git a/libs/astx/src/astx/exceptions.py b/libs/astx/src/astx/exceptions.py index e5e951f1..9d788d1c 100644 --- a/libs/astx/src/astx/exceptions.py +++ b/libs/astx/src/astx/exceptions.py @@ -13,12 +13,12 @@ ASTNodes, DictDataTypesStruct, Expr, - Identifier, ReprStruct, SourceLocation, StatementType, ) from astx.blocks import Block +from astx.data import Identifier from astx.tools.typing import typechecked diff --git a/libs/astx/src/astx/flows.py b/libs/astx/src/astx/flows.py index c109e262..ef454852 100644 --- a/libs/astx/src/astx/flows.py +++ b/libs/astx/src/astx/flows.py @@ -12,14 +12,13 @@ ASTNodes, DictDataTypesStruct, Expr, - Identifier, ReprStruct, SourceLocation, StatementType, ) from astx.blocks import Block +from astx.data import Identifier, InlineVariableDeclaration from astx.tools.typing import typechecked -from astx.variables import InlineVariableDeclaration @public @@ -734,11 +733,11 @@ def __init__( def __str__(self) -> str: """Return a string representation of the object.""" - return f"Goto[{self.label.value}]" + return f"Goto[{self.label.name}]" def get_struct(self, simplified: bool = False) -> ReprStruct: """Return the AST structure of the object.""" - key = f"GOTO-STMT[{self.label.value}]" + key = f"GOTO-STMT[{self.label.name}]" value: DictDataTypesStruct = {} return self._prepare_struct(key, value, simplified) diff --git a/libs/astx/src/astx/mixes.py b/libs/astx/src/astx/mixes.py index 83823ce9..cb561657 100644 --- a/libs/astx/src/astx/mixes.py +++ b/libs/astx/src/astx/mixes.py @@ -9,7 +9,7 @@ from astx.base import DataType from astx.callables import FunctionDef -from astx.variables import Variable +from astx.data import Variable __all__ = ["NamedExpr"] diff --git a/libs/astx/src/astx/operators.py b/libs/astx/src/astx/operators.py index 190ca80c..01b63656 100644 --- a/libs/astx/src/astx/operators.py +++ b/libs/astx/src/astx/operators.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Iterable, Literal, Optional, cast +from typing import TYPE_CHECKING, Iterable, Literal, Optional, cast from public import public from typing_extensions import TypeAlias @@ -14,13 +14,15 @@ DataType, DictDataTypesStruct, Expr, - Identifier, ReprStruct, SourceLocation, StatementType, ) +from astx.data import Variable from astx.tools.typing import typechecked -from astx.variables import Variable + +if TYPE_CHECKING: + from astx.data import Identifier @public diff --git a/libs/astx/tests/datatypes/test_boolean.py b/libs/astx/tests/datatypes/test_boolean.py index 6899f0c8..84ab579e 100644 --- a/libs/astx/tests/datatypes/test_boolean.py +++ b/libs/astx/tests/datatypes/test_boolean.py @@ -1,8 +1,8 @@ """Tests for Boolean data type.""" +from astx.data import VariableDeclaration from astx.literals.boolean import LiteralBoolean from astx.types.boolean import Boolean -from astx.variables import VariableDeclaration def test_variable_boolean() -> None: diff --git a/libs/astx/tests/datatypes/test_char_string.py b/libs/astx/tests/datatypes/test_char_string.py index e6d32753..3204439b 100644 --- a/libs/astx/tests/datatypes/test_char_string.py +++ b/libs/astx/tests/datatypes/test_char_string.py @@ -7,8 +7,8 @@ import astx import pytest +from astx.data import Variable from astx.types.operators import BinaryOp, UnaryOp -from astx.variables import Variable VAR_A = Variable("a") diff --git a/libs/astx/tests/datatypes/test_complex.py b/libs/astx/tests/datatypes/test_complex.py index c0e3028b..4dabf0fa 100644 --- a/libs/astx/tests/datatypes/test_complex.py +++ b/libs/astx/tests/datatypes/test_complex.py @@ -7,8 +7,8 @@ import astx import pytest +from astx.data import Variable from astx.types.operators import BinaryOp, UnaryOp -from astx.variables import Variable VAR_A = Variable("a") diff --git a/libs/astx/tests/datatypes/test_date_time.py b/libs/astx/tests/datatypes/test_date_time.py index 773b69aa..a1777fd2 100644 --- a/libs/astx/tests/datatypes/test_date_time.py +++ b/libs/astx/tests/datatypes/test_date_time.py @@ -7,6 +7,7 @@ import astx import pytest +from astx.data import Variable from astx.literals.temporal import ( LiteralDate, LiteralDateTime, @@ -14,7 +15,6 @@ LiteralTimestamp, ) from astx.types.operators import BinaryOp, UnaryOp -from astx.variables import Variable VAR_A = Variable("a") diff --git a/libs/astx/tests/datatypes/test_float.py b/libs/astx/tests/datatypes/test_float.py index e97eef1c..a8b1dcb1 100644 --- a/libs/astx/tests/datatypes/test_float.py +++ b/libs/astx/tests/datatypes/test_float.py @@ -7,8 +7,8 @@ import astx import pytest +from astx.data import Variable from astx.types.operators import BinaryOp, UnaryOp -from astx.variables import Variable VAR_A = Variable("a") diff --git a/libs/astx/tests/datatypes/test_integer.py b/libs/astx/tests/datatypes/test_integer.py index ae14f5ba..c12b2e94 100644 --- a/libs/astx/tests/datatypes/test_integer.py +++ b/libs/astx/tests/datatypes/test_integer.py @@ -7,8 +7,8 @@ import astx import pytest +from astx.data import Variable from astx.types.operators import BinaryOp, UnaryOp -from astx.variables import Variable VAR_A = Variable("a") diff --git a/libs/astx/tests/datatypes/test_operators.py b/libs/astx/tests/datatypes/test_operators.py index c0f158f8..710f821b 100644 --- a/libs/astx/tests/datatypes/test_operators.py +++ b/libs/astx/tests/datatypes/test_operators.py @@ -3,10 +3,10 @@ import pytest from astx.base import ASTKind +from astx.data import Variable from astx.literals.numeric import LiteralInt32 from astx.operators import CompareOp, WalrusOp from astx.types.operators import BinaryOp, UnaryOp -from astx.variables import Variable EXPECTED_COMPARATORS_LENGTH = 2 diff --git a/libs/astx/tests/datatypes/test_ttypes.py b/libs/astx/tests/datatypes/test_ttypes.py index 060a225b..6d56ee4f 100644 --- a/libs/astx/tests/datatypes/test_ttypes.py +++ b/libs/astx/tests/datatypes/test_ttypes.py @@ -3,6 +3,7 @@ import pytest from astx.base import DataType +from astx.data import Variable from astx.types.ttypes import ( t_boolean, t_complex, @@ -36,7 +37,6 @@ t_utf8_char, t_utf8_string, ) -from astx.variables import Variable ttypes = [ t_boolean, diff --git a/libs/astx/tests/datatypes/test_types.py b/libs/astx/tests/datatypes/test_types.py index e0621a73..5ee2797c 100644 --- a/libs/astx/tests/datatypes/test_types.py +++ b/libs/astx/tests/datatypes/test_types.py @@ -2,9 +2,9 @@ from __future__ import annotations +from astx.data import Variable from astx.types.casting import TypeCastExpr from astx.types.numeric import Int32 -from astx.variables import Variable from astx.viz import visualize_image diff --git a/libs/astx/tests/test_base.py b/libs/astx/tests/test_base.py index 40f62f1b..302ba4b0 100644 --- a/libs/astx/tests/test_base.py +++ b/libs/astx/tests/test_base.py @@ -77,14 +77,14 @@ def test_data_type() -> None: def test_identifier_creation() -> None: """Test basic identifier creation.""" ident = astx.Identifier("test_var") - assert ident.value == "test_var" + assert ident.name == "test_var" def test_identifier_with_location() -> None: """Test identifier with location.""" loc = astx.SourceLocation(1, COLUMN_NUMBER) ident_with_loc = astx.Identifier("var2", loc=loc) - assert ident_with_loc.value == "var2" + assert ident_with_loc.name == "var2" assert ident_with_loc.loc.line == 1 assert ident_with_loc.loc.col == COLUMN_NUMBER diff --git a/libs/astx/tests/test_blocks.py b/libs/astx/tests/test_blocks.py index 6612344b..3ce8eb8c 100644 --- a/libs/astx/tests/test_blocks.py +++ b/libs/astx/tests/test_blocks.py @@ -1,10 +1,10 @@ """Module for testing different kind of ASTx blocks.""" from astx.blocks import Block +from astx.data import Variable, VariableDeclaration from astx.literals.numeric import LiteralInt32 from astx.types.numeric import Int32 from astx.types.operators import BinaryOp -from astx.variables import Variable, VariableDeclaration def test_block() -> None: diff --git a/libs/astx/tests/test_callables.py b/libs/astx/tests/test_callables.py index 315e4c80..722caa84 100644 --- a/libs/astx/tests/test_callables.py +++ b/libs/astx/tests/test_callables.py @@ -17,12 +17,12 @@ YieldFromExpr, YieldStmt, ) +from astx.data import InlineVariableDeclaration, Variable from astx.flows import WhileStmt from astx.literals.numeric import LiteralInt32 from astx.modifiers import ScopeKind, VisibilityKind from astx.types.numeric import Int32 from astx.types.operators import BinaryOp, UnaryOp -from astx.variables import InlineVariableDeclaration, Variable from astx.viz import visualize_image diff --git a/libs/astx/tests/test_classes.py b/libs/astx/tests/test_classes.py index debce1c5..fb2774b2 100644 --- a/libs/astx/tests/test_classes.py +++ b/libs/astx/tests/test_classes.py @@ -10,9 +10,9 @@ StructDeclStmt, StructDefStmt, ) +from astx.data import Variable, VariableDeclaration from astx.literals import LiteralInt32 from astx.types.base import AnyType -from astx.variables import Variable, VariableDeclaration from astx.viz import visualize_image diff --git a/libs/astx/tests/test_context_manager.py b/libs/astx/tests/test_context_manager.py index 464bf001..7260f8e3 100644 --- a/libs/astx/tests/test_context_manager.py +++ b/libs/astx/tests/test_context_manager.py @@ -6,10 +6,10 @@ from astx.base import ( ASTKind, Expr, - Identifier, ) from astx.blocks import Block from astx.context_manager import WithItem, WithStmt +from astx.data import Identifier # Fixtures diff --git a/libs/astx/tests/test_exceptions.py b/libs/astx/tests/test_exceptions.py index 7a4b3a47..5f789051 100644 --- a/libs/astx/tests/test_exceptions.py +++ b/libs/astx/tests/test_exceptions.py @@ -1,6 +1,5 @@ """Tests for exceptions classes.""" -from astx.base import Identifier from astx.blocks import Block from astx.callables import ( Argument, @@ -9,6 +8,7 @@ FunctionDef, FunctionPrototype, ) +from astx.data import Identifier from astx.exceptions import ( CatchHandlerStmt, ExceptionHandlerStmt, diff --git a/libs/astx/tests/test_flows.py b/libs/astx/tests/test_flows.py index 5030b523..bd71d90e 100644 --- a/libs/astx/tests/test_flows.py +++ b/libs/astx/tests/test_flows.py @@ -7,6 +7,7 @@ from astx.base import ReprStruct, SourceLocation from astx.blocks import Block +from astx.data import InlineVariableDeclaration, Variable from astx.flows import ( AsyncForRangeLoopExpr, AsyncForRangeLoopStmt, @@ -29,7 +30,6 @@ from astx.literals.numeric import LiteralInt32 from astx.types.numeric import Int32 from astx.types.operators import BinaryOp, UnaryOp -from astx.variables import InlineVariableDeclaration, Variable from astx.viz import visualize_image diff --git a/libs/astx/tests/test_operators.py b/libs/astx/tests/test_operators.py index 1efd30d8..5e464aab 100644 --- a/libs/astx/tests/test_operators.py +++ b/libs/astx/tests/test_operators.py @@ -3,7 +3,8 @@ import astx import pytest -from astx.base import ASTKind, Identifier +from astx.base import ASTKind +from astx.data import Identifier, Variable from astx.literals.numeric import LiteralInt32 from astx.operators import ( AssignmentExpr, @@ -11,7 +12,6 @@ OpCodeAugAssign, VariableAssignment, ) -from astx.variables import Variable from astx.viz import visualize_image @@ -144,7 +144,7 @@ def test_not_op() -> None: ) def test_aug_assign_operations(operator: OpCodeAugAssign, value: int) -> None: """Test all augmented assignment operators using parametrize.""" - var_x = astx.Identifier(value="x") + var_x = astx.Identifier(name="x") literal_value = LiteralInt32(value) aug_assign = AugAssign(var_x, operator, literal_value) diff --git a/libs/astx/tests/test_packages.py b/libs/astx/tests/test_packages.py index d1666719..b685b934 100644 --- a/libs/astx/tests/test_packages.py +++ b/libs/astx/tests/test_packages.py @@ -1,5 +1,6 @@ """Module for testing different kind of ASTx blocks.""" +from astx.data import Variable, VariableDeclaration from astx.literals.numeric import LiteralInt32 from astx.packages import ( AliasExpr, @@ -14,7 +15,6 @@ ) from astx.types.numeric import Int32 from astx.types.operators import BinaryOp -from astx.variables import Variable, VariableDeclaration from astx.viz import visualize_image diff --git a/libs/astx/tests/test_subscript.py b/libs/astx/tests/test_subscript.py index 0fb18c8e..4ead2c6f 100644 --- a/libs/astx/tests/test_subscript.py +++ b/libs/astx/tests/test_subscript.py @@ -3,9 +3,9 @@ from typing import cast from astx.base import ASTKind, DictDataTypesStruct +from astx.data import Variable from astx.literals import LiteralInt32 from astx.subscript import Ellipsis, SubscriptExpr -from astx.variables import Variable from astx.viz import visualize_image diff --git a/libs/astx/tests/test_variables.py b/libs/astx/tests/test_variables.py index 88abf935..40e58a88 100644 --- a/libs/astx/tests/test_variables.py +++ b/libs/astx/tests/test_variables.py @@ -79,8 +79,8 @@ def test_arguments() -> None: def test_delete_stmt() -> None: """Test DeleteStmt creation and properties.""" - var1 = astx.Identifier(value="x") - var2 = astx.Identifier(value="y") + var1 = astx.Identifier(name="x") + var2 = astx.Identifier(name="y") # Create a DeleteStmt with multiple values delete_stmt = astx.DeleteStmt(value=[var1, var2]) diff --git a/libs/astx/tests/test_viz.py b/libs/astx/tests/test_viz.py index 05baddb4..05391061 100644 --- a/libs/astx/tests/test_viz.py +++ b/libs/astx/tests/test_viz.py @@ -1,10 +1,10 @@ """Tests visualization methods.""" from astx.blocks import Block +from astx.data import Variable, VariableDeclaration from astx.literals.numeric import LiteralInt32 from astx.types.numeric import Int32 from astx.types.operators import BinaryOp -from astx.variables import Variable, VariableDeclaration from astx.viz import visualize_ascii diff --git a/poetry.lock b/poetry.lock index 15e47ce6..8dc0bc06 100644 --- a/poetry.lock +++ b/poetry.lock @@ -943,6 +943,21 @@ typing-extensions = {version = ">=4.6.0", markers = "python_version < \"3.13\""} [package.extras] test = ["pytest (>=6)"] +[[package]] +name = "execnet" +version = "2.1.1" +description = "execnet: rapid multi-Python deployment" +optional = false +python-versions = ">=3.8" +groups = ["dev"] +files = [ + {file = "execnet-2.1.1-py3-none-any.whl", hash = "sha256:26dee51f1b80cebd6d0ca8e74dd8745419761d3bef34163928cbebbdc4749fdc"}, + {file = "execnet-2.1.1.tar.gz", hash = "sha256:5189b52c6121c24feae288166ab41b32549c7e2348652736540b9e6e7d4e72e3"}, +] + +[package.extras] +testing = ["hatch", "pre-commit", "pytest", "tox"] + [[package]] name = "executing" version = "2.2.0" @@ -2963,6 +2978,27 @@ pytest = ">=6.2.5" [package.extras] testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"] +[[package]] +name = "pytest-xdist" +version = "3.8.0" +description = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs" +optional = false +python-versions = ">=3.9" +groups = ["dev"] +files = [ + {file = "pytest_xdist-3.8.0-py3-none-any.whl", hash = "sha256:202ca578cfeb7370784a8c33d6d05bc6e13b4f25b5053c30a152269fd10f0b88"}, + {file = "pytest_xdist-3.8.0.tar.gz", hash = "sha256:7e578125ec9bc6050861aa93f2d59f1d8d085595d6551c2c90b6f4fad8d3a9f1"}, +] + +[package.dependencies] +execnet = ">=2.1" +pytest = ">=7.0.0" + +[package.extras] +psutil = ["psutil (>=3.0)"] +setproctitle = ["setproctitle"] +testing = ["filelock"] + [[package]] name = "python-dateutil" version = "2.9.0.post0" @@ -4386,4 +4422,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = ">=3.9,<4" -content-hash = "2f4f36090800c8ffc401940ed539515e63b55b0863370ad0f55668f69b4863d6" +content-hash = "13542dca55e38bb8ccb055563bdc6057c48bef25bdf047ae33193ae6ac99fa52" diff --git a/pyproject.toml b/pyproject.toml index fe89fe03..16dde1c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,6 +47,7 @@ mkdocs-gen-files = ">=0.5.0" types-requests = ">=2.31.0.20240406" # note: https://github.com/pypa/virtualenv/issues/2944 virtualenv = "<20.33.0" +pytest-xdist = "^3.8.0" [build-system] requires = ["poetry-core>=2"]