Skip to content

Commit fa5742b

Browse files
committed
Avoid using kwargs to make mypy happy.
See python/mypy#14073
1 parent 39e95a3 commit fa5742b

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

‎fpdf/template.py‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from typing import Any, Optional, Sequence
1717

1818
from .deprecation import get_stack_level
19-
from .enums import WrapMode
19+
from .enums import WrapMode, XPos, YPos
2020
from .errors import FPDFException
2121
from .fpdf import FPDF
2222

@@ -432,11 +432,10 @@ def _text(
432432
width = w if w is not None else x2 - (x1 if x1 is not None else pdf.get_x())
433433
height = h if h is not None else y2 - (y1 if y1 is not None else pdf.get_y())
434434

435-
cell_kwargs = {}
436-
if new_x is not None:
437-
cell_kwargs["new_x"] = new_x
438-
if new_y is not None:
439-
cell_kwargs["new_y"] = new_y
435+
# set default values, because cell() does not know how to
436+
# treat None as value for new_x, new_y
437+
new_xx = XPos.RIGHT if new_x is None else new_x
438+
new_yy = YPos.TOP if new_y is None else new_y
440439

441440
if multiline is None: # write without wrapping/trimming (default)
442441
pdf.cell(
@@ -446,7 +445,8 @@ def _text(
446445
border=0,
447446
align=align,
448447
fill=fill,
449-
**cell_kwargs,
448+
new_x=new_xx,
449+
new_y=new_yy,
450450
)
451451
elif multiline: # automatic word - warp
452452
pdf.multi_cell(
@@ -457,7 +457,8 @@ def _text(
457457
align=align,
458458
fill=fill,
459459
wrapmode=WrapMode.coerce(wrapmode),
460-
**cell_kwargs,
460+
new_x=new_xx,
461+
new_y=new_yy,
461462
)
462463
else: # trim to fit exactly the space defined
463464
text = pdf.multi_cell( # type: ignore[index,assignment]
@@ -476,7 +477,8 @@ def _text(
476477
border=0,
477478
align=align,
478479
fill=fill,
479-
**cell_kwargs,
480+
new_x=new_xx,
481+
new_y=new_yy,
480482
)
481483

482484
def _line(

0 commit comments

Comments
 (0)