Skip to content

Commit c054d85

Browse files
committed
Activate 'check_untyped_defs' and 'disallow_untyped_defs' mypy checks on ffcx.*
1 parent 84c6c11 commit c054d85

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

ffcx/compiler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
logger = logging.getLogger("ffcx")
8080

8181

82-
def _print_timing(stage: int, timing: float):
82+
def _print_timing(stage: int, timing: float) -> None:
8383
logger.info(f"Compiler stage {stage} finished in {timing:.4f} seconds.")
8484

8585

ffcx/formatting.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ def format_code(code: CodeBlocks) -> tuple[str, str]:
3838
return code_h, code_c
3939

4040

41-
def write_code(code_h, code_c, prefix, output_dir):
41+
def write_code(code_h: str, code_c: str, prefix: str, output_dir: str) -> None:
4242
"""Write code to files."""
4343
_write_file(code_h, prefix, ".h", output_dir)
4444
_write_file(code_c, prefix, ".c", output_dir)
4545

4646

47-
def _write_file(output, prefix, postfix, output_dir):
47+
def _write_file(output: str, prefix: str, postfix: str, output_dir: str) -> None:
4848
"""Write generated code to file."""
4949
filename = os.path.join(output_dir, prefix + postfix)
5050
with open(filename, "w") as hfile:

ffcx/main.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import pathlib
1515
import re
1616
import string
17+
from collections.abc import Sequence
18+
from typing import Optional
1719

1820
import ufl
1921

@@ -45,7 +47,7 @@
4547
parser.add_argument("ufl_file", nargs="+", help="UFL file(s) to be compiled")
4648

4749

48-
def main(args=None):
50+
def main(args: Optional[Sequence[str]] = None) -> int:
4951
"""Run ffcx on a UFL file."""
5052
xargs = parser.parse_args(args)
5153

pyproject.toml

+5-2
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,12 @@ ignore_missing_imports = true
7979

8080
[[tool.mypy.overrides]]
8181
module = ["ffcx.*", "ffcx.ir.*", "ffcx.codegeneration.*"]
82-
disallow_untyped_defs = false
83-
disallow_any_unimported = false
82+
disallow_any_unimported = false # most of these come from UFL
83+
84+
[[tool.mypy.overrides]]
85+
module = ["ffcx.ir.*", "ffcx.codegeneration.*"]
8486
check_untyped_defs = false
87+
disallow_untyped_defs = false
8588

8689
[tool.ruff]
8790
line-length = 100

0 commit comments

Comments
 (0)