Skip to content

Commit c5040d2

Browse files
committed
Fix mypy error code 'return-value'
1 parent 96b1ff2 commit c5040d2

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ disable_error_code = [
9696
"misc",
9797
"operator",
9898
"override",
99-
"return-value",
10099
"type-var",
101100
"var-annotated",
102101
]

ufl/cell.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def __init__(self, *cells: Cell):
358358
if not isinstance(self._tdim, numbers.Integral):
359359
raise ValueError("Expecting integer topological_dimension.")
360360

361-
def sub_cells(self) -> typing.List[AbstractCell]:
361+
def sub_cells(self) -> typing.Tuple[AbstractCell, ...]:
362362
"""Return list of cell factors."""
363363
return self._cells
364364

@@ -398,21 +398,21 @@ def num_sub_entities(self, dim: int) -> int:
398398
def sub_entities(self, dim: int) -> typing.Tuple[AbstractCell, ...]:
399399
"""Get the sub-entities of the given dimension."""
400400
if dim < 0 or dim > self._tdim:
401-
return []
401+
return ()
402402
if dim == 0:
403-
return [Cell("vertex") for i in range(self.num_sub_entities(0))]
403+
return tuple(Cell("vertex") for i in range(self.num_sub_entities(0)))
404404
if dim == self._tdim:
405-
return [self]
405+
return (self,)
406406
raise NotImplementedError(f"TensorProductCell.sub_entities({dim}) is not implemented.")
407407

408408
def sub_entity_types(self, dim: int) -> typing.Tuple[AbstractCell, ...]:
409409
"""Get the unique sub-entity types of the given dimension."""
410410
if dim < 0 or dim > self._tdim:
411-
return []
411+
return ()
412412
if dim == 0:
413-
return [Cell("vertex")]
413+
return (Cell("vertex"),)
414414
if dim == self._tdim:
415-
return [self]
415+
return (self,)
416416
raise NotImplementedError(f"TensorProductCell.sub_entities({dim}) is not implemented.")
417417

418418
def _lt(self, other) -> bool:
@@ -434,7 +434,7 @@ def _ufl_hash_data_(self) -> typing.Hashable:
434434
"""UFL hash data."""
435435
return tuple(c._ufl_hash_data_() for c in self._cells)
436436

437-
def reconstruct(self, **kwargs: typing.Any) -> Cell:
437+
def reconstruct(self, **kwargs: typing.Any) -> Cell | TensorProductCell:
438438
"""Reconstruct this cell, overwriting properties by those in kwargs."""
439439
for key, value in kwargs.items():
440440
raise TypeError(f"reconstruct() got unexpected keyword argument '{key}'")

ufl/functionspace.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def components(self) -> typing.Dict[typing.Tuple[int, ...], int]:
8080
if len(self._ufl_element.sub_elements) == 0:
8181
return {(): 0}
8282

83-
components = {}
83+
components: dict[tuple[int, ...], int] = {}
8484
offset = 0
8585
c_offset = 0
8686
for s in self.ufl_sub_spaces():

ufl/objects.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
globals()[measure_name] = Measure(integral_type)
2121

2222
# TODO: Firedrake hack, remove later
23-
ds_tb = ds_b + ds_t # type: ignore # noqa: F821
23+
ds_tb = ds_b + ds_t # type: ignore # noqa: F821
2424

2525
# Default measure dX including both uncut and cut cells
2626
dX = dx + dC # type: ignore # noqa: F821

0 commit comments

Comments
 (0)