Commit f86ef4b3 authored by Pierre Dittgen's avatar Pierre Dittgen
Browse files

Fix mypy issues

parent 65ec9423
......@@ -6,6 +6,7 @@ import logging
from collections import Counter
from datetime import datetime
from pathlib import Path
from typing import Any, Dict, List
from urllib.parse import urlencode, urljoin
import frictionless
......@@ -215,7 +216,7 @@ def create_validata_ui_report(rows_count: int, validata_core_report, schema_dict
v_report = copy.deepcopy(validata_core_report.to_dict())
# Create a new UI report from information picked in validata report
ui_report = {}
ui_report: Dict[str, Any] = {}
ui_report["table"] = {}
# source headers
......@@ -268,7 +269,7 @@ def create_validata_ui_report(rows_count: int, validata_core_report, schema_dict
ui_report["table"]["errors"]["body"].append(err)
# Group body errors by row id
rows = []
rows: List[Dict] = []
current_row_id = 0
for err in ui_report["table"]["errors"]["body"]:
if "rowPosition" not in err:
......@@ -287,7 +288,7 @@ def create_validata_ui_report(rows_count: int, validata_core_report, schema_dict
# Sort by error names in statistics
ui_report["table"]["count-by-code"] = {}
stats = {}
stats: Dict[str, Any] = {}
total_errors_count = 0
for key in ("structure", "body"):
# convert dict into tuples with french title instead of error code
......@@ -412,11 +413,11 @@ def validate(schema_instance: SchemaInstance, validata_resource: ValidataResourc
if err["code"] in {"source-error", "unknown-csv-dialect"}
]
if source_errors:
err = source_errors[0]
source_error = source_errors[0]
msg = (
"l'encodage du fichier est invalide. Veuillez le corriger"
if "charmap" in err["message"]
else err["message"]
if "charmap" in source_error["message"]
else source_error["message"]
)
flash_error("Erreur de source : {}".format(msg))
return redirect(url_for("custom_validator"))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment