Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated test_switch to align with dependencies (#173)
# Pull Request Template ## Description This pull request introduces essential updates to the `dependencies.py` and `test_switch.py` modules to enhance dependency management and streamline the testing process within the project. The primary changes include: 1. **Refactored `dependencies.py`:** - **Integrated Pydantic 2.0 for Inline Validation:** Implemented inline validation using Pydantic's `BaseModel` and `field_validator`, eliminating the need for external validation mechanisms. This ensures robust input validation while maintaining a lean codebase. - **Introduced `SeverityEnum`:** Utilized Python's `Enum` to define allowable severity levels (`ERROR`, `WARNING`, `NONE`), reducing the risk of typos and enhancing code clarity. - **Enhanced Type Hinting and Documentation:** Added comprehensive type hints and detailed docstrings to improve readability and maintainability. - **Logging Integration:** Configured a logger to handle warnings and informational messages, replacing direct print statements for better observability. - **PEP8 Compliance:** Ensured that the code adheres to Python's PEP8 style guidelines for consistency and readability. - **Author Attribution:** Updated the `__author__` list to include "astrogilda" alongside "fkiraly" to acknowledge contributions. 2. **Updated `test_switch.py`:** - **Aligned with Updated `dependencies.py`:** Replaced the old `_check_estimator_deps` function with the new `check_estimator_dependencies` function to maintain consistency. - **Type Hinting and Documentation:** Incorporated type hints and enhanced docstrings to clarify the function's behavior and expected inputs. - **Optimized Logic:** Simplified the dependency checking logic by directly utilizing the new `check_estimator_dependencies` function, eliminating the need for internal helper functions. - **PEP8 Compliance and Author Attribution:** Ensured consistent styling and updated the `__author__` list to include "astrogilda" for proper credit. These enhancements collectively improve the robustness, readability, and maintainability of the dependency management and testing utilities within the project, ensuring seamless integration and scalability. ## Type of change Please delete options that are not relevant. - [x] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] 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 thoroughly tested to ensure functionality and compatibility: - [x] **Unit Tests:** Updated and ran existing unit tests in `test_switch.py` to verify that the `run_test_for_class` function correctly determines whether to run tests based on dependency checks. - [x] **Static Type Checking:** Utilized type checkers (e.g., Pylance in VSCode) to ensure that type hints are correctly implemented and that no type-related errors are present. - [x] **Manual Testing:** Conducted manual tests by simulating different scenarios where dependencies are present or missing to confirm that the functions behave as expected. - [x] **PEP8 Linting:** Ran linting tools to ensure that the code adheres to PEP8 standards without introducing any style violations. ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] Any dependent changes have been merged and published in downstream modules ## Additional Information (if applicable) - **Pydantic 2.0 Usage:** Transitioned to using Pydantic's `BaseModel` and `field_validator` for inline validation, ensuring compatibility with the latest Pydantic version and enhancing input validation robustness. - **Type Checker Compatibility:** Addressed type checker (Pylance) errors by correctly handling the conversion between `str` and `SeverityEnum` using `field_validator` and suppressing false positives where necessary with `# type: ignore`. - **Logging Configuration:** The module now uses Python's built-in `logging` module, allowing for better integration with different logging configurations in various environments. - **Dependency Alignment:** Ensured that `test_switch.py` is fully aligned with the updated `dependencies.py`, maintaining consistency across modules and reducing potential integration issues. ## Add All Contributors Command Remember to acknowledge your contributions, replace `contribution_type` with your contribution (code, doc, etc.): ```plaintext @all-contributors please add @astrogilda for code, documentation ``` Co-authored-by: Sankalp Gilda <[email protected]>
- Loading branch information