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
6 changes: 6 additions & 0 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@
pip install --check-build-dependencies --no-build-isolation --config-settings=cmake.build-type="Developer" 'python/[test]'
python -c "from mpi4py import MPI; import dolfinx; assert not dolfinx.has_petsc; assert not dolfinx.has_petsc4py; assert dolfinx.has_superlu_dist"

- name: Run mypy
working-directory: python
run: |
pip install mypy types-cffi scipy-stubs

Check warning on line 138 in .github/workflows/ccpp.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Omitting "--only-binary :all:" can lead to the execution of setup scripts. Make sure it is safe here.

See more on https://sonarcloud.io/project/issues?id=FEniCS_dolfinx&issues=AZ4rJA1iokzNbNteG95g&open=AZ4rJA1iokzNbNteG95g&pullRequest=4216

Check warning on line 138 in .github/workflows/ccpp.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Using dependencies without locking resolved versions is security-sensitive.

See more on https://sonarcloud.io/project/issues?id=FEniCS_dolfinx&issues=AZ4rJA1iokzNbNteG95h&open=AZ4rJA1iokzNbNteG95h&pullRequest=4216

Check warning

Code scanning / SonarCloud

Python package manager scripts should not be executed during installation Medium

Omitting "--only-binary :all:" can lead to the execution of setup scripts. Make sure it is safe here. See more on SonarQube Cloud

Check warning

Code scanning / SonarCloud

Python dependencies should be locked to verified versions Medium

Using dependencies without locking resolved versions is security-sensitive. See more on SonarQube Cloud
mypy -p dolfinx

- name: Run mypy # Use a venv to avoid NumPy upgrades that are incompatible with numba
working-directory: python
run: |
Expand Down
9 changes: 7 additions & 2 deletions python/dolfinx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
# Template placeholder for injecting Windows dll directories in CI
# WINDOWSDLL

import numpy as _np

default_scalar_type: type[_np.floating | _np.complexfloating]
default_real_type: type[_np.floating]

try:
from petsc4py import PETSc as _PETSc

Expand All @@ -22,11 +27,11 @@
default_scalar_type = _PETSc.ScalarType # type: ignore
default_real_type = _PETSc.RealType # type: ignore
except ImportError:
import numpy as _np

default_scalar_type = _np.float64
default_real_type = _np.float64

del _np

from dolfinx import common
from dolfinx import cpp as _cpp
from dolfinx import fem, geometry, graph, io, jit, la, log, mesh, nls, plot, typing
Expand Down
6 changes: 3 additions & 3 deletions python/dolfinx/fem/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,15 +792,15 @@ def derivative_block(
""" # noqa: D301
if isinstance(F, ufl.Form) and not F.arguments():
if isinstance(u, Function):
return _derive_univariate_residual(F, u, du)
return _derive_univariate_residual(F, u, du) # type: ignore
elif isinstance(u, Sequence):
return _derive_block_residual(F, u, du)
return _derive_block_residual(F, u, du) # type: ignore
else:
raise ValueError("u must be either a ufl.Function or a sequence of ufl.Function")
elif isinstance(F, ufl.Form) and len(F.arguments()) == 1:
return _derive_univariate_jacobian(F, u, du) # type: ignore[arg-type]
elif isinstance(F, Sequence):
return _derive_block_jacobian(F, u, du)
return _derive_block_jacobian(F, u, du) # type: ignore
else:
raise ValueError(
"F must be either a UFL form (with rank zero or one), or a sequence of "
Expand Down
14 changes: 8 additions & 6 deletions python/dolfinx/fem/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,14 +663,16 @@ def functionspace(
if ufl_e.is_real:
cpp_dofmap = _cpp.fem.build_real_element_dofmap(
mesh.topology._cpp_object,
element.basix_element.entity_dofs,
element.basix_element.entity_closure_dofs,
int(np.prod(element.value_shape)),
element.basix_element.entity_dofs, # type: ignore
element.basix_element.entity_closure_dofs, # type: ignore
int(np.prod(element.value_shape)), # type: ignore
)
else:
cpp_dofmap = _cpp.fem.create_dofmap(
mesh.comm, mesh.topology._cpp_object, element._cpp_object
) # type: ignore
mesh.comm,
mesh.topology._cpp_object,
element._cpp_object, # type: ignore
)
assert np.issubdtype(mesh.geometry.x.dtype, element.dtype), ( # type: ignore
"Mesh and element dtype are not compatible."
)
Expand All @@ -692,7 +694,7 @@ class FunctionSpace(ufl.FunctionSpace, Generic[Real]):

def __init__(
self,
mesh: Mesh,
mesh: Mesh[Real],
element: ufl.finiteelement.AbstractFiniteElement,
cppV: (_cpp.fem.FunctionSpace_float32 | _cpp.fem.FunctionSpace_float64),
):
Expand Down
4 changes: 2 additions & 2 deletions python/dolfinx/fem/petsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,10 +1231,10 @@ def __init__(
)

if J is None:
J = derivative_block(F, u)
J = derivative_block(F, u) # type: ignore

self._J = _create_form(
J,
J, # type: ignore
form_compiler_options=form_compiler_options,
jit_options=jit_options,
entity_maps=entity_maps,
Expand Down
Loading