Repository navigation
MAINT: Fix the ty unsound-assignment findings in memory, cli and common (UA-7) - #4517
Open
Aditya Malkar (adimalkar) wants to merge 3 commits into
Open
Aditya Malkar (adimalkar) wants to merge 3 commits into
Aditya Malkar (adimalkar) wants to merge 3 commits into
Conversation
…on (UA-7) Fix the 12 unsound-assignment findings in pyrit/memory (without memory_models.py), pyrit/cli and pyrit/common, for microsoft#4402 (UA-7). - Type at the source: PyRITApiClient for the polling client, logging.getLevelNamesMapping() for log levels, and the typed session.scalar(select(...)) for the scenario retry count. - Validate into a local before assigning (catalog cursor, ODBC timeout, Alembic connection) and narrow the response text as object. - YamlLoadable.from_yaml_file drops its type: ignore and raises TypeError when from_dict returns another type, with a test. - cast with a comment where the type holds by construction: aioodbc.connect, the SAS token value, and the translated argv.
With their findings fixed, pyrit/memory (without memory_models.py), pyrit/cli and pyrit/common are checked by the rule. Relates to microsoft#4402
This branch has not been deployed
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.
Description
UA-7 for #4402: fixes the 12
unsound-assignmentfindings inpyrit/memory(withoutmemory_models.py),pyrit/cliandpyrit/common, and removes their eight files from the temporary override inpyproject.toml, so the rule now checks them._poll_until_terminal_asynctakes aPyRITApiClientinstead ofAny. Log levels come fromlogging.getLevelNamesMapping()instead ofgetattr(logging, ...). The scenario retry count is read with a typedsession.scalar(select(...)).objectuntil it is checked.YamlLoadable.from_yaml_filedrops its# type: ignore, and raisesTypeErrorwhen a class'sfrom_dictreturns another type. A test covers the rejected case.castwith a comment where the type holds by construction:aioodbc.connect(aioodbc ships no types), the SAS token value, and the translated argv stored by_parse_args_with_scenario_params._execute_get_seed_dataset_nameskeeps rows that arestr.SeedEntry.dataset_namehas noMappedannotation, so its rows are typedAny. Annotating it would remove this check, butmemory_models.pyis under the permanent override, so that is left for a separate change.Behavior changes, all on paths that were previously typed as impossible:
_execute_increment_scenario_number_triesraisesValueErrorif the row disappears between the update and the read. Before, it returnedNonefrom a function annotated-> int.env.pyraises when the configured connection is not a SQLAlchemyConnection, not only when it is missing.from_yaml_fileraisesTypeErrorwhenfrom_dictreturns another type, as above.This change was developed with AI assistance (Claude Code).