Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mypy #14

Merged
merged 77 commits into from
Dec 24, 2024
Merged

Fix mypy #14

merged 77 commits into from
Dec 24, 2024

Conversation

tunglxfast
Copy link
Contributor

@tunglxfast tunglxfast commented Dec 12, 2024

Begin with: 407 errors in 88 files (checked 230 source files)

@tunglxfast
Copy link
Contributor Author

Error left: 63 errors in 19 files.
@ake2l Hi Alex, can you take a look. For those errors left, I marked them with annotation @TODO: mypy issue and Dang will refactor them later.

@tunglxfast tunglxfast requested a review from ake2l December 18, 2024 08:32
@ake2l ake2l self-assigned this Dec 18, 2024
ake2l and others added 15 commits December 23, 2024 08:40
…tions. Clean up test cases for MongoDB, MSSQL, MySQL, and PostgreSQL performance measurements. Fix minor issues in test scripts and ensure consistency across test data files.
- Updated mypy version in pyproject.toml from 1.8.0 to 1.14.0.
- Enhanced README.md by improving headings and adding a badge for Trunk version.
- Refactored code in various files to improve type hinting and ensure better handling of optional parameters.
- Adjusted the logic in RdbmsClient and DataSourceUtil to handle pagination and data retrieval more robustly.
- Cleaned up the demo condition info.toml file by removing extra spaces in the title.
- Updated environment setup script for better readability.

These changes aim to improve the overall maintainability and clarity of the project.
…ing and optional parameter management (mypy fixes)

- Updated DataSourceUtil to check for statement type when accessing memstore.
- Modified CSVExporter to handle empty fieldnames and added a check for buffer file existence before writing.
- Enhanced UnifiedBufferedExporter with better buffer file initialization and metadata update logic, including retry mechanisms.
- Improved XMLExporter to ensure buffer file checks are in place before writing data.

These changes enhance the robustness and maintainability of the data export process.
…ement start times and task exporters

- Added a dictionary to track statement start times in the Context class.
- Introduced a dictionary for task exporters in the SetupContext class, along with corresponding getter and setter methods.
- Updated references in generate_task.py to utilize the new task exporters property instead of the private attribute.
- Cleaned up commented-out code in generate_task.py and task_util.py for better readability.

These changes improve the structure and maintainability of the context management system.
- Updated the _get_entity method to accept a more general Context type instead of SetupContext, enhancing flexibility.
- Adjusted the execute method to utilize the new Context type, allowing for broader context compatibility.
- Refined logic for determining variable prefixes and suffixes by ensuring proper context type checks, improving robustness.

These changes enhance the maintainability and adaptability of the VariableTask class within the context management system.
…pe consistency

- Updated the execute methods in KeyTask and NestedKeyTask to accept a more general Context type instead of the specific GenIterContext, enhancing flexibility.
- Added type checks to ensure that certain operations are only performed when the context is of type GenIterContext, improving robustness.
- Refined logic for adding current product fields based on context type, ensuring better compatibility with different context scenarios.

These changes enhance the maintainability and adaptability of the task classes within the context management system.
…and optional parameters

- Updated the `get_cyclic_data` method in `DatabaseClient` to allow `pagination` to be optional.
- Enhanced `SetupContext` to provide default values for `default_separator` and `default_locale` if not specified.
- Refined type hints in `KeyVariableTask` for `_generator` and improved handling of optional parameters in various methods.
- Adjusted `VariableTask` to ensure `statement.cyclic` defaults to `False` when not provided.

These changes enhance type safety and flexibility across the database client and task management system.
…and SQLAlchemy 2.x compatibility

- Updated SQLAlchemy queries to align with version 2.x standards, enhancing compatibility and performance.
- Refined the `consume` method in `DatabaseExporter` to improve type hints and handle optional metadata.
- Enhanced pagination handling in `RdbmsClient` methods to ensure robust data retrieval.
- Improved error handling in sequence number management, ensuring better transaction safety and clarity.

These changes enhance the maintainability and adaptability of the database client and exporter components.
Co-authored-by: Dang Ly <[email protected]>
- Cleaned up mypy-related comments and issues in various task classes, enhancing type consistency and clarity.
- Updated type hints in `datamimic_ce/__init__.py` and `datamimic_ce/data_sources/data_source_util.py` for better type safety.
- Removed unnecessary `continue-on-error` lines in GitHub Actions workflow.
- Improved handling of required environment variables and pagination in data processing functions.

These changes improve code maintainability and type safety throughout the project.
…ation

- Added command to install mypy types in the GitHub Actions workflow for improved type checking.
- Refined import statements in `generate_task.py` by removing unnecessary imports and ensuring proper usage of `OrderedDict`.

These changes improve type safety and streamline the development workflow.
- Upgraded psutil dependency to version 6.1.0 for improved performance and compatibility.
- Added pandas-stubs, types-psutil, and types-xmltodict to dev-dependencies for enhanced type checking.
- Removed the mypy types installation command from the GitHub Actions workflow to streamline the process.
- Introduced new pytest configuration options for better async test handling.

These changes enhance type safety, improve dependency management, and optimize the development workflow.
@ake2l ake2l merged commit d3545bc into development Dec 24, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants