-
Notifications
You must be signed in to change notification settings - Fork 0
Add type annotations for all returns and enable ruff annotation checks #43
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds explicit return type annotations to functions across the repository to comply with ruff type‐checking rules.
- Added "-> None" annotations to a variety of workflow scripts functions.
- Updated test functions with explicit return type annotations and enhanced pyproject.toml with new annotation checks.
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
workflow/scripts/realisation_to_srf.py | Added return type annotations to functions. |
workflow/scripts/plan_workflow.py | Added return type annotations to functions. |
workflow/scripts/nshm2022_to_realisation.py | Added return type annotations to functions. |
workflow/scripts/hf_sim.py | Added return type annotations to functions. |
workflow/scripts/generate_velocity_model_parameters.py | Added return type annotations to functions. |
workflow/scripts/generate_stoch.py | Added return type annotations to functions. |
workflow/scripts/generate_rupture_propagation.py | Added return type annotations to functions. |
workflow/scripts/gcmt_to_realisation.py | Added return type annotations to functions. |
workflow/scripts/gcmt_auto_simulate.py | Added return type annotations to functions. |
workflow/scripts/create_e3d_par.py | Added return type annotations to functions. |
workflow/scripts/check_srf.py | Added return type annotations to functions. |
workflow/scripts/check_domain.py | Added return type annotations to functions. |
workflow/scripts/bb_sim.py | Added return type annotations to functions. |
workflow/realisations.py | Updated parameter and return type annotations. |
workflow/log_utils.py | Updated type annotations in the log_call decorator. |
tests/*.py | Added explicit return type annotations on tests. |
pyproject.toml | Extended annotation checks with additional rules. |
Comments suppressed due to low confidence (1)
workflow/log_utils.py:87
- The wrapper function's return type is annotated as Callable, but it actually returns the result of f, which may not be a callable. Consider updating the annotation to '-> Any' or using a generic type variable to accurately represent f's return type.
def wrapper(*args: list[Any], **kwargs: dict[str, Any]) -> Callable:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds explicit return type annotations (mostly "-> None") to functions across the project and updates the ruff configuration to enforce these annotations.
- Return type annotations were added to several production functions.
- Test functions now include explicit "-> None" return types.
- The pyproject.toml file was updated with additional ruff ANN codes.
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
workflow/scripts/realisation_to_srf.py | Added "-> None" return type annotations. |
workflow/scripts/plan_workflow.py | Added "-> None" return type annotations. |
workflow/scripts/nshm2022_to_realisation.py | Added "-> None" return type annotations. |
workflow/scripts/hf_sim.py | Added "-> None" return type annotations. |
workflow/scripts/generate_velocity_model_parameters.py | Added "-> None" return type annotations. |
workflow/scripts/generate_stoch.py | Added "-> None" return type annotations. |
workflow/scripts/generate_rupture_propagation.py | Added "-> None" return type annotations. |
workflow/scripts/gcmt_to_realisation.py | Added "-> None" return type annotations. |
workflow/scripts/gcmt_auto_simulate.py | Added "-> None" return type annotations. |
workflow/scripts/create_e3d_par.py | Added "-> None" return type annotations. |
workflow/scripts/check_srf.py | Added "-> None" return type annotations. |
workflow/scripts/check_domain.py | Added "-> None" return type annotations. |
workflow/scripts/bb_sim.py | Added "-> None" return type annotations in two funcs. |
workflow/realisations.py | Added/updated return type annotations in class methods. |
workflow/log_utils.py | Added explicit type annotations to the wrapper. |
tests/test_utils.py | Updated test functions with "-> None" annotations. |
tests/test_realisation.py | Updated test functions with "-> None" annotations. |
tests/test_log_utils.py | Updated test functions with appropriate return types. |
tests/test_cli.py | Updated test function with "-> None" annotation. |
pyproject.toml | Extended ruff configuration with new ANN codes. |
Tests will fail until: fastapi/typer#1145 merges. Turns out the problem is |
This PR adds almost all annotation type checking to the project and then adds type annotations where ruff requires it.