Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@ jobs:
# - run: cd doc; make doctest
build:
if: ${{ github.repository != 'stfc/PSyclone-mirror' }}
# TODO 2837: Switch to ubuntu-latest once Python 3.7 support is removed.
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.13]
python-version: ['3.10', '3.13']
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -99,9 +98,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Some of the examples use Jupyter. We need to keep IPython to
# below 8.0 as we still run the test suite with Python 3.7.
pip install "ipython>=7.0,<8.0" jupyter
# Some of the examples use Jupyter.
pip install jupyter
# We need to install sphinx to get correct doc testing
# Uncomment the below to use the submodule version of fparser rather
# than the latest release from pypi.
Expand All @@ -123,12 +121,12 @@ jobs:
# Jupyter notebooks are out-of-date
# ( make -C tutorial/notebooks notebook )
- name: Test with pytest
if: ${{ !(matrix.python-version == 3.8) }}
if: ${{ !(matrix.python-version == '3.10') }}
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.8 }}
if: ${{ matrix.python-version == '3.10' }}
run: |
locale
pytest -n auto --cov=psyclone --cov-report=xml src/psyclone/tests
Expand Down
3 changes: 3 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
42) PR #3034 for #2837. Updates the supported versions of Python used in
the test suite to 3.10 and 3.13.

41) PR #3013 for #2856. Makes 'intrinsics available on device'
configurable.

Expand Down
4 changes: 2 additions & 2 deletions doc/developer_guide/working_practises.rst
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,13 @@ computational cost (so that we 'fail fast'):
3. All links within the Sphinx documentation (rst files) are checked (see
note below);

4. All of the examples are tested (for Python versions 3.7, 3.8 and 3.13)
4. All of the examples are tested (for Python versions 3.10 and 3.13)
using the ``Makefile`` in the ``examples`` directory. No compilation is
performed; only the ``transform`` (performs the PSyclone transformations)
and ``notebook`` (runs the various Jupyter notebooks) targets are used.
The ``transform`` target is run 2-way parallel (``-j 2``).

5. The full test suite is run for Python versions 3.7, 3.8 and 3.13 but
5. The full test suite is run for Python versions 3.10 and 3.13 but
without the compilation checks. ``pytest`` is passed the ``-n auto`` flag
so that it will run the tests in parallel on as many cores as are
available (currently 2 on GHA instances).
Expand Down
10 changes: 2 additions & 8 deletions src/psyclone/docstring_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,8 @@ def create_docstring_data(args: List[str], desc: str,
# pylint: disable=import-outside-toplevel
from sphinx.util.typing import stringify_annotation
except ImportError:
# Fix for Python-3.7 where sphinx didn't yet rename this.
# TODO 2837: Can remove this 3.7 sphinx import
try:
# pylint: disable=import-outside-toplevel
from sphinx.util.typing import stringify as stringify_annotation
except ImportError:
# pylint: disable=import-outside-toplevel
from psyclone.utils import stringify_annotation
# pylint: disable=import-outside-toplevel
from psyclone.utils import stringify_annotation
# If its a param then we can create an ArgumentData for this.
if args[0] == "param":
if len(args) == 2:
Expand Down
14 changes: 4 additions & 10 deletions src/psyclone/psyGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,8 @@
try:
from sphinx.util.typing import stringify_annotation
except ImportError:
# Fix for Python-3.7 where sphinx didn't yet rename this.
# TODO 2837: Can remove this 3.7 sphinx import
try:
from sphinx.util.typing import stringify as stringify_annotation
# Igoring coverage from the no sphinx workaround as too difficult to do
except ImportError:
from psyclone.utils import stringify_annotation
# No Sphinx available so use our own, simpler version.
from psyclone.utils import stringify_annotation

from psyclone.configuration import Config, LFRIC_API_NAMES, GOCEAN_API_NAMES
from psyclone.core import AccessType, VariablesAccessMap
Expand Down Expand Up @@ -2884,9 +2879,8 @@ def validate_options(self, **kwargs):
kwargs[option], valid_options[option].type):
wrong_types[option] = type(kwargs[option]).__name__
except TypeError:
# For older versions of Python, such as 3.8 they don't yet
# support type checking for Generics, e.g. Union[...] so
# we skip this check and it needs to be done in the
# Type checking for Generics, e.g. Union[...], doesn't
# work so we skip this check - it is done in the
# relevant function instead.
pass

Expand Down
15 changes: 6 additions & 9 deletions src/psyclone/psyir/frontend/fparser2.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from dataclasses import dataclass, field
import os
import sys
from typing import Optional, List, Iterable
from typing import Iterable

from fparser.common.readfortran import FortranStringReader
from fparser.two import C99Preprocessor, Fortran2003, utils
Expand Down Expand Up @@ -974,14 +974,11 @@ class SelectTypeInfo:
'class default' clauses, or -1 if no default clause is found.

"""
# 'str | None' syntax is only supported in Python >=3.10 so use
# 'typing.Optional[]'. Similarly, 'list[str]' is only valid in
# Python >=3.9 so use 'typing.List[str]'.
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)
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)
clause_type: list[str] = field(default_factory=list)
stmts: list[list[StmtBase]] = field(default_factory=list)
selector: str = ""
num_clauses: int = -1
default_idx: int = -1
Expand Down
11 changes: 5 additions & 6 deletions src/psyclone/psyir/symbols/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from collections import OrderedDict
from dataclasses import dataclass
from enum import Enum
from typing import Any, Union
from typing import Any

from psyclone.configuration import Config
from psyclone.errors import InternalError
Expand Down Expand Up @@ -109,7 +109,7 @@ def reference_accesses(self):
return VariablesAccessMap()

@property
def is_allocatable(self) -> Union[bool, None]:
def is_allocatable(self) -> bool | None:
'''
:returns: whether this DataType is allocatable. In the base class
set this to be always False.'''
Expand All @@ -124,7 +124,7 @@ def __str__(self):
return "UnresolvedType"

@property
def is_allocatable(self) -> Union[bool, None]:
def is_allocatable(self) -> bool | None:
'''
:returns: whether this DataType is allocatable. In case of an
UnresolvedType we don't know.'''
Expand Down Expand Up @@ -354,7 +354,7 @@ def reference_accesses(self):
return access_info

@property
def is_allocatable(self) -> Union[bool, None]:
def is_allocatable(self) -> bool | None:
'''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
Expand Down Expand Up @@ -1101,8 +1101,7 @@ class ComponentType(CommentableMixin):
:type initial_value: Optional[:py:class:`psyclone.psyir.nodes.Node`]
'''
name: str
# Use Union for compatibility with Python < 3.10
datatype: Union[DataType, DataTypeSymbol]
datatype: DataType | DataTypeSymbol
visibility: Symbol.Visibility
initial_value: Any

Expand Down
2 changes: 0 additions & 2 deletions src/psyclone/tests/parse/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ def test_line_length_unicode():
'''Check that a file containing unicode character comments
parses correctly.

Note: This test failed with Python >3,<3.7 before explicit codecs
were defined in the open(filename, ...) call.
'''
kwargs = dict(encoding='utf8')
with tempfile.NamedTemporaryFile(mode='w', **kwargs) as tmp_file:
Expand Down
25 changes: 7 additions & 18 deletions src/psyclone/tests/psyir/transformations/transformations_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

import os
import pytest
import sys
from fparser.common.readfortran import FortranStringReader
from psyclone.psyir.nodes import (
CodeBlock, Literal, Loop, Node, Reference, Schedule, Statement,
Expand Down Expand Up @@ -587,23 +586,13 @@ def test_omploop_trans_new_options(sample_psyir):
"Please see the documentation and check the provided types."
in str(excinfo.value))

# Check python version, as this tests have different behaviour for
# new python versions vs 3.8 or 3.7.
# TODO #2837: This can be removed when Python 3.7 and 3.8 are retired.
if sys.version_info[1] < 11:
with pytest.raises(TypeError) as excinfo:
omplooptrans.apply(tree.walk(Loop)[0], collapse="x")
assert ("The 'collapse' argument must be an integer or a bool "
"but got an object of type <class 'str'>" in
str(excinfo.value))
else:
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))
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))


def test_omplooptrans_apply_nowait(fortran_reader, fortran_writer):
Expand Down
Loading