Skip to content

Commit

Permalink
Merge pull request #107 from ecmwf-ifs/69-python-3.11-compatibility
Browse files Browse the repository at this point in the history
Python 3.11 compatibility
  • Loading branch information
mlange05 authored Jul 3, 2023
2 parents 615fdc5 + faaddcc commit b9b5cd3
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 43 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/code_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: code-checks

# Controls when the workflow will run
on:
# Triggers the workflow on push events
push:
branches: [ 'main' ]
tags-ignore: [ '**' ]

# Triggers the workflow on pull request events
pull_request:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
code_checks:
name: code checks

runs-on: ubuntu-latest
strategy:
fail-fast: false # false: try to complete all jobs
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[tests,examples] ./transformations ./lint_rules
pip list
- name: Add pylint annotator
uses: pr-annotators/[email protected]
- name: Analysing the code with pylint
run: |
pylint --rcfile=.pylintrc loki tests
pushd transformations && pylint --rcfile=../.pylintrc transformations tests; popd
pushd lint_rules && pylint --rcfile=../.pylintrc lint_rules tests; popd
jupyter nbconvert --to=script --output-dir=example_converted example/*.ipynb
pylint --rcfile=.pylintrc_ipynb example_converted/*.py
2 changes: 1 addition & 1 deletion .github/workflows/regression_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false # false: try to complete all jobs
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
Expand Down
33 changes: 1 addition & 32 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,14 @@ on:
workflow_dispatch:

jobs:
code_checks:
name: code checks

runs-on: ubuntu-latest
strategy:
fail-fast: false # false: try to complete all jobs
matrix:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[tests,examples] ./transformations ./lint_rules
pip list
- name: Add pylint annotator
uses: pr-annotators/[email protected]
- name: Analysing the code with pylint
run: |
pylint --rcfile=.pylintrc loki tests
pushd transformations && pylint --rcfile=../.pylintrc transformations tests; popd
pushd lint_rules && pylint --rcfile=../.pylintrc lint_rules tests; popd
jupyter nbconvert --to=script --output-dir=example_converted example/*.ipynb
pylint --rcfile=.pylintrc_ipynb example_converted/*.py
pytest:
name: Python ${{ matrix.python-version }}

runs-on: ubuntu-20.04
strategy:
fail-fast: false # false: try to complete all jobs
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Loki: Freely programmable source-to-source translation

[![license](https://img.shields.io/github/license/ecmwf-ifs/loki)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![code-checks](https://github.com/ecmwf-ifs/loki/actions/workflows/code_checks.yml/badge.svg)](https://github.com/ecmwf-ifs/loki/actions/workflows/code_checks.yml)
[![tests](https://github.com/ecmwf-ifs/loki/actions/workflows/tests.yml/badge.svg)](https://github.com/ecmwf-ifs/loki/actions/workflows/tests.yml)
[![regression-tests](https://github.com/ecmwf-ifs/loki/actions/workflows/regression_tests.yml/badge.svg)](https://github.com/ecmwf-ifs/loki/actions/workflows/regression_tests.yml)
[![codecov](https://codecov.io/gh/ecmwf-ifs/loki/branch/main/graph/badge.svg?token=9ZDS95SFWI)](https://codecov.io/gh/ecmwf-ifs/loki)
Expand Down
11 changes: 2 additions & 9 deletions loki/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"""

import weakref
from enum import IntEnum
from enum import Enum
from loki.tools import flatten, as_tuple, LazyNodeLookup


Expand All @@ -24,15 +24,8 @@ class DataType:
Base class for data types a symbol may have
"""

def __init__(self, *args): # pylint:disable=unused-argument
# Make sure we always instantiate one of the subclasses
# Note that we cannot use ABC for that as this would cause a
# metaclass clash with IntEnum, which is used to represent
# intrinsic types in BasicType
assert self.__class__ is not DataType


class BasicType(DataType, IntEnum):
class BasicType(DataType, int, Enum):
"""
Representation of intrinsic data types, names taken from the FORTRAN convention.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license_file = LICENSE

[options]
packages = find:
python_requires = >=3.8,<3.11
python_requires = >=3.8,<3.12
install_requires =
numpy<1.24 # essential for tests, loop transformations and other dependencies
pymbolic>=2022.1 # essential for expression tree
Expand Down

0 comments on commit b9b5cd3

Please sign in to comment.