Skip to content

Switch CI type checking from mypy to Pyrefly - #4500

Open
garth-wells wants to merge 23 commits into
mainfrom
ci/pyrefly-typechecking
Open

Switch CI type checking from mypy to Pyrefly#4500
garth-wells wants to merge 23 commits into
mainfrom
ci/pyrefly-typechecking

Conversation

@garth-wells

@garth-wells garth-wells commented Sep 13, 2026

Copy link
Copy Markdown
Member

Summary

  • replace the CI mypy job and dependency with Pyrefly
  • add Pyrefly configuration for the Python package, demos, and tests
  • baseline the 58 existing migration diagnostics so new diagnostics still fail CI
  • update type-checking documentation and repository guidance
  • preserve the generated-stub mypy suppressions for downstream consumers

Validation

  • Pyrefly checks pass in the openmpi / PETSc float64 / int32 CI leg
  • loaded the configuration with Pyrefly 1.3.0
  • validated the baseline JSON
  • parsed .github/workflows/ci.yml as YAML
  • ran Ruff check and format checks on the touched Python source
  • ran Gersemi on python/CMakeLists.txt (only the existing unknown nanobind command warnings)
  • ran git diff --check

AI assistance

AI assistance: OpenAI Codex drafted parts of this PR. Human review is pending before marking it ready.

print("pyvista and pyvistaqt are required to visualise the solution")
have_pyvista = False
pv = None
pvqt = None
@garth-wells garth-wells added ci Continuous Integration type-hints labels Sep 13, 2026
@garth-wells
garth-wells marked this pull request as ready for review September 13, 2026 20:30
Comment thread python/dolfinx/la/petsc.py Outdated
x0: npt.NDArray[np.inexact] | Sequence[npt.NDArray[np.inexact]],
x1: PETSc.Vec,
) -> None:
) -> None: ...
Comment thread python/dolfinx/la/petsc.py Fixed
Comment thread python/dolfinx/fem/petsc.py Fixed
Comment thread python/dolfinx/fem/petsc.py Fixed
def assign(
x0: PETSc.Vec,
x1: npt.NDArray[np.inexact] | Sequence[npt.NDArray[np.inexact]],
) -> None: ...
Comment thread python/dolfinx/fem/petsc.py Fixed


@overload
def assign(u: _Function | Sequence[_Function], x: PETSc.Vec) -> None: ...


@overload
def assign(u: PETSc.Vec, x: _Function | Sequence[_Function]) -> None: ...
@jhale

jhale commented Sep 14, 2026

Copy link
Copy Markdown
Member

Looks good, mypy was missing some odd things. Is it possible to put the config largely back into pyproject? Prefer the single file approach.

@garth-wells
garth-wells requested a review from jhale September 14, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continuous Integration type-hints

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants