Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 4, 2025

The linter was disabled in CI due to ~800 errors. This PR fixes all linting issues and re-enables hatch fmt --check in the workflow.

Configuration

  • Added [tool.ruff] config to pyproject.toml with target Python 3.11
  • Suppressed overly strict rules (relative imports, print in CLI tools, exception message formatting, etc.)
  • Added per-file ignores for release_tools/, tests/, and forked jsonrpyc/

Bug Fixes

  • Added missing logging import in codeql/client.py (F821)
  • Removed duplicate RunHooks import in agent.py (F811)
  • Removed unused io import in jsonrpyc/__init__.py (F401)
  • Fixed unused loop variables with dict.values()/dict.keys() where applicable

Formatting

  • Applied ruff formatter to 24 files for consistent style

CI

- name: Run static analysis
  run: hatch fmt --check
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix linter errors</issue_title>
<issue_description>I switched off the linter because it produces 100s of error messages:

We should fix those errors (or find a way to suppress them if they're uninteresting), so that we can switch the check on.</issue_description>

<agent_instructions>Run hatch fmt --check and fix all the errors that it finds.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 4, 2025 09:42
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>
Copilot AI changed the title [WIP] Fix linter errors in codebase Fix linter errors and enable static analysis in CI Dec 4, 2025
Copilot AI requested a review from kevinbackhouse December 4, 2025 09:56
Copilot finished work on behalf of kevinbackhouse December 4, 2025 09:56
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

parse_prompt_args returns
tuple of size 5
and
tuple of size 6
.
parse_prompt_args returns
tuple of size 5
and
tuple of size 6
.

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.

Suggested changeset 1
src/seclab_taskflow_agent/__main__.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/seclab_taskflow_agent/__main__.py b/src/seclab_taskflow_agent/__main__.py
--- a/src/seclab_taskflow_agent/__main__.py
+++ b/src/seclab_taskflow_agent/__main__.py
@@ -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
EOF
@@ -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
Copilot is powered by AI and may make mistakes. Always verify output.
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

Variable _name is not used.

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 yet

No 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.

Suggested changeset 1
src/seclab_taskflow_agent/__main__.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/seclab_taskflow_agent/__main__.py b/src/seclab_taskflow_agent/__main__.py
--- a/src/seclab_taskflow_agent/__main__.py
+++ b/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)
EOF
@@ -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)
Copilot is powered by AI and may make mistakes. Always verify output.
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

Variable _description is not used.

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

This statement has no effect.

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

This statement has no effect.

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

This statement has no effect.

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

This statement has no effect.

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

This statement has no effect.

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:
    pass

Alternatively, 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.

Suggested changeset 1
src/seclab_taskflow_agent/mcp_servers/codeql/jsonrpyc/__init__.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/seclab_taskflow_agent/mcp_servers/codeql/jsonrpyc/__init__.py b/src/seclab_taskflow_agent/mcp_servers/codeql/jsonrpyc/__init__.py
--- a/src/seclab_taskflow_agent/mcp_servers/codeql/jsonrpyc/__init__.py
+++ b/src/seclab_taskflow_agent/mcp_servers/codeql/jsonrpyc/__init__.py
@@ -49,7 +49,8 @@
     def fileno(self) -> int: ...
 
     @property
-    def closed(self) -> bool: ...
+    def closed(self) -> bool:
+        pass
 
     def write(self, b: str) -> int: ...
 
EOF
@@ -49,7 +49,8 @@
def fileno(self) -> int: ...

@property
def closed(self) -> bool: ...
def closed(self) -> bool:
pass

def write(self, b: str) -> int: ...

Copilot is powered by AI and may make mistakes. Always verify output.

def write(self, b: str) -> int:
...
def write(self, b: str) -> int: ...

Check notice

Code scanning / CodeQL

Statement has no effect Note

This statement has no effect.

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

This statement has no effect.

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.

Suggested changeset 1
src/seclab_taskflow_agent/mcp_servers/codeql/jsonrpyc/__init__.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/seclab_taskflow_agent/mcp_servers/codeql/jsonrpyc/__init__.py b/src/seclab_taskflow_agent/mcp_servers/codeql/jsonrpyc/__init__.py
--- a/src/seclab_taskflow_agent/mcp_servers/codeql/jsonrpyc/__init__.py
+++ b/src/seclab_taskflow_agent/mcp_servers/codeql/jsonrpyc/__init__.py
@@ -53,7 +53,7 @@
 
     def write(self, b: str) -> int: ...
 
-    def flush(self) -> None: ...
+    def flush(self) -> None: pass
 
 
 class Spec:
EOF
@@ -53,7 +53,7 @@

def write(self, b: str) -> int: ...

def flush(self) -> None: ...
def flush(self) -> None: pass


class Spec:
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix linter errors

2 participants