patched-codes / patchwork

Automate development gruntwork like code reviews, patching and documentation with LLM workflows.
https://patched.codes
GNU Affero General Public License v3.0
722 stars 40 forks source link

Typing Metadata #290

Closed CTY-git closed 1 month ago

patched-admin commented 1 month ago
A new constant variable "IS_CONFIG" has been added to the types.py file in the patchwork/common/utils directory. The code changes in typed.py include updating the fields in the AnalyzeImpactInputs and AnalyzeImpactOutputs classes to use `list` instead of `Iterable`, adjusting the import statement for TypedDict, and adding a future import of annotations. Import statements were updated to include IS_CONFIG from patchwork.common.utils.types, and headers and method attributes in the CallAPIInputs class were modified with Annotated for metadata. Additionally, various classes were updated with annotations and IS_CONFIG type hints for specific attributes. The modifications include restructuring classes, adding new import statements, and using Annotated for type hinting along with changes to attribute types and metadata annotations. ------
* File changed: [patchwork/common/utils/types.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-1e0c89fe67a72a4a9d6b5e87927d9edd327df46f713bba6e47b5b0a2e6e57220) [A new constant variable "IS_CONFIG" has been added to the types.py file in the patchwork/common/utils directory.](https://github.com/patched-codes/patchwork/pull/290/files#diff-1e0c89fe67a72a4a9d6b5e87927d9edd327df46f713bba6e47b5b0a2e6e57220)
* File changed: [patchwork/steps/AnalyzeImpact/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-0210bb94d8db916e7dd0640f9344deeffaf272703c61ecf2bb86d2cbf6c3ebd6) [The code in the file typed.py was updated to use `list` instead of `Iterable` for the `extracted_responses` and `files_to_patch` fields in the `AnalyzeImpactInputs` and `AnalyzeImpactOutputs` classes, respectively. Additionally, the import statement for `TypedDict` was adjusted, and a future import of annotations was added.](https://github.com/patched-codes/patchwork/pull/290/files#diff-0210bb94d8db916e7dd0640f9344deeffaf272703c61ecf2bb86d2cbf6c3ebd6)
* File changed: [patchwork/steps/CallAPI/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-8fa197c3ad1cfd5d1075cbc9d1521c9895ea4b31f374d1ec6a29c2afe6ac1272) [The code in typed.py now includes an import statement for IS_CONFIG from patchwork.common.utils.types. The headers and method attributes in the CallAPIInputs class have been updated to use Annotated to specify additional metadata.](https://github.com/patched-codes/patchwork/pull/290/files#diff-8fa197c3ad1cfd5d1075cbc9d1521c9895ea4b31f374d1ec6a29c2afe6ac1272)
* File changed: [patchwork/steps/CallCode2Prompt/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-3fa21a47891c507393238ccbcdbb3a01453431426de50b7ccce7423e135f20cc) [The diff updates the import statement to include a new module "Annotated" and adds a new import statement for "IS_CONFIG" from a different module. It also modifies the structure of the "CallCode2PromptInputs" class, changing the attribute types to use the Annotated type with IS_CONFIG annotations.](https://github.com/patched-codes/patchwork/pull/290/files#diff-3fa21a47891c507393238ccbcdbb3a01453431426de50b7ccce7423e135f20cc)
* File changed: [patchwork/steps/CallLLM/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-7eee5f695e6a689150f65f01187311311ea8560450c433ec8637b6bffbf3795c) [The changes in the diff indicate a modification in the imports for type annotations, as well as the introduction of a new import from "patchwork.common.utils.types" called "IS_CONFIG." The "CallLLMInputs" class has been updated to include new annotations using "Annotated" and "IS_CONFIG," with changes in the type hints for various attributes.](https://github.com/patched-codes/patchwork/pull/290/files#diff-7eee5f695e6a689150f65f01187311311ea8560450c433ec8637b6bffbf3795c)
* File changed: [patchwork/steps/CommitChanges/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-a3309e50ef033035edb67fdc62c1f211add096f9557444b28bcaead7ad48acef) [In the "CommitChanges/typed.py" file, the "CommitChangesInputs" class is modified to include new annotations using the "Annotated" module from "typing_extensions" for the fields "disable_branch," "force_branch_creation," "branch_prefix," and "branch_suffix" with an additional imported "IS_CONFIG" from "patchwork.common.utils.types." The original "disable_branch" and "force_branch_creation" fields are replaced, and a new "__CommitChangesRequiredInputs" class is introduced to represent the required inputs separately.](https://github.com/patched-codes/patchwork/pull/290/files#diff-a3309e50ef033035edb67fdc62c1f211add096f9557444b28bcaead7ad48acef)
* File changed: [patchwork/steps/CreateIssue/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-420cbe90b0d0a1c1c583967e9f3126742b24adb5c55b183f3b68701266268ce8) [The code in the `typed.py` file was modified to refactor the `CreateIssueInputs` class by introducing a new class `__CreateIssueRequiredInputs` with annotated fields, and then inheriting from it in the `CreateIssueInputs` class with additional annotated fields for `gitlab_api_key` and `github_api_key`. Additionally, a new import statement was added for `IS_CONFIG` from `patchwork.common.utils.types`.](https://github.com/patched-codes/patchwork/pull/290/files#diff-420cbe90b0d0a1c1c583967e9f3126742b24adb5c55b183f3b68701266268ce8)
* File changed: [patchwork/steps/CreateIssueComment/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-bfa35e5abf689e4b59cf8df582fc552001dfee6b1a3524ccd155b5ebcfde734a) [The import statement in typed.py was updated to include Annotated from typing_extensions instead of NotRequired. The CreateIssueCommentInputs class was modified to include annotations for issue_text and issue_url as Annotated[str, IS_CONFIG], and the class now also inherits from __CreateIssueCommentRequiredInputs and includes annotations for scm_url, gitlab_api_key, and github_api_key with IS_CONFIG type.](https://github.com/patched-codes/patchwork/pull/290/files#diff-bfa35e5abf689e4b59cf8df582fc552001dfee6b1a3524ccd155b5ebcfde734a)
* File changed: [patchwork/steps/CreatePR/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-27b139e8d7ae3df11f774d449f6a94be0f14cf4fd728b421bfaebd2ad0a2f8cd) [The code in the patchwork/steps/CreatePR/typed.py file has been updated to replace the NotRequired type with Annotated from the typing_extensions module. Additionally, a new class named __CreatePRRequiredInputs was introduced along with changes to the CreatePRInputs class, including adding Annotated types and a new IS_CONFIG dependency from the patchwork.common.utils.types module.](https://github.com/patched-codes/patchwork/pull/290/files#diff-27b139e8d7ae3df11f774d449f6a94be0f14cf4fd728b421bfaebd2ad0a2f8cd)
* File changed: [patchwork/steps/CreatePRComment/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-4a0d54503f40d3616fb1f410b35233850e5de1317b6e9491509eda476754c48b) [The import statement in the file is changed to include "Annotated" from typing_extensions. The class "CreatePRCommentInputs" is modified to include additional annotations for the fields "noisy_comments," "scm_url," "gitlab_api_key," and "github_api_key" with the annotation "IS_CONFIG."](https://github.com/patched-codes/patchwork/pull/290/files#diff-4a0d54503f40d3616fb1f410b35233850e5de1317b6e9491509eda476754c48b)
* File changed: [patchwork/steps/ExtractCode/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-5c1e2a2836257b700cb10be3bf510e23fab57827619db331c20131171e236ecf) [The diff in the typed.py file adds an import statement for Annotated and IS_CONFIG from typing_extensions and a new import from patchwork.common.utils.types. It also introduces a new class __ExtractCodeRequiredInputs that extends from TypedDict and modifies the ExtractCodeInputs class to include annotations for context_size, vulnerability_limit, and severity fields.](https://github.com/patched-codes/patchwork/pull/290/files#diff-5c1e2a2836257b700cb10be3bf510e23fab57827619db331c20131171e236ecf)
* File changed: [patchwork/steps/ExtractCodeContexts/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-d8eecbb3f8fa7ec847484357e85e0804faa3f570bc6c1f336a9735a7e31649ba) [The code in the file "typed.py" has been modified to include a new import statement and two new classes. The import statement now includes "__future__" annotations, while two new classes, "ExtractCodeContextsInputs" and "ExtractCodeContextsOutputs", have been added with specific attributes and annotations.](https://github.com/patched-codes/patchwork/pull/290/files#diff-d8eecbb3f8fa7ec847484357e85e0804faa3f570bc6c1f336a9735a7e31649ba)
* File changed: [patchwork/steps/ExtractCodeMethodForCommentContexts/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-578219c0a72cc57e3d957bde0d2116b8758726b9874566a3fef6dce00ccb0eae) [The code in the file has been updated to use "__future__ annotations" instead of importing "NotRequired" and "Iterable". Two new classes "ExtractCodeMethodForCommentContextsInputs" and "ExtractCodeMethodForCommentContextsOutputs" have been defined with different annotations for "base_path" and "context_grouping".](https://github.com/patched-codes/patchwork/pull/290/files#diff-578219c0a72cc57e3d957bde0d2116b8758726b9874566a3fef6dce00ccb0eae)
* File changed: [patchwork/steps/ExtractDiff/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-5ce2d61d50376ec99b97875207947d0fb5fd6cef8158ee6407a4781eb8e37c08) [In the specified Python file, the import statement for `NotRequired` from `typing_extensions` is replaced with `Annotated`. Additionally, the `ExtractDiffInputs` class is modified to include annotations for `libraries_api_key`, `github_api_key`, and `severity`, using the `IS_CONFIG` type from a custom module.](https://github.com/patched-codes/patchwork/pull/290/files#diff-5ce2d61d50376ec99b97875207947d0fb5fd6cef8158ee6407a4781eb8e37c08)
* File changed: [patchwork/steps/ExtractModelResponse/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-dd60930006e1570f77dfda74df19e1979df7f2516246b52c1040114bdeaf6911) [The code in the file "typed.py" in the "ExtractModelResponse" module has been modified to change the import from "NotRequired" to "Annotated" from the "typing_extensions" module. Additionally, a new import from "patchwork.common.utils.types" has been added and the structure and annotation of the "ExtractModelResponseInputs" class has been updated to include a new class "__ExtractModelResponseRequiredInputs" and use "Annotated" for type hinting.](https://github.com/patched-codes/patchwork/pull/290/files#diff-dd60930006e1570f77dfda74df19e1979df7f2516246b52c1040114bdeaf6911)
* File changed: [patchwork/steps/ExtractPackageManagerFile/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-89d8ddc4136c84ccac973b18c0c0108bd4fbbf556228028afcc035aea050c02f) [The diff includes changing the import statement in the typed.py file to use future annotations, adding Annotated type from typing_extensions, and updating the ExtractPackageManagerFileInputs class to include Annotated types for the specified fields, along with importing IS_CONFIG from the common.utils.types module.](https://github.com/patched-codes/patchwork/pull/290/files#diff-89d8ddc4136c84ccac973b18c0c0108bd4fbbf556228028afcc035aea050c02f)
* File changed: [patchwork/steps/GenerateCodeRepositoryEmbeddings/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-9892f9a1373719655ec7138b82fdc27beaea41aee11d2d0941cf33acadeccb3b) [The code in the file typed.py was updated to import Annotated from typing_extensions instead of NotRequired, and now the disable_cache key in the GenerateCodeRepositoryEmbeddingsInputs class is annotated with the IS_CONFIG type. Additionally, the total parameter was added to the GenerateCodeRepositoryEmbeddingsInputs class.](https://github.com/patched-codes/patchwork/pull/290/files#diff-9892f9a1373719655ec7138b82fdc27beaea41aee11d2d0941cf33acadeccb3b)
* File changed: [patchwork/steps/GenerateEmbeddings/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-1ee879098ead0c92c1757b552fab866b9ac38799a9843a6d52b558048584673d) [The code in the file "typed.py" has been updated to use the "Annotated" class from typing_extensions for type hinting. The class GenerateEmbeddingsInputs has been restructured to include a new class __GenerateEmbeddingsRequiredInputs and the annotation for the fields "embedding_name" and "disable_cache" have been modified to use the Annotated class with IS_CONFIG.](https://github.com/patched-codes/patchwork/pull/290/files#diff-1ee879098ead0c92c1757b552fab866b9ac38799a9843a6d52b558048584673d)
* File changed: [patchwork/steps/LLM/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-e2b864381f414aeeb9fbd5a90666b56a6715b36c5bef760a0cbbebe94e0487c0) [The code in the typed.py file has been updated to include annotations from the typing_extensions module such as Annotated. Additionally, the use of Annotated with IS_CONFIG has been added to specify configuration details for various attributes in the classes defined within the file.](https://github.com/patched-codes/patchwork/pull/290/files#diff-e2b864381f414aeeb9fbd5a90666b56a6715b36c5bef760a0cbbebe94e0487c0)
* File changed: [patchwork/steps/ModifyCode/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-3e303aefd271baac9cc6af3019ea4a82081b96c97121304f21a5c6bc5fee5c19) [The diff in the file `typed.py` changes the `Iterable` type to `list` for the attributes `files_to_patch` and `extracted_responses` within the `ModifyCodeInputs` class.](https://github.com/patched-codes/patchwork/pull/290/files#diff-3e303aefd271baac9cc6af3019ea4a82081b96c97121304f21a5c6bc5fee5c19)
* File changed: [patchwork/steps/PR/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-7314b3f35a75a646a72bd4fee80989b2deef7d1729f3ac1f916f1d22818f7448) [The patchwork/steps/PR/typed.py file has been modified to include annotations from the typing_extensions module and a new import statement from patchwork.common.utils.types. The class PRInputs now has added annotations specifying that certain attributes are configurations.](https://github.com/patched-codes/patchwork/pull/290/files#diff-7314b3f35a75a646a72bd4fee80989b2deef7d1729f3ac1f916f1d22818f7448)
* File changed: [patchwork/steps/PreparePR/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-0d5994fe0e2db916ef55cbf5769416324ea2414a8b3816f1b1af9638eafb3b00) [The import statement in the code has been changed to use 'Annotated' instead of 'NotRequired' from the 'typing_extensions' module. Additionally, the 'PreparePRInputs' class has been split into two classes, with 'pr_header' now being a part of a separate class '__PreparePRRequiredInputs' and using 'Annotated' with 'IS_CONFIG'. The original 'PreparePRInputs' class is now a subclass of '__PreparePRRequiredInputs' and 'total=False'.](https://github.com/patched-codes/patchwork/pull/290/files#diff-0d5994fe0e2db916ef55cbf5769416324ea2414a8b3816f1b1af9638eafb3b00)
* File changed: [patchwork/steps/PreparePrompt/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-7f16e6f4ea0ee98d9db05990b169e17c3fc7046d7d30c9ed46dce588dccf6fb7) [The code in the `PreparePrompt` class has been updated to use the `Annotated` type hint from `typing_extensions` for `prompt_template_file`, `prompt_id`, `prompt_value_file`, and `prompt_values`. Additionally, the `PreparePromptInputs` class has been split into `__PreparePromptRequiredInputs` and `PreparePromptInputs`, where `prompt_template_file` and `prompt_id` are required fields annotated with the `IS_CONFIG` type, and `prompt_value_file` and `prompt_values` are optional fields with specific types.](https://github.com/patched-codes/patchwork/pull/290/files#diff-7f16e6f4ea0ee98d9db05990b169e17c3fc7046d7d30c9ed46dce588dccf6fb7)
* File changed: [patchwork/steps/QueryEmbeddings/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-c3e145f6838c6c2978161f27ad80cefeb64c9a35d3e484fc2cb02f8150433e36) [The code in the typed.py file introduces changes to the QueryEmbeddingsInputs class by adding new annotations using Annotated and IS_CONFIG, and modifying the class structure to include required and optional inputs for embedding_name, texts, top_k, and token_limit.](https://github.com/patched-codes/patchwork/pull/290/files#diff-c3e145f6838c6c2978161f27ad80cefeb64c9a35d3e484fc2cb02f8150433e36)
* File changed: [patchwork/steps/ReadIssues/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-7d1aa186c520609e13cf4d79e08e7d77310535ef745bc416832be91d6d550e4b) [The code in the `type.py` file has been modified to change the import statement from `NotRequired` to `Annotated` from the `typing_extensions` module. Additionally, a new class `__ReadIssuesRequiredInputs` has been defined with the `issue_url` attribute annotated with `IS_CONFIG`, and the existing class `ReadIssuesInputs` has been updated to include the attributes `scm_url`, `gitlab_api_key`, and `github_api_key` also annotated with `IS_CONFIG`.](https://github.com/patched-codes/patchwork/pull/290/files#diff-7d1aa186c520609e13cf4d79e08e7d77310535ef745bc416832be91d6d550e4b)
* File changed: [patchwork/steps/ReadPRDiffs/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-3620f5358988da86a1fa4499b6cbe59782ed86a5f963e2932ce8e1b11a8e19c0) [The code in the file "typed.py" has been updated to use annotations from the typing_extensions module, specifically switching from NotRequired to Annotated. The ReadPRDiffsInputs class has been modified to include the Annotated type for certain fields and a new __ReadPRDiffsRequiredInputs class has been introduced to manage required fields.](https://github.com/patched-codes/patchwork/pull/290/files#diff-3620f5358988da86a1fa4499b6cbe59782ed86a5f963e2932ce8e1b11a8e19c0)
* File changed: [patchwork/steps/ScanDepscan/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-a2edab78802b1fffb21854873bbf007b13225bacceb2f0e1e033008f68233fe1) [The 'NotRequired' import from 'typing_extensions' is replaced with 'Annotated', and 'IS_CONFIG' is imported from 'patchwork.common.utils.types'. The 'ScanDepscanInputs' class is updated with 'total=False' parameter and 'language' field is annotated with 'IS_CONFIG'.](https://github.com/patched-codes/patchwork/pull/290/files#diff-a2edab78802b1fffb21854873bbf007b13225bacceb2f0e1e033008f68233fe1)
* File changed: [patchwork/steps/ScanSemgrep/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-991501aea1546627b4e9fffef92362d229dda67cd3f061ea8d3ad69717a6f238) [The Python file has been modified to change the imported module from NotRequired to Annotated, and a new imported module IS_CONFIG has been added. The class ScanSemgrepInputs has also been updated to change the data types and add annotations for the attributes sarif_file_path and semgrep_extra_args.](https://github.com/patched-codes/patchwork/pull/290/files#diff-991501aea1546627b4e9fffef92362d229dda67cd3f061ea8d3ad69717a6f238)
* File changed: [patchwork/steps/SlackMessage/typed.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-2279f331d8818bdd107804d08761e4d91122b3fcb3700b3ae90771b7de0a96b8) [The changes in the code involve replacing the `NotRequired` import with `Annotated` and adding an import statement for `IS_CONFIG`. Additionally, the `Annotated` type is applied to the `slack_channel` and `slack_token` fields in the `SlackMessageRequiredInputs` class, as well as to the `slack_message_template_file` and `slack_message_template` fields in the `SlackMessageInputs` class.](https://github.com/patched-codes/patchwork/pull/290/files#diff-2279f331d8818bdd107804d08761e4d91122b3fcb3700b3ae90771b7de0a96b8)
* File changed: [tests/steps/test_CallAPI.py](https://github.com/patched-codes/patchwork/pull/290/files#diff-c46e9dd1f6b159f8daf0772e63a5d40b86750e6a29788db3d13720150e653df1) [The changes in this diff involve reordering the lines of code related to setting the expected headers and making the API call in the test case for calling an API in the "test_CallAPI.py" file. The lines related to setting and checking the expected body of the request have been removed from the test.](https://github.com/patched-codes/patchwork/pull/290/files#diff-c46e9dd1f6b159f8daf0772e63a5d40b86750e6a29788db3d13720150e653df1)