Repository navigation
Refactor task buffer type declarations and improve type checking - #878
Merged
Merged
Conversation
run_logged_task_command, log_task_commands and _command_logging_modules took the task buffer as Any, though their docstrings say TaskBuffer and common.py already imports it for type checking. They now declare it, so the calls to insert_task_command and set_task_command_response are checked against the DB proxy's signatures. They match. The test registers a fake that implements only what run_logged_task_command uses, and now casts it.
The EvpThr threads of recover_lost_files_daemon and evpPD2P are given the server's TaskBuffer, as each daemon's main already declares. get_params_to_get_tasks is given a JediTaskBufferInterface by JobGenerator and a JediTaskBuffer by the job generator message processor, so it takes either, as JobGeneratorThread already does. After this no task buffer in pandaserver or pandajedi is declared Any.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves type safety across several modules by replacing generic
Anytypes with more specific"TaskBuffer"type annotations. This helps clarify function signatures and class constructors, making the codebase easier to understand and maintain. Additionally, minor updates were made to the test suite to ensure compatibility with these type changes.Type annotation improvements:
pandaserver/api/v1/common.pyto use"TaskBuffer"instead ofAny, including the_command_logging_modulesdictionary and related functions. [1] [2]taskBufferIFparameter in theget_params_to_get_tasksfunction inpandajedi/jediorder/JobGenerator.pyto use a more precise type annotation:"JediTaskBufferInterface | JediTaskBuffer".Test suite adjustments:
pandaserver/api/v1/tests/task_command_log_tests.py, usedTYPE_CHECKINGandcastto ensure that the fake task buffer is treated as a"TaskBuffer"for type checking purposes. [1] [2] [3]Daemon script updates:
EvpThrthread classes inpandaserver/daemons/scripts/evpPD2P.pyandpandaserver/daemons/scripts/recover_lost_files_daemon.pyto require a"TaskBuffer"instead ofAny. [1] [2]