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
835 stars 51 forks source link

Test branch #647

Closed CTY-git closed 3 weeks ago

CTY-git commented 3 weeks ago
## File Changed: `patchwork/common/client/scm.py` Details: Ensure to use snake_case for function names in Python instead of camelCase. Lambda variable `branch_checker` should not use camelCase. Affected Code Snippet: ```python branch_checker = lambda pr: True if original_branch is not None: branch_checker = lambda pr: branch_checker and pr.base.ref == original_branch if feature_branch is not None: branch_checker = lambda pr: branch_checker and pr.head.ref == feature_branch ``` Start Line: 437 End Line: 441 ## File Changed: `patchwork/steps/Combine/Combine.py` Details: Method lacks a docstring. Functions should have detailed descriptions covering parameters, types, return values, and purpose. Affected Code Snippet: ```python @@ -18,7 +18,7 @@ def run(self): ``` Start Line: 18 End Line: 18 ------------- ## File Changed: `patchwork/steps/ModifyCode/ModifyCode.py` Details: The function replace_code_in_file uses snake_case for its name and the arguments. However, the parameters initialized within the function, specifically start_line and end_line, should also adhere to the naming conventions and use snake_case. Affected Code Snippet: ```python +def replace_code_in_file(file_path: str, start_line: int | None, end_line: int | None, new_code: str,) -> None: + path = Path(file_path) ``` Start Line: 12 End Line: 17 ------------- Details: In the function replace_code_in_file, detailed docstrings adhering to the Google-style format are missing. Affected Code Snippet: ```python +def replace_code_in_file(file_path: str, start_line: int | None, end_line: int | None, new_code: str,) -> None: ``` Start Line: 12 End Line: 17 ------------- Details: Handling the existence check for file_path within replace_code_in_file lacks specific errors or detailed messages. Affected Code Snippet: ```python + if path.exists(): ``` Start Line: 16 End Line: 17 ------------- Details: The code modifications do not provide handling for None types within the parameter validation. Affected Code Snippet: ```python + lines[start_line:end_line] = handle_indent(lines, new_code.splitlines(keepends=True), start_line, end_line) ``` Start Line: 24 End Line: 25 ------------- Details: Imports are not sorted following `isort` guidelines and explicit imports for introduced modules have been added accordingly. Affected Code Snippet: ```python +from pathlib import Path ``` Start Line: 3 End Line: 4 ## File Changed: `patchwork/steps/ModifyCodePB/ModifyCodePB.py` Details: The function `run` is defined in camelCase. Python convention mandates the use of snake_case for function names. Affected Code Snippet: ```python def run(self) -> dict: ``` Start Line: 11 End Line: 11 ------------- Details: No docstrings are present for the functions. Including detailed descriptions with parameters, types, return values, and function purpose is essential. Affected Code Snippet: ```python def __init__(self, inputs: dict): ``` Start Line: 2 End Line: 4 ------------- Details: Inputs and outputs are not clearly defined using TypedDict. Clear typing conventions should be used for better readability and type checking. Affected Code Snippet: ```python def __init__(self, inputs: dict): def run(self) -> dict: ``` Start Line: 2 End Line: 11 [{'Details': 'The variable name `key_map` and class name `PRPB` could be more descriptive.', 'Affected Code Snippet': '```python\nkey_map = dict(path=inputs["path_key"])\n```', 'Start Line': 9, 'End Line': 9}, {'Details': '`__init__.py` is missing in the diff output', 'Affected Code Snippet': 'N/A', 'Start Line': 'N/A', 'End Line': 'N/A'}, {'Details': 'No docstrings are provided for functions and class.', 'Affected Code Snippet': '```python\nclass PRPB(Step, input_class=PRPBInputs, output_class=PRPBOutputs):\n```', 'Start Line': 5, 'End Line': 5}, {'Details': 'No docstrings found.', 'Affected Code Snippet': '```python\ndef __init__(self, inputs):\n```', 'Start Line': 7, 'End Line': 7}, {'Details': 'No docstrings found.', 'Affected Code Snippet': '```python\ndef run(self):\n```', 'Start Line': 20, 'End Line': 20}, {'Details': 'No type annotations for function parameters and return values', 'Affected Code Snippet': '```python\ndef __init__(self, inputs):\n```', 'Start Line': 7, 'End Line': 7}, {'Details': 'No type annotations for function parameters and return values', 'Affected Code Snippet': '```python\ndef run(self):\n```', 'Start Line': 20, 'End Line': 20}, {'Details': 'Double quotes are inconsistently used for dictionary keys', 'Affected Code Snippet': '```python\nkey_map = dict(path=inputs["path_key"])\n```', 'Start Line': 9, 'End Line': 9}] ## File Changed: `patchwork/steps/PRPB/typed.py` Details: The file `__init__.py` should be included in the module even if empty. Affected Code Snippet: N/A Start Line: N/A End Line: N/A ------------- Details: No README.md found. Affected Code Snippet: N/A Start Line: N/A End Line: N/A ------------- Details: No functions to verify docstrings. Affected Code Snippet: N/A Start Line: N/A End Line: N/A ------------- Details: No functions to verify docstrings. Affected Code Snippet: N/A Start Line: N/A End Line: N/A ------------- Details: Imports should be sorted using isort. Affected Code Snippet: ```python +from typing_extensions import Annotated, Dict, List, TypedDict + +from patchwork.common.utils.step_typing import StepTypeConfig ``` Start Line: 1 End Line: 3 ------------- ## File Changed: `patchwork/steps/ReadPRs/ReadPRs.py` Details: The change modifies the return type of `run` method from `List[DataPoint]` to `DataPoint`, which seems incorrect based on the logic. Affected Code Snippet: ``` def run(self) -> DataPoint: prs = self.scm_client.find_prs(self.repo_slug, state=self.pr_state, limit=self.limit) ``` Start Line: 88 End Line: 90 ------------- Details: Type hints were added in the main function `run`, but the change should be verified for correctness. Affected Code Snippet: ``` def run(self) -> DataPoint: prs = self.scm_client.find_prs(self.repo_slug, state=self.pr_state, limit=self.limit) ``` Start Line: 88 End Line: 90 ------------- Details: Inconsistent quotation marks were corrected. Affected Code Snippet: ``` self.repo_slug = inputs["repo_slug"] self.pr_ids = self.__parse_pr_ids_input(inputs.get("pr_ids")) self.pr_state = self.__parse_pr_state_input(inputs.get("pr_state")) ``` Start Line: 49 End Line: 53 ------------- Details: Properly sorted imports and removed unnecessary ones. Affected Code Snippet: ``` from typing import List ``` Start Line: 3 End Line: 4 ------------- Details: Initialized default value for `limit` parameter. Affected Code Snippet: ``` self.limit = inputs.get("limit", 50) ``` Start Line: 52 End Line: 53 ## File Changed: `patchwork/steps/ReadPRs/typed.py` Details: The rule 'Do not use unclear or nondescriptive naming conventions.' has been violated. Although `pr_texts` provides some context, the detailed nature of the attribute would benefit from a more descriptive name possibly indicating that it refers to outputs from processing pull request diffs. Affected Code Snippet: ``` + pr_texts: List[ReadPRDiffsPBOutputs] ``` Start Line: 22 End Line: 22 ## File Changed: `patchwork/steps/SimplifiedLLMOncePB/SimplifiedLLMOncePB.py` Details: Function names should follow snake_case instead of camelCase. Affected Code Snippet: ```python def __json_schema_as_suffix(self, prompt: str): ``` Start Line: 13 End Line: 14 ------------- Details: Related components should be organized using class inheritance where possible. Affected Code Snippet: ```python + super().__init__(inputs) ``` Start Line: 8 End Line: 9 ------------- Details: Detailed docstrings are missing for functions. Affected Code Snippet: ```python + def __json_schema_as_suffix(self, prompt: str): ``` Start Line: 13 End Line: 14 ------------- Details: Missing detailed descriptions with parameters, types, return values, and function purpose. Affected Code Snippet: ```python + def run(self) -> dict: ``` Start Line: 17 End Line: 49 ------------- Details: Missing type annotations in the code and for function parameters and return values. Affected Code Snippet: ```python + def run(self) -> dict: ``` Start Line: 17 End Line: 49 ------------- Details: Inconsistent quotation marks for dictionary keys should use double quotes consistently. Affected Code Snippet: ```python + self.user = inputs["prompt_user"] ``` Start Line: 10 End Line: 10 ------------- ## File Changed: `patchwork/steps/SimplifiedLLMOncePB/typed.py` Details: [Do not use unclear or nondescriptive naming conventions.] Affected Code Snippet: ```python class __SimplifiedLLMOncePBInputsRequired(TypedDict): ``` Start Line: 6 End Line: 6 ------------- Details: [Do not neglect using Annotated for StepTypeConfig.] Affected Code Snippet: ```python + anthropic_api_key: Annotated[ ``` Start Line: 19 End Line: 19 ------------- Details: [Do not omit type annotations in the code.] Affected Code Snippet: ```python + prompt_value: Dict[str, Any] ``` Start Line: 10 End Line: 10 ------------- Details: [Do not forget to sort imports; use isort for import sorting.] Affected Code Snippet: ```python +from typing_extensions import Annotated, Any, Dict, TypedDict ``` Start Line: 1 End Line: 1 ------------- Details: [Do not use inconsistent quotation marks for dictionary keys; use double quotes consistently.] Affected Code Snippet: ```python + str, StepTypeConfig(is_config=True, or_op=["patched_api_key", "google_api_key", "openai_api_key"]) ``` Start Line: 16 End Line: 16 ## File Changed: `patchwork/steps/__init__.py` Details: Use isort for consistent import sorting. Affected Code Snippet: ```python from patchwork.steps.QueryEmbeddings.QueryEmbeddings import QueryEmbeddings from patchwork.steps.ReadIssues.ReadIssues import ReadIssues ``` Start Line: 35 End Line: 43 -------------