diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 7dcb14a819..5d8e1ebaa5 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -77,7 +77,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.10', '3.13'] + python-version: ['3.9', '3.13'] steps: - uses: actions/checkout@v4 with: @@ -121,12 +121,12 @@ jobs: # Jupyter notebooks are out-of-date # ( make -C tutorial/notebooks notebook ) - name: Test with pytest - if: ${{ !(matrix.python-version == '3.10') }} + if: ${{ !(matrix.python-version == '3.9') }} run: | locale pytest -n auto --cov=psyclone --cov-report=xml src/psyclone/tests - name: Test with pytest and C Locale - if: ${{ matrix.python-version == '3.10' }} + if: ${{ matrix.python-version == '3.9' }} run: | locale pytest -n auto --cov=psyclone --cov-report=xml src/psyclone/tests diff --git a/src/psyclone/psyir/frontend/fparser2.py b/src/psyclone/psyir/frontend/fparser2.py index d95d520820..a8af08d570 100644 --- a/src/psyclone/psyir/frontend/fparser2.py +++ b/src/psyclone/psyir/frontend/fparser2.py @@ -44,7 +44,7 @@ from dataclasses import dataclass, field import os import sys -from typing import Iterable +from typing import Iterable, Optional from fparser.common.readfortran import FortranStringReader from fparser.two import C99Preprocessor, Fortran2003, utils @@ -974,9 +974,9 @@ class SelectTypeInfo: 'class default' clauses, or -1 if no default clause is found. """ - guard_type: list[str | None] = field(default_factory=list) - guard_type_name: list[str | None] = field(default_factory=list) - intrinsic_type_name: list[str | None] = field(default_factory=list) + guard_type: list[Optional[str]] = field(default_factory=list) + guard_type_name: list[Optional[str]] = field(default_factory=list) + intrinsic_type_name: list[Optional[str]] = field(default_factory=list) clause_type: list[str] = field(default_factory=list) stmts: list[list[StmtBase]] = field(default_factory=list) selector: str = "" diff --git a/src/psyclone/psyir/symbols/datatypes.py b/src/psyclone/psyir/symbols/datatypes.py index 4696d16104..94ff9127cd 100644 --- a/src/psyclone/psyir/symbols/datatypes.py +++ b/src/psyclone/psyir/symbols/datatypes.py @@ -43,7 +43,7 @@ from collections import OrderedDict from dataclasses import dataclass from enum import Enum -from typing import Any +from typing import Any, Optional, Union from psyclone.configuration import Config from psyclone.errors import InternalError @@ -109,7 +109,7 @@ def reference_accesses(self): return VariablesAccessMap() @property - def is_allocatable(self) -> bool | None: + def is_allocatable(self) -> Optional[bool]: ''' :returns: whether this DataType is allocatable. In the base class set this to be always False.''' @@ -124,7 +124,7 @@ def __str__(self): return "UnresolvedType" @property - def is_allocatable(self) -> bool | None: + def is_allocatable(self) -> Optional[bool]: ''' :returns: whether this DataType is allocatable. In case of an UnresolvedType we don't know.''' @@ -354,7 +354,7 @@ def reference_accesses(self): return access_info @property - def is_allocatable(self) -> bool | None: + def is_allocatable(self) -> Optional[bool]: '''If we have enough information in the partial_datatype, determines whether this data type is allocatable or not. If it is unknown, it will return None. Note that atm PSyclone @@ -1101,7 +1101,7 @@ class ComponentType(CommentableMixin): :type initial_value: Optional[:py:class:`psyclone.psyir.nodes.Node`] ''' name: str - datatype: DataType | DataTypeSymbol + datatype: Union[DataType, DataTypeSymbol] visibility: Symbol.Visibility initial_value: Any diff --git a/src/psyclone/tests/psyir/transformations/transformations_test.py b/src/psyclone/tests/psyir/transformations/transformations_test.py index 22b7d6454a..f743399e92 100644 --- a/src/psyclone/tests/psyir/transformations/transformations_test.py +++ b/src/psyclone/tests/psyir/transformations/transformations_test.py @@ -40,6 +40,7 @@ API-agnostic tests for various transformation classes. ''' +import sys import os import pytest from fparser.common.readfortran import FortranStringReader @@ -590,11 +591,16 @@ def test_omploop_trans_new_options(sample_psyir): with pytest.raises(TypeError) as excinfo: omplooptrans.apply(tree.walk(Loop)[0], collapse="x") - assert ("'OMPLoopTrans' received options with the wrong types:\n" - "'collapse' option expects type 'int | bool' but " - "received 'x' of type 'str'.\n" - "Please see the documentation and check the provided types." - in str(excinfo.value)) + if sys.version_info >= (3, 10): + assert ("'OMPLoopTrans' received options with the wrong types:\n" + "'collapse' option expects type 'int | bool' but " + "received 'x' of type 'str'.\n" + "Please see the documentation and check the provided types." + in str(excinfo.value)) + else: + assert ("The 'collapse' argument must be an integer or a bool but got" + " an object of type " + in str(excinfo.value)) def test_omplooptrans_apply_nowait(fortran_reader, fortran_writer):