Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

The CI format-check job was failing with 46 files requiring Black reformatting and 30 files with incorrect import sorting.

Changes

  • Applied Black formatter to src/ and tests/ directories (46 files reformatted)
  • Applied isort to fix import order violations (30 files corrected)
  • All formatting now complies with pyproject.toml configuration (line-length: 100, isort profile: black)

No functional changes—purely cosmetic formatting to satisfy linter requirements.

Original prompt

The provided GitHub Actions workflow is failing due to code formatting checks with Black. Specifically, 46 files would be reformatted. This failure occurred in the 'Check formatting with black' workflow step within the .github/workflows/ci.yml configuration file on ref: 655b917fa0f86b970276185ef338211a79d0e988. To address this issue, the following actions must be taken: 1. Apply the necessary format changes to the files in the repository by running the command black src/ tests/. 2. Validate that the formatting issues have been resolved. 3. Commit the changes with an appropriate message. 4. Ensure that the GitHub Actions workflow passes after the updates.

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: Lexicoding-systems <234111021+Lexicoding-systems@users.noreply.github.com>
@Lexicoding-systems Lexicoding-systems marked this pull request as ready for review January 8, 2026 06:02
Copilot AI changed the title [WIP] Fix formatting issues with Black in multiple files Apply Black and isort formatting to resolve CI failures Jan 8, 2026

import json
import os
import secrets

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'secrets' is not used.

Copilot Autofix

AI 15 days ago

To fix an unused import, you remove the import statement so that only actually used modules remain. This reduces clutter and avoids misleading future maintainers about dependencies.

In this file, the best fix is to delete the import secrets line (line 10) from src/lexecon/api/server.py, leaving all other imports untouched. No other code changes, methods, or definitions are needed because we are only cleaning up an unused dependency. This will not alter runtime behavior since secrets is not referenced anywhere.

Suggested changeset 1
src/lexecon/api/server.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/lexecon/api/server.py b/src/lexecon/api/server.py
--- a/src/lexecon/api/server.py
+++ b/src/lexecon/api/server.py
@@ -7,7 +7,6 @@
 
 import json
 import os
-import secrets
 import time
 import uuid
 from datetime import datetime, timezone
EOF
@@ -7,7 +7,6 @@

import json
import os
import secrets
import time
import uuid
from datetime import datetime, timezone
Copilot is powered by AI and may make mistakes. Always verify output.
from fastapi import FastAPI, HTTPException, Request, status
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import HTMLResponse, FileResponse, JSONResponse, PlainTextResponse
from fastapi.responses import FileResponse, HTMLResponse, JSONResponse, PlainTextResponse

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'JSONResponse' is not used.

Copilot Autofix

AI 15 days ago

To fix an unused import, remove the unused symbol from the import statement while leaving the rest of the imports intact. This avoids unnecessary dependencies and slightly reduces cognitive load without changing behavior.

Concretely, in src/lexecon/api/server.py, adjust the from fastapi.responses import ... line so that JSONResponse is no longer imported. Keep FileResponse, HTMLResponse, and PlainTextResponse as they are. No other code changes or additions are required, and no new methods, imports, or definitions are needed.

Suggested changeset 1
src/lexecon/api/server.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/lexecon/api/server.py b/src/lexecon/api/server.py
--- a/src/lexecon/api/server.py
+++ b/src/lexecon/api/server.py
@@ -15,7 +15,7 @@
 
 from fastapi import FastAPI, HTTPException, Request, status
 from fastapi.middleware.cors import CORSMiddleware
-from fastapi.responses import FileResponse, HTMLResponse, JSONResponse, PlainTextResponse
+from fastapi.responses import FileResponse, HTMLResponse, PlainTextResponse
 from pydantic import BaseModel, Field
 
 from lexecon.audit_export.service import AuditExportService, ExportFormat, ExportScope
EOF
@@ -15,7 +15,7 @@

from fastapi import FastAPI, HTTPException, Request, status
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import FileResponse, HTMLResponse, JSONResponse, PlainTextResponse
from fastapi.responses import FileResponse, HTMLResponse, PlainTextResponse
from pydantic import BaseModel, Field

from lexecon.audit_export.service import AuditExportService, ExportFormat, ExportScope
Copilot is powered by AI and may make mistakes. Always verify output.
# Security imports
from lexecon.security.auth_service import AuthService, Role, Permission, User, Session
# Governance service imports
from lexecon.risk.service import RiskScoringEngine, RiskService

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'RiskScoringEngine' is not used.

Copilot Autofix

AI 15 days ago

To fix an unused-import issue, the general approach is to remove the unused symbol from the import statement (or the entire import if none of its symbols are used). This eliminates the unnecessary dependency and matches the CodeQL recommendation.

Here, the best minimal fix without changing functionality is to keep importing RiskService (which is presumably used elsewhere in this file) but stop importing RiskScoringEngine. That means editing the import line at/around line 39 in src/lexecon/api/server.py to remove RiskScoringEngine from the imported names, leaving just from lexecon.risk.service import RiskService. No other methods, imports, or definitions are required.

Suggested changeset 1
src/lexecon/api/server.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/lexecon/api/server.py b/src/lexecon/api/server.py
--- a/src/lexecon/api/server.py
+++ b/src/lexecon/api/server.py
@@ -36,7 +36,7 @@
 from lexecon.responsibility.tracker import DecisionMaker, ResponsibilityLevel, ResponsibilityTracker
 
 # Governance service imports
-from lexecon.risk.service import RiskScoringEngine, RiskService
+from lexecon.risk.service import RiskService
 from lexecon.security.audit_service import AuditService, ExportStatus
 
 # Security imports
EOF
@@ -36,7 +36,7 @@
from lexecon.responsibility.tracker import DecisionMaker, ResponsibilityLevel, ResponsibilityTracker

# Governance service imports
from lexecon.risk.service import RiskScoringEngine, RiskService
from lexecon.risk.service import RiskService
from lexecon.security.audit_service import AuditService, ExportStatus

# Security imports
Copilot is powered by AI and may make mistakes. Always verify output.
ExportScope
)
# Security imports
from lexecon.security.auth_service import AuthService, Permission, Role, Session, User

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'Session' is not used.
Import of 'User' is not used.

Copilot Autofix

AI 15 days ago

To fix this kind of problem, we remove any names from import lists that are not actually used in the module. This keeps imports minimal, reduces mental overhead when reading the file, and eliminates unnecessary dependencies flagged by static analysis.

In this file, we should edit the import on line 43 in src/lexecon/api/server.py to remove Session and User from the list of imported symbols, leaving AuthService, Permission, and Role unchanged. No additional methods, definitions, or imports are needed; we’re simply trimming the import list. Care should be taken not to alter other imports or code outside the shown snippet.

Suggested changeset 1
src/lexecon/api/server.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/lexecon/api/server.py b/src/lexecon/api/server.py
--- a/src/lexecon/api/server.py
+++ b/src/lexecon/api/server.py
@@ -40,7 +40,7 @@
 from lexecon.security.audit_service import AuditService, ExportStatus
 
 # Security imports
-from lexecon.security.auth_service import AuthService, Permission, Role, Session, User
+from lexecon.security.auth_service import AuthService, Permission, Role
 from lexecon.security.signature_service import SignatureService
 from lexecon.storage.persistence import LedgerStorage
 
EOF
@@ -40,7 +40,7 @@
from lexecon.security.audit_service import AuditService, ExportStatus

# Security imports
from lexecon.security.auth_service import AuthService, Permission, Role, Session, User
from lexecon.security.auth_service import AuthService, Permission, Role
from lexecon.security.signature_service import SignatureService
from lexecon.storage.persistence import LedgerStorage

Copilot is powered by AI and may make mistakes. Always verify output.
import uuid
import hashlib
from dataclasses import dataclass, field
from datetime import datetime, timedelta, timezone

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'timedelta' is not used.

Copilot Autofix

AI 15 days ago

To fix an unused import, you remove the unreferenced symbol from the import statement (or delete the entire import if none of its names are used). This keeps only the actually used identifiers and avoids misleading dependencies.

In this file, datetime and timezone are used in type hints and in the default_factory on line 68, but timedelta is not referenced anywhere in the visible code. The best minimal fix is to edit the import on line 20 in src/lexecon/audit_export/service.py to drop timedelta while leaving datetime and timezone as they are. No additional methods, definitions, or imports are required.

Concretely:

  • In src/lexecon/audit_export/service.py, find the line:
    • from datetime import datetime, timedelta, timezone
  • Change it to:
    • from datetime import datetime, timezone

This preserves all existing functionality and only removes the unused symbol.

Suggested changeset 1
src/lexecon/audit_export/service.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/lexecon/audit_export/service.py b/src/lexecon/audit_export/service.py
--- a/src/lexecon/audit_export/service.py
+++ b/src/lexecon/audit_export/service.py
@@ -17,7 +17,7 @@
 import json
 import uuid
 from dataclasses import dataclass, field
-from datetime import datetime, timedelta, timezone
+from datetime import datetime, timezone
 from enum import Enum
 from typing import Any, Dict, List, Optional, Set
 
EOF
@@ -17,7 +17,7 @@
import json
import uuid
from dataclasses import dataclass, field
from datetime import datetime, timedelta, timezone
from datetime import datetime, timezone
from enum import Enum
from typing import Any, Dict, List, Optional, Set

Copilot is powered by AI and may make mistakes. Always verify output.
from dataclasses import dataclass, field
from datetime import datetime, timedelta, timezone
from enum import Enum
from typing import Any, Dict, List, Optional, Set

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'Set' is not used.

Copilot Autofix

AI 15 days ago

To fix the problem, remove the unused Set symbol from the typing import so that only actually used types are imported. This keeps the code clean and removes an unnecessary dependency without affecting functionality.

Specifically, in src/lexecon/audit_export/service.py, adjust the import on line 22 so that Set is no longer imported. Leave Any, Dict, List, and Optional as they may be used elsewhere in the file. No other methods, imports, or definitions are required for this change.

Suggested changeset 1
src/lexecon/audit_export/service.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/lexecon/audit_export/service.py b/src/lexecon/audit_export/service.py
--- a/src/lexecon/audit_export/service.py
+++ b/src/lexecon/audit_export/service.py
@@ -19,7 +19,7 @@
 from dataclasses import dataclass, field
 from datetime import datetime, timedelta, timezone
 from enum import Enum
-from typing import Any, Dict, List, Optional, Set
+from typing import Any, Dict, List, Optional
 
 
 class ExportFormat(Enum):
EOF
@@ -19,7 +19,7 @@
from dataclasses import dataclass, field
from datetime import datetime, timedelta, timezone
from enum import Enum
from typing import Any, Dict, List, Optional, Set
from typing import Any, Dict, List, Optional


class ExportFormat(Enum):
Copilot is powered by AI and may make mistakes. Always verify output.
from enum import Enum
from typing import Optional, Dict, List, Tuple
from dataclasses import dataclass
from typing import Dict, List, Optional, Tuple

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'Dict' is not used.

Copilot Autofix

AI 15 days ago

To fix the problem, the import should be reduced to only the typing symbols that are actually used in this file. Since CodeQL reports that Dict is unused, and we must not assume other unused names beyond what the tool reports, we should remove Dict from the from typing import ... list while leaving List, Optional, and Tuple intact.

Concretely, in src/lexecon/security/auth_service.py, at line 19, change the import line from from typing import Dict, List, Optional, Tuple to from typing import List, Optional, Tuple. No other code changes are required, and this does not alter any runtime behavior because Dict was not referenced anywhere.

Suggested changeset 1
src/lexecon/security/auth_service.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/lexecon/security/auth_service.py b/src/lexecon/security/auth_service.py
--- a/src/lexecon/security/auth_service.py
+++ b/src/lexecon/security/auth_service.py
@@ -16,7 +16,7 @@
 from dataclasses import dataclass
 from datetime import datetime, timedelta, timezone
 from enum import Enum
-from typing import Dict, List, Optional, Tuple
+from typing import List, Optional, Tuple
 
 
 class Role(str, Enum):
EOF
@@ -16,7 +16,7 @@
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
from enum import Enum
from typing import Dict, List, Optional, Tuple
from typing import List, Optional, Tuple


class Role(str, Enum):
Copilot is powered by AI and may make mistakes. Always verify output.
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.backends import default_backend
from typing import Any, Dict, Optional, Tuple

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'Optional' is not used.

Copilot Autofix

AI 15 days ago

To fix an unused-import problem, you either remove the unused symbol from the import statement or start using it meaningfully in the code. Since there is no apparent need for Optional in the shown type hints, the best way to fix this without changing functionality is to delete Optional from the from typing import ... line.

Concretely, in src/lexecon/security/signature_service.py, on line 15, change the import line from from typing import Any, Dict, Optional, Tuple to from typing import Any, Dict, Tuple. No other code changes are necessary, and no additional methods, imports, or definitions are required.

Suggested changeset 1
src/lexecon/security/signature_service.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/lexecon/security/signature_service.py b/src/lexecon/security/signature_service.py
--- a/src/lexecon/security/signature_service.py
+++ b/src/lexecon/security/signature_service.py
@@ -12,7 +12,7 @@
 import json
 import os
 from datetime import datetime, timezone
-from typing import Any, Dict, Optional, Tuple
+from typing import Any, Dict, Tuple
 
 from cryptography.exceptions import InvalidSignature
 from cryptography.hazmat.backends import default_backend
EOF
@@ -12,7 +12,7 @@
import json
import os
from datetime import datetime, timezone
from typing import Any, Dict, Optional, Tuple
from typing import Any, Dict, Tuple

from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.backends import default_backend
Copilot is powered by AI and may make mistakes. Always verify output.
import pytest
from unittest.mock import Mock

import pytest

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'pytest' is not used.

Copilot Autofix

AI 15 days ago

To fix an unused import, the general approach is to remove the import statement for the unused module, ensuring that nothing in the file depends on it. This eliminates unnecessary dependencies and cleans up the code.

In this specific case, the best fix is to delete the line import pytest from tests/test_middleware.py. No other changes are needed because the rest of the code does not reference pytest. This does not alter existing test functionality, as the tests rely only on unittest.mock, fastapi.Request, and the lexecon.security modules. Concretely, remove line 5 in the snippet (the import pytest line) and leave the other imports unchanged.

Suggested changeset 1
tests/test_middleware.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/tests/test_middleware.py b/tests/test_middleware.py
--- a/tests/test_middleware.py
+++ b/tests/test_middleware.py
@@ -2,7 +2,6 @@
 
 from unittest.mock import Mock
 
-import pytest
 from fastapi import Request
 
 from lexecon.security.auth_service import Permission, Role, Session
EOF
@@ -2,7 +2,6 @@

from unittest.mock import Mock

import pytest
from fastapi import Request

from lexecon.security.auth_service import Permission, Role, Session
Copilot is powered by AI and may make mistakes. Always verify output.
import pytest
from fastapi import Request

from lexecon.security.auth_service import Permission, Role, Session

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'Session' is not used.
Import of 'Permission' is not used.

Copilot Autofix

AI 15 days ago

To fix the problem, remove the unused imported names while keeping the used one. In general, unused-import issues are resolved either by deleting the unused imports or by tightening wildcard imports to only the required symbols.

Specifically here, in tests/test_middleware.py at line 8, replace from lexecon.security.auth_service import Permission, Role, Session with an import of only Role, since Permission and Session are never referenced in this file. This change does not alter existing functionality because it only removes unused names and leaves the needed one intact. No additional methods, imports, or definitions are required.

Suggested changeset 1
tests/test_middleware.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/tests/test_middleware.py b/tests/test_middleware.py
--- a/tests/test_middleware.py
+++ b/tests/test_middleware.py
@@ -5,7 +5,7 @@
 import pytest
 from fastapi import Request
 
-from lexecon.security.auth_service import Permission, Role, Session
+from lexecon.security.auth_service import Role
 from lexecon.security.middleware import get_current_user, require_permission
 
 
EOF
@@ -5,7 +5,7 @@
import pytest
from fastapi import Request

from lexecon.security.auth_service import Permission, Role, Session
from lexecon.security.auth_service import Role
from lexecon.security.middleware import get_current_user, require_permission


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

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request applies automated code formatting using Black and isort to resolve CI failures. The changes are purely cosmetic, reformatting 46 files with Black (line-length: 100) and correcting import order in 30 files according to the black profile configuration in pyproject.toml.

Key changes:

  • String quotes standardized from single to double quotes throughout
  • Import statements reordered alphabetically and grouped (stdlib, third-party, first-party)
  • Line breaks and wrapping adjusted to comply with 100-character line length
  • Trailing commas added to multi-line structures
  • Whitespace normalized around operators, function calls, and data structures

Reviewed changes

Copilot reviewed 49 out of 49 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
tests/test_tracing.py Quote standardization, line wrapping, blank line additions between decorators and functions
tests/test_storage_persistence.py Import reordering, trailing comma additions, line wrapping for long arguments
tests/test_security.py Import order correction (shutil/tempfile swap), trailing comma addition
tests/test_risk_service.py Import alphabetization, line wrapping for function calls
tests/test_policy.py Trailing comma additions, line wrapping improvements
tests/test_override_service.py Import reordering, line wrapping for long conditionals
tests/test_middleware.py Import order correction, formatting consistency
tests/test_metrics.py Quote standardization, line wrapping for chained method calls
tests/test_logging.py Line wrapping for function calls
tests/test_ledger.py Blank line additions for code organization
tests/test_identity.py Line wrapping, blank line additions for imports
tests/test_governance_models.py Major import statement reorganization with comment preservation
tests/test_governance_api.py Import order correction
tests/test_export_determinism.py Import reordering, line wrapping for conditionals
tests/test_evidence_service.py Import alphabetization, line wrapping
tests/test_escalation_service.py Import reordering, line wrapping for function calls
tests/test_decision_service.py Import organization, line wrapping, blank line additions
tests/test_compliance_mapping.py Import additions, line wrapping for arguments
tests/test_cli.py Trailing comma addition, blank line addition
tests/test_capability_tokens.py Line wrapping for list comprehensions
tests/test_audit_verify.py Dictionary formatting improvements, line wrapping
tests/test_audit_export.py Import reordering, extensive line wrapping and formatting
tests/test_article_12_records.py Line wrapping for function calls
tests/test_append_only_store.py Import order, blank line additions, line wrapping
tests/test_api_additional.py Dictionary formatting, line wrapping
tests/test_api.py Dictionary formatting consistency
src/lexecon/tools/audit_verify.py Blank line after exception class, line wrapping
src/lexecon/storage/persistence.py Extensive SQL query formatting with multi-line strings
src/lexecon/security/signature_service.py Import reordering, line wrapping for cryptography calls
src/lexecon/security/middleware.py Import reordering, line wrapping, blank line additions
src/lexecon/security/auth_service.py Extensive formatting of SQL queries and long conditionals
src/lexecon/security/audit_service.py Import reordering, SQL formatting, line wrapping
src/lexecon/risk/service.py Import order, line wrapping for function calls
src/lexecon/responsibility/tracker.py Import order correction, line wrapping, blank line additions
src/lexecon/responsibility/storage.py Import order, extensive SQL formatting
src/lexecon/responsibility/init.py Import statement consolidation
src/lexecon/override/service.py Import reordering, line wrapping
src/lexecon/identity/signing.py Blank line addition after import
src/lexecon/evidence/service.py Import order correction, line wrapping
src/lexecon/evidence/append_only_store.py Blank line after exception, line wrapping
src/lexecon/escalation/service.py Import reordering, line wrapping
src/lexecon/decision/service.py Import organization with comment preservation
src/lexecon/compliance_mapping/service.py Import reordering, extensive line wrapping and blank line additions
src/lexecon/compliance/eu_ai_act/storage.py SQL query formatting
src/lexecon/compliance/eu_ai_act/article_14_oversight.py Import order, extensive dictionary and line wrapping
src/lexecon/compliance/eu_ai_act/article_12_records.py Import order, extensive formatting improvements
src/lexecon/compliance/eu_ai_act/article_11_technical_docs.py Import order, extensive dictionary formatting
src/lexecon/audit_export/service.py Import reordering, extensive line wrapping and formatting
Comments suppressed due to low confidence (1)

src/lexecon/evidence/append_only_store.py:88

    def __delitem__(self, key: str):

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Lexicoding-systems and others added 5 commits January 10, 2026 01:01
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Lexicoding <234111021+Lexicoding-systems@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Lexicoding <234111021+Lexicoding-systems@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Lexicoding <234111021+Lexicoding-systems@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Lexicoding <234111021+Lexicoding-systems@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Lexicoding <234111021+Lexicoding-systems@users.noreply.github.com>
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.

2 participants