Strengthen the types - #16
Conversation
- Replace Any types with TypedDict in device_info.py for device specs - Add ColorDiffMetrics and ColorDiffResult TypedDicts for calc_color_diff_patches - Add DetectionParams and CorrectionParams TypedDicts for analyzer - Update loose dict and list types with proper type parameters - Add CorrectionModel type alias in _factory.py - Update docstrings to reflect new type annotations - Add noqa comments for intentional Any usage in **kwargs
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
User description
PR Type
Enhancement
Description
Replace loose
dictandlisttypes with specific type parametersAdd TypedDict definitions for structured data (ColorDiffMetrics, ColorDiffResult, DetectionParams, CorrectionParams, DeviceSpecsDict)
Add CorrectionModel type alias for correction model union type
Improve error handling in CorrectionModelFactory with validation
Update docstrings to reflect new type annotations and add noqa comments for intentional Any usage
Diagram Walkthrough
File Walkthrough
det_yv8_onnx.py
Strengthen type annotations in YOLOv8 detectorcolor_correction/core/card_detection/det_yv8_onnx.py
listtolist[str]forinput/output names
input_shapetype fromtupletotuple[int, ...]for betterspecificity
_factory.py
Add type alias and improve factory error handlingcolor_correction/core/correction/_factory.py
CorrectionModeltype alias for union of correction model classesstrparameter withLiteralModelCorrectionfor type safetydictwithAnyfor**kwargswith noqa commentdocumentation
CorrectionModelaliaspolynomial.py
Strengthen polynomial model type annotationscolor_correction/core/correction/polynomial.py
Pipelinetype from sklearn for proper type annotationdictwithAnyfor**kwargswith noqa commentsself.modeltype from untyped toPipeline | Noneself.degreetype annotation tointfit()return type fromnp.ndarraytoPipelinecolor_correction.py
Add TypedDicts for color difference metricscolor_correction/services/color_correction.py
ColorDiffMetricsTypedDict for color difference metrics (min, max,mean, std)
ColorDiffResultTypedDict for structured color difference resultsdictwithAnyfor**kwargswith noqa commentcalc_color_diff_patches()return type fromdicttoColorDiffResultcorrection_analyzer.py
Add TypedDicts for detection and correction parameterscolor_correction/services/correction_analyzer.py
DetectionParamsTypedDict with optional detection_conf_thparameter
CorrectionParamsTypedDict with optional degree parameterdicttypes with specific TypedDict types in methodsignatures
np.ndarraytoImageBGRfor claritydicttodict[str, Any]for specificitydevice_info.py
Add DeviceSpecsDict TypedDict for hardware detectioncolor_correction/utils/device_info.py
DeviceSpecsDictTypedDict for device specifications with optionalfields
dict[str, Any]parameters withDeviceSpecsDictindetect_darwin, detect_linux, detect_windows functions
dict[str,Callable[[DeviceSpecsDict], DeviceSpecsDict]]DeviceSpecsDicttypeannotation
Anyimport and addCallableimportreport_generator.py
Strengthen report generator type annotationscolor_correction/utils/report_generator.py
generate_table()method signature with specific type parametersheadersparameter type fromlisttolist[Any]rowsparameter type fromlisttolist[str]