1212
1313from docx .enum .section import WD_HEADER_FOOTER , WD_ORIENTATION , WD_SECTION_START
1414from docx .oxml .ns import nsmap
15- from docx .oxml .shared import CT_OnOff
16- from docx .oxml .simpletypes import ST_SignedTwipsMeasure , ST_TwipsMeasure , XsdString , ST_FtnPos , ST_NumberFormat , ST_RestartNumber
15+ from docx .oxml .shared import CT_OnOff , CT_DecimalNumber
16+ from docx .oxml .simpletypes import ST_SignedTwipsMeasure , ST_TwipsMeasure , XsdString , ST_FtnPos , ST_NumberFormat , ST_RestartNumber , ST_DecimalNumber
1717from docx .oxml .table import CT_Tbl
1818from docx .oxml .text .paragraph import CT_P
1919from docx .oxml .xmlchemy import (
@@ -35,13 +35,19 @@ class CT_FtnPos(BaseOxmlElement):
3535
3636class CT_FtnProps (BaseOxmlElement ):
3737 """``<w:footnotePr>`` element, section wide footnote properties"""
38+
39+ get_or_add_pos : Callable [[], CT_FtnPos ]
40+ get_or_add_numFmt : Callable [[], CT_NumFmt ]
41+ get_or_add_numStart : Callable [[], CT_DecimalNumber ]
42+ get_or_add_numRestart : Callable [[], CT_NumRestart ]
43+
3844 _tag_seq = (
3945 'w:pos' , 'w:numFmt' , 'w:numStart' , 'w:numRestart'
4046 )
41- pos = ZeroOrOne ('w:pos' , successors = _tag_seq )
42- numFmt = ZeroOrOne ('w:numFmt' , successors = _tag_seq [1 :])
43- numStart = ZeroOrOne ('w:numStart' , successors = _tag_seq [2 :])
44- numRestart = ZeroOrOne ('w:numRestart' , successors = _tag_seq [3 :])
47+ pos : CT_FtnPos | None = ZeroOrOne ('w:pos' , successors = _tag_seq ) # pyright: ignore[reportGeneralTypeIssues]
48+ numFmt : CT_NumFmt | None = ZeroOrOne ('w:numFmt' , successors = _tag_seq [1 :]) # pyright: ignore[reportGeneralTypeIssues]
49+ numStart : CT_DecimalNumber | None = ZeroOrOne ('w:numStart' , successors = _tag_seq [2 :]) # pyright: ignore[reportGeneralTypeIssues]
50+ numRestart : CT_NumRestart | None = ZeroOrOne ('w:numRestart' , successors = _tag_seq [3 :]) # pyright: ignore[reportGeneralTypeIssues]
4551
4652
4753class CT_HdrFtr (BaseOxmlElement ):
@@ -132,6 +138,7 @@ class CT_SectPr(BaseOxmlElement):
132138 get_or_add_pgSz : Callable [[], CT_PageSz ]
133139 get_or_add_titlePg : Callable [[], CT_OnOff ]
134140 get_or_add_type : Callable [[], CT_SectType ]
141+ get_or_add_footnotePr : Callable [[], CT_FtnProps ]
135142 _add_footerReference : Callable [[], CT_HdrFtrRef ]
136143 _add_headerReference : Callable [[], CT_HdrFtrRef ]
137144 _remove_titlePg : Callable [[], None ]
@@ -173,7 +180,9 @@ class CT_SectPr(BaseOxmlElement):
173180 titlePg : CT_OnOff | None = ZeroOrOne ( # pyright: ignore[reportAssignmentType]
174181 "w:titlePg" , successors = _tag_seq [14 :]
175182 )
176- footnotePr = ZeroOrOne ("w:footnotePr" , successors = _tag_seq [1 :])
183+ footnotePr : CT_FtnProps | None = ZeroOrOne ( # pyright: ignore[reportGeneralTypeIssues]
184+ "w:footnotePr" , successors = _tag_seq [1 :]
185+ )
177186 del _tag_seq
178187
179188 def add_footerReference (self , type_ : WD_HEADER_FOOTER , rId : str ) -> CT_HdrFtrRef :
@@ -241,7 +250,7 @@ def footer(self, value: int | Length | None):
241250 pgMar .footer = value if value is None or isinstance (value , Length ) else Length (value )
242251
243252 @property
244- def footnote_number_format (self ):
253+ def footnote_number_format (self ) -> ST_NumberFormat | None :
245254 """
246255 The value of the ``w:val`` attribute in the ``<w:numFmt>`` child
247256 element of ``<w:footnotePr>`` element, as a |String|, or |None| if either the element or the
@@ -253,13 +262,13 @@ def footnote_number_format(self):
253262 return fPr .numFmt .val
254263
255264 @footnote_number_format .setter
256- def footnote_number_format (self , value ):
265+ def footnote_number_format (self , value : ST_NumberFormat | None ):
257266 fPr = self .get_or_add_footnotePr ()
258267 numFmt = fPr .get_or_add_numFmt ()
259268 numFmt .val = value
260269
261270 @property
262- def footnote_numbering_restart_location (self ):
271+ def footnote_numbering_restart_location (self ) -> ST_RestartNumber | None :
263272 """
264273 The value of the ``w:val`` attribute in the ``<w:numRestart>`` child
265274 element of ``<w:footnotePr>`` element, as a |String|, or |None| if either the element or the
@@ -271,20 +280,20 @@ def footnote_numbering_restart_location(self):
271280 return fPr .numRestart .val
272281
273282 @footnote_numbering_restart_location .setter
274- def footnote_numbering_restart_location (self , value ):
283+ def footnote_numbering_restart_location (self , value : ST_RestartNumber | None ):
275284 fPr = self .get_or_add_footnotePr ()
276285 numStart = fPr .get_or_add_numStart ()
277286 numRestart = fPr .get_or_add_numRestart ()
278287 numRestart .val = value
279- if numStart is None or len (numStart .values ()) == 0 :
288+ if len (numStart .values ()) == 0 :
280289 numStart .val = 1
281290 elif value != 'continuous' :
282291 numStart .val = 1
283292 msg = "When ``<w:numRestart> is not 'continuous', then ``<w:numStart>`` must be 1."
284293 warn (msg , UserWarning , stacklevel = 2 )
285294
286295 @property
287- def footnote_numbering_start_value (self ):
296+ def footnote_numbering_start_value (self ) -> ST_DecimalNumber | None :
288297 """
289298 The value of the ``w:val`` attribute in the ``<w:numStart>`` child
290299 element of ``<w:footnotePr>`` element, as a |Number|, or |None| if either the element or the
@@ -296,20 +305,20 @@ def footnote_numbering_start_value(self):
296305 return fPr .numStart .val
297306
298307 @footnote_numbering_start_value .setter
299- def footnote_numbering_start_value (self , value ):
308+ def footnote_numbering_start_value (self , value : ST_DecimalNumber | None ):
300309 fPr = self .get_or_add_footnotePr ()
301310 numStart = fPr .get_or_add_numStart ()
302311 numRestart = fPr .get_or_add_numRestart ()
303312 numStart .val = value
304- if numRestart is None or len (numRestart .values ()) == 0 :
313+ if len (numRestart .values ()) == 0 :
305314 numRestart .val = 'continuous'
306315 elif value != 1 :
307316 numRestart .val = 'continuous'
308317 msg = "When ``<w:numStart> is not 1, then ``<w:numRestart>`` must be 'continuous'."
309318 warn (msg , UserWarning , stacklevel = 2 )
310319
311320 @property
312- def footnote_position (self ):
321+ def footnote_position (self ) -> ST_FtnPos | None :
313322 """
314323 The value of the ``w:val`` attribute in the ``<w:pos>`` child
315324 element of ``<w:footnotePr>`` element, as a |String|, or |None| if either the element or the
@@ -321,7 +330,7 @@ def footnote_position(self):
321330 return fPr .pos .val
322331
323332 @footnote_position .setter
324- def footnote_position (self , value ):
333+ def footnote_position (self , value : ST_FtnPos | None ):
325334 fPr = self .get_or_add_footnotePr ()
326335 pos = fPr .get_or_add_pos ()
327336 pos .val = value
0 commit comments