@@ -163,6 +163,7 @@ def parse_dte_xml(xml_doc: XmlElement) -> data_models.DteXmlData:
163163 'ds:Signature' , # "Firma Digital sobre Documento"
164164 namespaces = xml_utils .XML_DSIG_NS_MAP ,
165165 )
166+ assert signature_em is not None
166167
167168 if liquidacion_em is not None or exportaciones_em is not None :
168169 raise NotImplementedError ("XML element 'Documento' is the only one supported." )
@@ -191,6 +192,7 @@ def parse_dte_xml(xml_doc: XmlElement) -> data_models.DteXmlData:
191192 'sii-dte:Encabezado' , # "Identificacion y Totales del Documento"
192193 namespaces = DTE_XMLNS_MAP ,
193194 )
195+ assert encabezado_em is not None
194196 # note: excluded because currently it is not useful.
195197 # ted_em = documento_em.find(
196198 # 'sii-dte:TED', # "Timbre Electronico de DTE"
@@ -215,18 +217,22 @@ def parse_dte_xml(xml_doc: XmlElement) -> data_models.DteXmlData:
215217 'sii-dte:IdDoc' , # "Identificacion del DTE"
216218 namespaces = DTE_XMLNS_MAP ,
217219 )
220+ assert id_doc_em is not None
218221 emisor_em = encabezado_em .find (
219222 'sii-dte:Emisor' , # "Datos del Emisor"
220223 namespaces = DTE_XMLNS_MAP ,
221224 )
225+ assert emisor_em is not None
222226 receptor_em = encabezado_em .find (
223227 'sii-dte:Receptor' , # "Datos del Receptor"
224228 namespaces = DTE_XMLNS_MAP ,
225229 )
230+ assert receptor_em is not None
226231 totales_em = encabezado_em .find (
227232 'sii-dte:Totales' , # "Montos Totales del DTE"
228233 namespaces = DTE_XMLNS_MAP ,
229234 )
235+ assert totales_em is not None
230236
231237 # 'Documento.Encabezado.IdDoc'
232238 # Excluded elements (optional according to the XML schema but the SII may require some of these
@@ -453,13 +459,15 @@ def parse_dte_xml(xml_doc: XmlElement) -> data_models.DteXmlData:
453459 'ds:KeyInfo' , # "Informacion de Claves Publicas y Certificado"
454460 namespaces = xml_utils .XML_DSIG_NS_MAP ,
455461 )
462+ assert signature_key_info_em is not None
456463 # signature_key_info_key_value_em = signature_key_info_em.find(
457464 # 'ds:KeyValue',
458465 # namespaces=xml_utils.XML_DSIG_NS_MAP)
459466 signature_key_info_x509_data_em = signature_key_info_em .find (
460467 'ds:X509Data' , # "Informacion del Certificado Publico"
461468 namespaces = xml_utils .XML_DSIG_NS_MAP ,
462469 )
470+ assert signature_key_info_x509_data_em is not None
463471 signature_key_info_x509_cert_em = signature_key_info_x509_data_em .find (
464472 'ds:X509Certificate' , # "Certificado Publico"
465473 namespaces = xml_utils .XML_DSIG_NS_MAP ,
@@ -523,7 +531,7 @@ def parse_dte_xml(xml_doc: XmlElement) -> data_models.DteXmlData:
523531 )
524532
525533
526- def _text_strip_or_none (xml_em : XmlElement ) -> Optional [str ]:
534+ def _text_strip_or_none (xml_em : Optional [ XmlElement ] ) -> Optional [str ]:
527535 # note: we need the pair of functions '_text_strip_or_none' and '_text_strip_or_raise'
528536 # because, under certain circumstances, an XML tag:
529537 # - with no content -> `xml_em.text` is None instead of ''
@@ -539,7 +547,7 @@ def _text_strip_or_none(xml_em: XmlElement) -> Optional[str]:
539547 return stripped_text
540548
541549
542- def _text_strip_or_raise (xml_em : XmlElement ) -> str :
550+ def _text_strip_or_raise (xml_em : Optional [ XmlElement ] ) -> str :
543551 # note: we need the pair of functions '_text_strip_or_none' and '_text_strip_or_raise'
544552 # because, under certain circumstances, an XML tag:
545553 # - with no content -> `xml_em.text` is None instead of ''
0 commit comments