File tree Expand file tree Collapse file tree 4 files changed +51
-2
lines changed
Expand file tree Collapse file tree 4 files changed +51
-2
lines changed Original file line number Diff line number Diff line change 5555 pip install pytest
5656 pytest -q
5757
58+ - name : Type-check backend (mypy)
59+ run : |
60+ pip install mypy
61+ mypy backend
62+
5863
Original file line number Diff line number Diff line change 1212from flask_cors import CORS
1313import logging
1414from werkzeug .utils import secure_filename
15+ from backend .types import BasicAnalysis
1516from bleach .sanitizer import Cleaner
1617from backend .errors import register_error_handlers , ValidationError
1718
@@ -68,12 +69,12 @@ def _block_external_url_fetcher(url):
6869 }
6970})
7071
71- def perform_basic_analysis (df : pd .DataFrame ) -> dict :
72+ def perform_basic_analysis (df : pd .DataFrame ) -> BasicAnalysis :
7273 """Выполняет базовый анализ данных DataFrame."""
7374 logger .debug (f"Starting basic analysis. DataFrame shape: { df .shape } " )
7475 logger .debug (f"DataFrame columns: { df .columns .tolist ()} " )
7576
76- analysis = {
77+ analysis : BasicAnalysis = {
7778 'numeric_columns' : {},
7879 'string_columns' : {}
7980 }
Original file line number Diff line number Diff line change 1+ from typing import TypedDict , Dict , List , Any
2+
3+
4+ class NumericStats (TypedDict ):
5+ sum : float
6+ mean : float
7+ min : float
8+ max : float
9+
10+
11+ class StringStats (TypedDict ):
12+ unique_values_count : int
13+ unique_values : List [str ]
14+
15+
16+ class BasicAnalysis (TypedDict ):
17+ numeric_columns : Dict [str , NumericStats ]
18+ string_columns : Dict [str , StringStats ]
19+
20+
21+ class FileUploadResponse (TypedDict ):
22+ table_data : List [Dict [str , Any ]]
23+ columns : List [str ]
24+ total_rows : int
25+ current_page : int
26+ page_size : int
27+ total_pages : int
28+ basic_analysis : BasicAnalysis
29+
30+
Original file line number Diff line number Diff line change 1+ [mypy]
2+ python_version = 3.12
3+ ignore_missing_imports = True
4+ warn_unused_ignores = True
5+ warn_redundant_casts = True
6+ warn_unused_configs = True
7+ strict_optional = True
8+
9+ [mypy-backend.*]
10+ disallow_untyped_defs = True
11+ check_untyped_defs = True
12+
13+
You can’t perform that action at this time.
0 commit comments