This PR refactors the camera compatibility script to include type annotations, improve function definitions, and update functionality for better clarity and maintainability. The following changes have been implemented:
Type Annotations Added:
Added type hints to function signatures for better readability and to support type checking.
Updated CompatibleModel class and all relevant functions with appropriate types.
Refactored find_matching_camera Function:
Updated to accept a list of CompatibleModel objects directly, improving clarity and functionality.
New tabulate_data Function:
Introduced tabulate_data function to handle data tabulation and printing, separating concerns for better modularity.
Updated identify_model_column Function:
Improved the identify_model_column function to use a set for column_values to avoid duplicate processing.
Enhanced comments and cleaned up the logic for clarity.
Improved Documentation:
Updated docstrings to reflect the new type annotations and provide clear explanations of the function parameters and return types.
Code Formatting:
Made minor adjustments to align with PEP 8 and improve code readability.
Changes
CompatibleModel class:
Added type annotations to the init and str methods.
Function Definitions:
get_camera_list: Updated type hints to handle List[CompatibleModel] and Dict[str, CompatibleModel].
find_matching_camera: Changed to accept verkada_cameras as a parameter.
parse_compatibility_list: Updated docstring to reflect new return type.
read_customer_list: Simplified return type annotation.
tabulate_data: Added to handle data printing in a tabulated format.
identify_model_column: Updated to use a set for column values and added improved comments.
Updated stubs:
process stub is updated so the expected tuple output is correct.
Example Usage
The refactored functions now include type hints, making it easier to understand the expected inputs and outputs. For instance, the identify_model_column function now requires both the raw customer data and the list of Verkada camera models to determine the best matching column index.
Type of change
[x] Bug fix (non-breaking change which fixes an issue)
[x] New feature (non-breaking change which adds functionality)
[x] Breaking change (fix or feature that would cause existing functionality to not work as expected)
[ ] This change requires a documentation update
How Has This Been Tested?
The changes have been tested with CSV outputs using the following steps:
Ran the script using the CSV found in the repository.
Checked output printed in terminal was formatted properly.
Checked the output saved to the file matched the original output.
Gone Global
Description
This PR refactors the camera compatibility script to include type annotations, improve function definitions, and update functionality for better clarity and maintainability. The following changes have been implemented:
Type Annotations Added:
Refactored find_matching_camera Function:
New tabulate_data Function:
Updated identify_model_column Function:
Improved Documentation:
Code Formatting:
Changes
CompatibleModel class:
Function Definitions:
Updated stubs:
Example Usage
The refactored functions now include type hints, making it easier to understand the expected inputs and outputs. For instance, the identify_model_column function now requires both the raw customer data and the list of Verkada camera models to determine the best matching column index.
Type of change
How Has This Been Tested?
The changes have been tested with CSV outputs using the following steps:
Test Configuration:
Checklist