-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Description
Improve type safety and add comprehensive validation for flag values and operations to catch errors early and provide better developer experience.
Goals
- Complete type annotations coverage
- Runtime value validation
- Enhanced IDE support
- Custom type definitions
- Validation error handling
Proposed Implementation
- Type Annotations
from typing import TypeVar, Generic, Union, Optional
from datetime import datetime
T = TypeVar('T')
class Flag(Generic[T]):
def __init__(
self,
name: str,
value: T,
operation: Optional[str] = None,
description: Optional[str] = None
) -> None: ...
def is_enabled(self, compare_value: Optional[T] = None) -> bool: ...
class Flaggle:
def __init__(
self,
url: str,
interval: int = 60,
default_flags: Optional[dict[str, Flag[Any]]] = None,
timeout: int = 10,
verify_ssl: bool = True
) -> None: ...- Value Validation
class FlagValue(Generic[T]):
"""Validated flag value container."""
def __init__(self, value: T) -> None:
self.validate(value)
self._value = value
@staticmethod
def validate(value: T) -> None:
# Type-specific validation
pass
class Flag(Generic[T]):
def __init__(self, name: str, value: T) -> None:
self.value = FlagValue[T](value)Acceptance Criteria
- Complete type annotations for all public APIs
- Runtime value validation
- Custom type definitions for flag values
- Validation error handling
- Type checking in CI pipeline
- Updated documentation with type information
- Migration guide for existing users
Additional Benefits
- Better IDE support (autocomplete, type checking)
- Early error detection
- Improved code maintainability
- Better developer experience
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request