fix(ci): fix black/ruff failures, add CoC and PR template
- Fix Python formatting (sync no longer strips blank lines from .py files) - Remove test_community_build.py (tests private sync module) - Fix ruff warnings in test files - Add CODE_OF_CONDUCT.md - Add .github/PULL_REQUEST_TEMPLATE.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -16,12 +16,14 @@ from pathlib import Path
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Valid scope values
|
||||
VALID_SCOPES = ["read", "write", "admin"]
|
||||
|
||||
# Scope can be single ("read") or multiple space-separated ("read write admin")
|
||||
Scope = str
|
||||
|
||||
|
||||
def validate_scope(scope: str) -> bool:
|
||||
"""
|
||||
Validate that scope contains only valid scope values.
|
||||
@@ -38,6 +40,7 @@ def validate_scope(scope: str) -> bool:
|
||||
scope_list = scope.split()
|
||||
return all(s in VALID_SCOPES for s in scope_list)
|
||||
|
||||
|
||||
def normalize_scope(scope: str) -> str:
|
||||
"""
|
||||
Normalize scope string by removing duplicates and sorting.
|
||||
@@ -56,6 +59,7 @@ def normalize_scope(scope: str) -> str:
|
||||
unique_scopes.append(s)
|
||||
return " ".join(unique_scopes)
|
||||
|
||||
|
||||
@dataclass
|
||||
class APIKey:
|
||||
"""
|
||||
@@ -105,6 +109,7 @@ class APIKey:
|
||||
"""Check if key is valid (not revoked, not expired)."""
|
||||
return not self.revoked and not self.is_expired()
|
||||
|
||||
|
||||
class APIKeyManager:
|
||||
"""
|
||||
Manages per-project API keys with persistence.
|
||||
@@ -487,9 +492,11 @@ class APIKeyManager:
|
||||
"valid": key.is_valid(),
|
||||
}
|
||||
|
||||
|
||||
# Global instance
|
||||
_api_key_manager: APIKeyManager | None = None
|
||||
|
||||
|
||||
def get_api_key_manager() -> APIKeyManager:
|
||||
"""Get the global API Key Manager instance."""
|
||||
global _api_key_manager
|
||||
|
||||
Reference in New Issue
Block a user