diff --git a/mypy.ini b/mypy.ini index e3ec935c..e9b6d932 100644 --- a/mypy.ini +++ b/mypy.ini @@ -42,6 +42,7 @@ strict_optional = True disallow_untyped_defs = True check_untyped_defs = True warn_return_any = True +warn_unused_ignores = True show_column_numbers = True show_error_codes = True diff --git a/src/cl_sii/extras/mm_fields.py b/src/cl_sii/extras/mm_fields.py index dfb2de42..a101e2fc 100644 --- a/src/cl_sii/extras/mm_fields.py +++ b/src/cl_sii/extras/mm_fields.py @@ -229,6 +229,6 @@ def _validated(self, value: Optional[object]) -> Optional[RcvPeriodoTributario]: except TypeError as exc: raise self.make_error('type') from exc - validated = RcvPeriodoTributario.from_date(value) # type: ignore + validated = RcvPeriodoTributario.from_date(value) return validated diff --git a/src/cl_sii/libs/rows_processing.py b/src/cl_sii/libs/rows_processing.py index fc9fda90..86ff99c6 100644 --- a/src/cl_sii/libs/rows_processing.py +++ b/src/cl_sii/libs/rows_processing.py @@ -55,11 +55,7 @@ def csv_rows_mm_deserialization_iterator( on CSV error when iterating over ``csv_reader`` """ - # note: mypy complaint is wrong because a 'csv.DictReader' object can be iterated over - # and yields instances of 'Dict[str, object]'. - # > Incompatible types in assignment (expression has type "DictReader", variable has type - # > "Iterable[Dict[str, object]]") - rows_iterator: Iterable[Dict[str, object]] = csv_reader # type: ignore + rows_iterator: Iterable[Dict[str, object]] = csv_reader iterator = rows_mm_deserialization_iterator( rows_iterator, row_schema, n_rows_offset, max_n_rows, fields_to_remove_names ) diff --git a/src/cl_sii/libs/tz_utils.py b/src/cl_sii/libs/tz_utils.py index a64f5d98..fc7ead55 100644 --- a/src/cl_sii/libs/tz_utils.py +++ b/src/cl_sii/libs/tz_utils.py @@ -23,7 +23,7 @@ pytz.tzinfo.BaseTzInfo, pytz.tzinfo.StaticTzInfo, pytz.tzinfo.DstTzInfo, - pytz._FixedOffset, # type: ignore + pytz._FixedOffset, ] diff --git a/src/cl_sii/rcv/parse_csv.py b/src/cl_sii/rcv/parse_csv.py index e5e2a7b7..8a5d6d08 100644 --- a/src/cl_sii/rcv/parse_csv.py +++ b/src/cl_sii/rcv/parse_csv.py @@ -633,16 +633,16 @@ def postprocess(self, data: dict, **kwargs: Any) -> dict: def to_detalle_entry(self, data: dict) -> RvDetalleEntry: try: - emisor_rut: Rut = data['emisor_rut'] # type: ignore - tipo_docto = data['tipo_docto'] # type: ignore - folio: int = data['folio'] # type: ignore - fecha_emision_date: date = data['fecha_emision_date'] # type: ignore - receptor_rut: Rut = data['receptor_rut'] # type: ignore - monto_total: int = data['monto_total'] # type: ignore - receptor_razon_social: str = data['receptor_razon_social'] # type: ignore - fecha_recepcion_dt: datetime = data['fecha_recepcion_dt'] # type: ignore - fecha_acuse_dt: Optional[datetime] = data['fecha_acuse_dt'] # type: ignore - fecha_reclamo_dt: Optional[datetime] = data['fecha_reclamo_dt'] # type: ignore + emisor_rut: Rut = data['emisor_rut'] + tipo_docto = data['tipo_docto'] + folio: int = data['folio'] + fecha_emision_date: date = data['fecha_emision_date'] + receptor_rut: Rut = data['receptor_rut'] + monto_total: int = data['monto_total'] + receptor_razon_social: str = data['receptor_razon_social'] + fecha_recepcion_dt: datetime = data['fecha_recepcion_dt'] + fecha_acuse_dt: Optional[datetime] = data['fecha_acuse_dt'] + fecha_reclamo_dt: Optional[datetime] = data['fecha_reclamo_dt'] except KeyError as exc: raise ValueError("Programming error: a referenced field is missing.") from exc @@ -765,15 +765,15 @@ def postprocess(self, data: dict, **kwargs: Any) -> dict: def to_detalle_entry(self, data: dict) -> RcRegistroDetalleEntry: try: - emisor_rut: Rut = data['emisor_rut'] # type: ignore - tipo_docto = data['tipo_docto'] # type: ignore - folio: int = data['folio'] # type: ignore - fecha_emision_date: date = data['fecha_emision_date'] # type: ignore - receptor_rut: Rut = data['receptor_rut'] # type: ignore - monto_total: int = data['monto_total'] # type: ignore - emisor_razon_social: str = data['emisor_razon_social'] # type: ignore - fecha_recepcion_dt: datetime = data['fecha_recepcion_dt'] # type: ignore - fecha_acuse_dt: Optional[datetime] = data['fecha_acuse_dt'] # type: ignore + emisor_rut: Rut = data['emisor_rut'] + tipo_docto = data['tipo_docto'] + folio: int = data['folio'] + fecha_emision_date: date = data['fecha_emision_date'] + receptor_rut: Rut = data['receptor_rut'] + monto_total: int = data['monto_total'] + emisor_razon_social: str = data['emisor_razon_social'] + fecha_recepcion_dt: datetime = data['fecha_recepcion_dt'] + fecha_acuse_dt: Optional[datetime] = data['fecha_acuse_dt'] except KeyError as exc: raise ValueError("Programming error: a referenced field is missing.") from exc @@ -798,15 +798,15 @@ def to_detalle_entry(self, data: dict) -> RcRegistroDetalleEntry: class RcvCompraNoIncluirCsvRowSchema(RcvCompraRegistroCsvRowSchema): def to_detalle_entry(self, data: dict) -> RcNoIncluirDetalleEntry: try: - emisor_rut: Rut = data['emisor_rut'] # type: ignore - tipo_docto = data['tipo_docto'] # type: ignore - folio: int = data['folio'] # type: ignore - fecha_emision_date: date = data['fecha_emision_date'] # type: ignore - receptor_rut: Rut = data['receptor_rut'] # type: ignore - monto_total: int = data['monto_total'] # type: ignore - emisor_razon_social: str = data['emisor_razon_social'] # type: ignore - fecha_recepcion_dt: datetime = data['fecha_recepcion_dt'] # type: ignore - fecha_acuse_dt: Optional[datetime] = data['fecha_acuse_dt'] # type: ignore + emisor_rut: Rut = data['emisor_rut'] + tipo_docto = data['tipo_docto'] + folio: int = data['folio'] + fecha_emision_date: date = data['fecha_emision_date'] + receptor_rut: Rut = data['receptor_rut'] + monto_total: int = data['monto_total'] + emisor_razon_social: str = data['emisor_razon_social'] + fecha_recepcion_dt: datetime = data['fecha_recepcion_dt'] + fecha_acuse_dt: Optional[datetime] = data['fecha_acuse_dt'] except KeyError as exc: raise ValueError("Programming error: a referenced field is missing.") from exc @@ -934,15 +934,15 @@ def postprocess(self, data: dict, **kwargs: Any) -> dict: def to_detalle_entry(self, data: dict) -> RcReclamadoDetalleEntry: try: - emisor_rut: Rut = data['emisor_rut'] # type: ignore - tipo_docto = data['tipo_docto'] # type: ignore - folio: int = data['folio'] # type: ignore - fecha_emision_date: date = data['fecha_emision_date'] # type: ignore - receptor_rut: Rut = data['receptor_rut'] # type: ignore - monto_total: int = data['monto_total'] # type: ignore - emisor_razon_social: str = data['emisor_razon_social'] # type: ignore - fecha_recepcion_dt: datetime = data['fecha_recepcion_dt'] # type: ignore - fecha_reclamo_dt: Optional[datetime] = data['fecha_reclamo_dt'] # type: ignore + emisor_rut: Rut = data['emisor_rut'] + tipo_docto = data['tipo_docto'] + folio: int = data['folio'] + fecha_emision_date: date = data['fecha_emision_date'] + receptor_rut: Rut = data['receptor_rut'] + monto_total: int = data['monto_total'] + emisor_razon_social: str = data['emisor_razon_social'] + fecha_recepcion_dt: datetime = data['fecha_recepcion_dt'] + fecha_reclamo_dt: Optional[datetime] = data['fecha_reclamo_dt'] except KeyError as exc: raise ValueError("Programming error: a referenced field is missing.") from exc @@ -1053,14 +1053,14 @@ def postprocess(self, data: dict, **kwargs: Any) -> dict: def to_detalle_entry(self, data: dict) -> RcPendienteDetalleEntry: try: - emisor_rut: Rut = data['emisor_rut'] # type: ignore - tipo_docto = data['tipo_docto'] # type: ignore - folio: int = data['folio'] # type: ignore - fecha_emision_date: date = data['fecha_emision_date'] # type: ignore - receptor_rut: Rut = data['receptor_rut'] # type: ignore - monto_total: int = data['monto_total'] # type: ignore - emisor_razon_social: str = data['emisor_razon_social'] # type: ignore - fecha_recepcion_dt: datetime = data['fecha_recepcion_dt'] # type: ignore + emisor_rut: Rut = data['emisor_rut'] + tipo_docto = data['tipo_docto'] + folio: int = data['folio'] + fecha_emision_date: date = data['fecha_emision_date'] + receptor_rut: Rut = data['receptor_rut'] + monto_total: int = data['monto_total'] + emisor_razon_social: str = data['emisor_razon_social'] + fecha_recepcion_dt: datetime = data['fecha_recepcion_dt'] except KeyError as exc: raise ValueError("Programming error: a referenced field is missing.") from exc diff --git a/src/cl_sii/rtc/parse_aec.py b/src/cl_sii/rtc/parse_aec.py index ffbdc65e..81e406cc 100644 --- a/src/cl_sii/rtc/parse_aec.py +++ b/src/cl_sii/rtc/parse_aec.py @@ -236,7 +236,7 @@ def parse_xml_to_dict(xml_em: XmlElement) -> Mapping[str, object]: # Validators ########################################################################### - _validate_rut = pydantic.field_validator( # type: ignore[pydantic-field] + _validate_rut = pydantic.field_validator( 'rut', mode='before', )(_validate_rut) @@ -281,12 +281,12 @@ def parse_xml_to_dict(xml_em: XmlElement) -> Mapping[str, object]: # Validators ########################################################################### - _empty_str_to_none = pydantic.field_validator( # type: ignore[pydantic-field] + _empty_str_to_none = pydantic.field_validator( 'nombre', mode='before', )(_empty_str_to_none) - _validate_rut = pydantic.field_validator( # type: ignore[pydantic-field] + _validate_rut = pydantic.field_validator( 'rut', mode='before', )(_validate_rut) @@ -425,12 +425,12 @@ def as_dte_data_l1(self) -> cl_sii.dte.data_models.DteDataL1: # Validators ########################################################################### - _validate_rut_emisor = pydantic.field_validator( # type: ignore[pydantic-field] + _validate_rut_emisor = pydantic.field_validator( 'rut_emisor', mode='before', )(_validate_rut) - _validate_rut_receptor = pydantic.field_validator( # type: ignore[pydantic-field] + _validate_rut_receptor = pydantic.field_validator( 'rut_receptor', mode='before', )(_validate_rut) @@ -776,19 +776,19 @@ def parse_xml_to_dict(xml_em: XmlElement) -> Mapping[str, object]: # Validators ########################################################################### - _empty_str_to_none = pydantic.field_validator( # type: ignore[pydantic-field] + _empty_str_to_none = pydantic.field_validator( 'nmb_contacto', 'fono_contacto', 'mail_contacto', mode='before', )(_empty_str_to_none) - _validate_rut_cedente = pydantic.field_validator( # type: ignore[pydantic-field] + _validate_rut_cedente = pydantic.field_validator( 'rut_cedente', mode='before', )(_validate_rut) - _validate_rut_cesionario = pydantic.field_validator( # type: ignore[pydantic-field] + _validate_rut_cesionario = pydantic.field_validator( 'rut_cesionario', mode='before', )(_validate_rut)