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
8 changes: 7 additions & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,17 @@ jobs:
# It is the responsibility of the developer to apply Black. (Auto-
# committing the results of running Black here is possible but
# then breaks the normal GitHub reviewing workflow.)
# NOTE: Black's decisions depend upon the version of Python being
# used. Therefore, fparser developers are recommended to use the
# the version of Python that is specified below.
black:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.14
- uses: psf/black@stable
with:
src: "./src ./example"
Expand All @@ -65,7 +71,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.13']
python-version: ['3.9', '3.10', '3.14']
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Modifications by (in alphabetical order):
* P. Vitt, University of Siegen, Germany
* A. Voysey, UK Met Office

13/03/2026 PR #495 for #494. Fix CI issues with the black formatting check.

13/03/2026 PR #491 for #490. Fix syntax warning and add build artifact
to gitignore.

Expand Down
23 changes: 17 additions & 6 deletions doc/source/developers_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -976,13 +976,24 @@ Python versions and the coverage reports are uploaded automatically to CodeCov
(https://codecov.io/gh/stfc/fparser). The configuration for this is in the
`.github/workflows/unit-tests.yml` file.

In addition, an Action is also used check that all of the code conforms
to Black (https://black.readthedocs.io) formatting. It is up to the developer
to ensure that this passes (e.g. by running `black` locally and committing
the results). Note that it is technically possibly to have the Action
actually make the changes and commit them but this was found to break
Black Formatting
++++++++++++++++

A second job within the GitHub Action is used to check that all of the
code conforms to Black (https://black.readthedocs.io) formatting. It
is up to the developer to ensure that this passes (e.g. by running
`black` locally and committing the results).

The formatting choices made by Black are influenced by the version of Python
being used. Therefore it is recommended that a developer use the version of
Python that is specfied for the `Black` job within the yml configuration
file mentioned above. (This will normally be the most recent, stable version
of Python.)

Note that while it is technically possibly to have the Action
actually make the changes and commit them, this was found to break
the Github review process since the automated commit is not permitted to
trigger further Actions and this then leaves GitHub thinking that the
trigger further Actions. This then leaves GitHub thinking that the
various checks have not run.

Automatic Packaging
Expand Down
1 change: 0 additions & 1 deletion example/create_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
Usage: create_dependencies.py file1.f90 file2.F90 ...
"""


import os
import sys

Expand Down
7 changes: 2 additions & 5 deletions example/split_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
Usage: split_file.py file.f90
"""


import os
import subprocess
import sys
Expand Down Expand Up @@ -107,8 +106,7 @@ def create_makefile(main_name, all_objs, all_filenames):
clean_actions = "\trm -f $(OBJS) *.mod"

with open(makefile, mode="w", encoding="utf-8") as f_out:
f_out.write(
f"""
f_out.write(f"""
F90 ?= {f90}
# We have to enforce this setting, since using ?= will not
# change the value of CPP, which will then be using `cc -E`, which
Expand Down Expand Up @@ -142,8 +140,7 @@ def create_makefile(main_name, all_objs, all_filenames):
# =======
clean:
{clean_actions}
"""
)
""")


# -----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/fparser/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
Module content
--------------
"""

# Author: Pearu Peterson <pearu@cens.ioc.ee>
# Created: Oct 2006

Expand Down
1 change: 0 additions & 1 deletion src/fparser/common/readfortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@
import fparser.common.sourceinfo
from fparser.common.splitline import String, string_replace_map, splitquote


__all__ = [
"FortranFileReader",
"FortranStringReader",
Expand Down
2 changes: 1 addition & 1 deletion src/fparser/common/sourceinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@
I'm not sure what that is.

"""

import os
import re


##############################################################################


Expand Down
1 change: 0 additions & 1 deletion src/fparser/common/splitline.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@

"""


import re
from typing import List, Tuple, Optional, Union

Expand Down
1 change: 1 addition & 0 deletions src/fparser/common/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
directory

"""

import pytest


Expand Down
1 change: 1 addition & 0 deletions src/fparser/common/tests/logging_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"""
Helps with testing methods which write to the standard logger.
"""

import logging


Expand Down
1 change: 1 addition & 0 deletions src/fparser/common/tests/test_base_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"""
Test battery associated with fparser.common.base_classes package.
"""

import re
import pytest

Expand Down
1 change: 0 additions & 1 deletion src/fparser/common/tests/test_sourceinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
get_source_info,
)


##############################################################################


Expand Down
1 change: 1 addition & 0 deletions src/fparser/common/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
Test the various utility functions

"""

import pytest

from fparser.common.utils import split_comma, ParseError
Expand Down
1 change: 1 addition & 0 deletions src/fparser/one/parsefortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
# DAMAGE.

"""Provides FortranParser."""

# Author: Pearu Peterson <pearu@cens.ioc.ee>
# Created: May 2006

Expand Down
1 change: 1 addition & 0 deletions src/fparser/one/tests/test_where_construct_stmt_r745.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
R745 where-construct-stmt is [where-construct-name:] WHERE ( mask-expr )

"""

import pytest

from fparser.common.sourceinfo import FortranFormat
Expand Down
1 change: 1 addition & 0 deletions src/fparser/scripts/fparser2_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
by Ondřej Čertík via Ioannis Nikiteas.

"""

from time import perf_counter

from fparser.common.sourceinfo import FortranFormat
Expand Down
1 change: 1 addition & 0 deletions src/fparser/scripts/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
representation of the code(s).

"""

import sys
import logging
from fparser.scripts.script_options import set_read_options
Expand Down
18 changes: 6 additions & 12 deletions src/fparser/scripts/script_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,11 @@


def set_read_options(parser):
parser.set_usage(
"""\
parser.set_usage("""\
%prog [options] <Fortran files>

Description:
%prog reads Fortran codes."""
)
%prog reads Fortran codes.""")
parser.add_option(
"--task",
default="show",
Expand All @@ -85,13 +83,11 @@ def set_read_options(parser):


def set_parse_options(parser):
parser.set_usage(
"""\
parser.set_usage("""\
%prog [options] <Fortran files>

Description:
%prog parses Fortran codes."""
)
%prog parses Fortran codes.""")
parser.add_option(
"--task",
default="show",
Expand All @@ -109,13 +105,11 @@ def set_fparser_options(parser):

"""

parser.set_usage(
"""\
parser.set_usage("""\
%prog [options] <Fortran files>

Description:
%prog parses Fortran code."""
)
%prog parses Fortran code.""")
parser.add_option(
"--task",
default="show",
Expand Down
1 change: 1 addition & 0 deletions src/fparser/tests/test_fparser_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
Test the setup performed for the fparser module.

"""

import os
import fparser

Expand Down
2 changes: 1 addition & 1 deletion src/fparser/two/C99Preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"""C99 Preprocessor Syntax Rules."""

# Author: Balthasar Reuter <balthasar.reuter@ecmwf.int>
# Based on previous work by Martin Schlipf (https://github.com/martin-schlipf)
# First version created: Jan 2020
Expand All @@ -44,7 +45,6 @@
from fparser.two import pattern_tools as pattern
from fparser.two.utils import Base, StringBase, WORDClsBase


# The list of classes that implement preprocessor directives
# This list is used in match_cpp_directive() and
# fparser.two.utils.BlockBase.match().
Expand Down
22 changes: 7 additions & 15 deletions src/fparser/two/Fortran2003.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
# DAMAGE.

"""Fortran 2003 Syntax Rules."""

# Original author: Pearu Peterson <pearu@cens.ioc.ee>
# First version created: Oct 2006

Expand Down Expand Up @@ -13290,36 +13291,27 @@ def tostr(self):
_names.append(n)
n = n[:-5]
# Generate 'list' class
exec(
"""\
exec("""\
class %s_List(SequenceBase):
subclass_names = [\'%s\']
use_names = []
def match(string): return SequenceBase.match(r\',\', %s, string)

"""
% (n, n, n)
)
""" % (n, n, n))
elif n.endswith("_Name"):
_names.append(n)
n = n[:-5]
exec(
"""\
exec("""\
class %s_Name(Base):
subclass_names = [\'Name\']
"""
% (n)
)
""" % (n))
elif n.startswith("Scalar_"):
_names.append(n)
n = n[7:]
exec(
"""\
exec("""\
class Scalar_%s(Base):
subclass_names = [\'%s\']
"""
% (n, n)
)
""" % (n, n))


DynamicImport().import_now()
Expand Down
20 changes: 7 additions & 13 deletions src/fparser/two/Fortran2008/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
2003 standard to implement the Fortran 2008 standard.

"""

import inspect
import sys

Expand Down Expand Up @@ -99,7 +100,6 @@
from fparser.two.Fortran2008.label_do_stmt_r816 import Label_Do_Stmt
from fparser.two.Fortran2008.nonlabel_do_stmt_r817 import Nonlabel_Do_Stmt


# pylint: disable=eval-used
# pylint: disable=exec-used

Expand All @@ -125,33 +125,27 @@
_names.append(n)
n = n[:-5]
# Generate 'list' class
exec(
f"""\
exec(f"""\
class {n}_List(SequenceBase):
subclass_names = [\'{n}\']
use_names = []
@staticmethod
def match(string): return SequenceBase.match(r\',\', {n}, string)
"""
)
""")
elif n.endswith("_Name"):
_names.append(n)
n = n[:-5]
exec(
f"""\
exec(f"""\
class {n}_Name(Base):
subclass_names = [\'Name\']
"""
)
""")
elif n.startswith("Scalar_"):
_names.append(n)
n = n[7:]
exec(
f"""\
exec(f"""\
class Scalar_{n}(Base):
subclass_names = [\'{n}\']
"""
)
""")
# Make sure NEW_CLS does not reference a class so is not accidentally
# picked up in __all__.
NEW_CLS = None
Expand Down
1 change: 1 addition & 0 deletions src/fparser/two/Fortran2008/action_stmt_c201.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"""
Module containing Fortran2008 Action_Stmt constraint C201
"""

from fparser.two.Fortran2003 import Action_Stmt_C201 as Action_Stmt_C201_2003
from fparser.two.Fortran2008.action_stmt_r214 import Action_Stmt

Expand Down
Loading
Loading