-
Notifications
You must be signed in to change notification settings - Fork 6
Fix linter errors and enable static analysis in CI #109
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: kevinbackhouse <4358136+kevinbackhouse@users.noreply.github.com>
- Add ruff configuration to pyproject.toml with appropriate rule ignores - Set target Python version to 3.11 (matching CI) - Fix actual code issues: - Add missing logging import in codeql/client.py - Remove unused RunHooks import in agent.py - Remove unused io import in jsonrpyc/__init__.py - Rename unused variables with underscore prefix - Replace dict.items() with dict.values()/dict.keys() where appropriate - Apply auto-formatting with ruff formatter - Enable hatch fmt --check in CI workflow Co-authored-by: kevinbackhouse <4358136+kevinbackhouse@users.noreply.github.com>
| def parse_prompt_args(available_tools: AvailableTools, | ||
| user_prompt: str | None = None): | ||
|
|
||
| def parse_prompt_args(available_tools: AvailableTools, user_prompt: str | None = None): |
Check notice
Code scanning / CodeQL
Returning tuples with varying lengths Note
tuple of size 5
tuple of size 6
parse_prompt_args returns
tuple of size 5
tuple of size 6
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 days ago
To fix this issue, ensure that all return points of parse_prompt_args return tuples of the same length. The best fix, maintaining existing semantics, is to pad the returned tuple at line 93 (return None, None, None, None, help_msg) by adding another None before help_msg, making it a 6-tuple. This will match the number and order of values returned in other exit points at line 104 and 108. Evaluate whether this impacts any downstream logic (callers expecting a short tuple), but as per instruction, remain within the scope of the shown code.
No additional methods or imports are needed. Only a change to line 93 is required in src/seclab_taskflow_agent/main.py.
-
Copy modified line R93
| @@ -90,7 +90,7 @@ | ||
| except SystemExit as e: | ||
| if e.code == 2: | ||
| logging.exception(f"User provided incomplete prompt: {user_prompt}") | ||
| return None, None, None, None, help_msg | ||
| return None, None, None, None, None, help_msg | ||
| p = args[0].p.strip() if args[0].p else None | ||
| t = args[0].t.strip() if args[0].t else None | ||
| l = args[0].l |
| run = task_body.get('run', '') | ||
| inputs = task_body.get('inputs', {}) | ||
| prompt = task_body.get('user_prompt', '') | ||
| _name = task_body.get("name", "taskflow") # placeholder, not used yet |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 days ago
To fix the problem, remove the line assigning to _name, since the variable is unused and its assignment does not have side effects. This means deleting line 484:
484: _name = task_body.get("name", "taskflow") # placeholder, not used yetNo additional imports, method changes, or variable definitions are required. The fix is a single-line deletion inside the provided code region of src/seclab_taskflow_agent/__main__.py.
| @@ -481,7 +481,6 @@ | ||
| model_settings.update(task_model_settings) | ||
|
|
||
| # parse our taskflow grammar | ||
| _name = task_body.get("name", "taskflow") # placeholder, not used yet | ||
| _description = task_body.get("description", "taskflow") # placeholder not used yet | ||
| agents = task_body.get("agents", []) | ||
| headless = task_body.get("headless", False) |
| inputs = task_body.get('inputs', {}) | ||
| prompt = task_body.get('user_prompt', '') | ||
| _name = task_body.get("name", "taskflow") # placeholder, not used yet | ||
| _description = task_body.get("description", "taskflow") # placeholder not used yet |
Check notice
Code scanning / CodeQL
Unused local variable Note
Copilot Autofix
AI 3 days ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
|
|
||
| def fileno(self) -> int: | ||
| ... | ||
| def fileno(self) -> int: ... |
Check notice
Code scanning / CodeQL
Statement has no effect Note
Copilot Autofix
AI 3 days ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
| @property | ||
| def closed(self) -> bool: | ||
| ... | ||
| def closed(self) -> bool: ... |
Check notice
Code scanning / CodeQL
Statement has no effect Note
Copilot Autofix
AI 3 days ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
|
|
||
| def readlines(self) -> list[str]: | ||
| ... | ||
| def readlines(self) -> list[str]: ... |
Check notice
Code scanning / CodeQL
Statement has no effect Note
Copilot Autofix
AI 3 days ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
|
|
||
| def fileno(self) -> int: | ||
| ... | ||
| def fileno(self) -> int: ... |
Check notice
Code scanning / CodeQL
Statement has no effect Note
Copilot Autofix
AI 3 days ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
| @property | ||
| def closed(self) -> bool: | ||
| ... | ||
| def closed(self) -> bool: ... |
Check notice
Code scanning / CodeQL
Statement has no effect Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 days ago
The best way to fix this is to replace the property definition for closed in the OutputStream protocol from:
@property
def closed(self) -> bool: ...to use pass as the body:
@property
def closed(self) -> bool:
passAlternatively, if you wish to be more explicit, you might raise NotImplementedError, but for Protocol definitions with no provided implementation, pass is preferred for clearer intent and to avoid unnecessary runtime errors. Only lines 51-52 in the file need to be changed. There are no new imports or other code changes required.
-
Copy modified lines R52-R53
| @@ -49,7 +49,8 @@ | ||
| def fileno(self) -> int: ... | ||
|
|
||
| @property | ||
| def closed(self) -> bool: ... | ||
| def closed(self) -> bool: | ||
| pass | ||
|
|
||
| def write(self, b: str) -> int: ... | ||
|
|
|
|
||
| def write(self, b: str) -> int: | ||
| ... | ||
| def write(self, b: str) -> int: ... |
Check notice
Code scanning / CodeQL
Statement has no effect Note
Copilot Autofix
AI 3 days ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
|
|
||
| def flush(self) -> None: | ||
| ... | ||
| def flush(self) -> None: ... |
Check notice
Code scanning / CodeQL
Statement has no effect Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 days ago
The best way to fix this issue is to replace the standalone ellipsis (...) as the method body for flush(self) in the OutputStream protocol with a single pass statement. This makes it clear that the method does nothing at runtime and is intended only to specify the required interface. Edit the region in file src/seclab_taskflow_agent/mcp_servers/codeql/jsonrpyc/__init__.py at the definition of the flush method of the OutputStream protocol (on or around line 56) and replace the line containing ... with pass. No additional imports, method definitions, or other changes are required.
-
Copy modified line R56
| @@ -53,7 +53,7 @@ | ||
|
|
||
| def write(self, b: str) -> int: ... | ||
|
|
||
| def flush(self) -> None: ... | ||
| def flush(self) -> None: pass | ||
|
|
||
|
|
||
| class Spec: |
The linter was disabled in CI due to ~800 errors. This PR fixes all linting issues and re-enables
hatch fmt --checkin the workflow.Configuration
[tool.ruff]config topyproject.tomlwith target Python 3.11release_tools/,tests/, and forkedjsonrpyc/Bug Fixes
loggingimport incodeql/client.py(F821)RunHooksimport inagent.py(F811)ioimport injsonrpyc/__init__.py(F401)dict.values()/dict.keys()where applicableFormatting
CI
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.