Skip to content

Commit 1f961cb

Browse files
committed
Fix linting and type checking issues
1 parent a80b34b commit 1f961cb

File tree

8 files changed

+127
-41
lines changed

8 files changed

+127
-41
lines changed

implementations/uim-mock-agent/src/discovery.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This module provides functionality for discovering UIM services and their intents
55
by fetching and parsing agents.json files from UIM-compatible web services.
66
"""
7+
78
import json
89
from typing import Dict
910

@@ -44,7 +45,8 @@ def extract_intent_metadata(agents_data: Dict) -> Dict:
4445
agents_data: The parsed agents.json data
4546
4647
Returns:
47-
Dict: A dictionary containing extracted intents, execute endpoint, and service URL
48+
Dict: A dictionary containing extracted intents, execute
49+
endpoint, and service URL
4850
"""
4951
print(f"Debug: agents_data structure: {json.dumps(agents_data, indent=2)}")
5052
intents = []
@@ -75,7 +77,7 @@ def extract_intent_metadata(agents_data: Dict) -> Dict:
7577

7678
def main():
7779
"""
78-
Main function for testing the discovery module functionality.
80+
Test the discovery module functionality.
7981
8082
Fetches agents.json, extracts intent metadata, and displays the results.
8183
"""

implementations/uim-mock-agent/src/intent_execution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This module provides functionality for executing intents against UIM-compatible
55
web services, including parameter handling and authentication.
66
"""
7+
78
from typing import Any, Dict
89

910
import requests

implementations/uim-mock-agent/src/key_management.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This module provides functionality for generating, storing, and retrieving
55
cryptographic key pairs used for signing and verifying UIM protocol messages.
66
"""
7+
78
import os
89

910
from cryptography.hazmat.backends import default_backend

implementations/uim-mock-agent/src/pat_issuance.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This module provides functionality for obtaining Policy Adherence Tokens (PATs)
55
from UIM-compatible web services by submitting signed policies.
66
"""
7+
78
import base64
89
from typing import Dict
910

implementations/uim-mock-agent/src/policy_management.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This module provides functionality for fetching, displaying, and processing
55
ODRL policies from UIM-compatible web services.
66
"""
7+
78
import requests
89
from error_handling import APIError, NetworkError
910
from policy_signing import sign_policy, submit_signed_policy_and_get_pat
@@ -80,9 +81,10 @@ def display_policy(policy):
8081

8182

8283
def process_policy():
83-
"""
84-
Process the ODRL policy by fetching, displaying, signing, and submitting it
85-
to obtain a Policy Adherence Token (PAT).
84+
"""Process the ODRL policy by fetching, displaying, signing, and submitting it.
85+
86+
This function handles the complete policy processing workflow to obtain a
87+
Policy Adherence Token (PAT).
8688
8789
Returns:
8890
dict or None: The PAT result if successful, None if an error occurred

implementations/uim-mock-agent/src/policy_signing.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
This module provides functionality for signing ODRL policies and submitting them
55
to UIM-compatible web services to obtain Policy Adherence Tokens (PATs).
66
"""
7+
78
from typing import Dict
89

910
import jwt
10-
from cryptography.hazmat.primitives import serialization
1111
from error_handling import APIError
1212
from key_management import get_key_pair
1313
from pat_issuance import handle_pat_issuance
@@ -48,13 +48,9 @@ def submit_signed_policy_and_get_pat(signed_policy: str, service_url: str) -> Di
4848
"""
4949
try:
5050
agent_id = "ai-agent-1" # This should be a unique identifier for your AI agent
51-
_, public_key = get_key_pair(service_url)
52-
public_key_pem = public_key.public_bytes(
53-
encoding=serialization.Encoding.PEM,
54-
format=serialization.PublicFormat.SubjectPublicKeyInfo,
55-
).decode("utf-8")
56-
57-
result = handle_pat_issuance(signed_policy, agent_id, public_key_pem)
51+
# Get the key pair but we only need the agent_id for handle_pat_issuance
52+
# The pat_issuance module will handle getting the public key internally
53+
result = handle_pat_issuance(signed_policy, agent_id)
5854

5955
if result["success"]:
6056
return {"pat": result["pat"]}

poetry.lock

Lines changed: 108 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ black = "^24.2.0"
4949
isort = "^5.13.2"
5050
pylint = "^3.3.4"
5151
pre-commit = "^3.6.2"
52+
flake8-docstrings = "^1.7.0"
53+
flake8-bugbear = "^24.12.12"
54+
flake8-comprehensions = "^3.16.0"
5255

5356
[tool.poetry.group.docs.dependencies]
5457
mkdocs = "^1.6.0"

0 commit comments

Comments
 (0)