fix public api

This commit is contained in:
2025-10-13 14:23:47 +03:00
parent 4a895df52c
commit 36b4d16610
36 changed files with 164 additions and 158 deletions
+11 -9
View File
@@ -1,3 +1,5 @@
__all__ = ["PossibleValues", "ValidationStatus", "Flag", "InputFlag"]
from enum import Enum
from re import Pattern
from typing import Literal, override
@@ -16,7 +18,7 @@ class ValidationStatus(Enum):
class Flag:
def __init__(
self, name: str, *,
self, name: str, *,
prefix: Literal["-", "--", "---"] = "--",
possible_values: list[str] | Pattern[str] | PossibleValues = PossibleValues.ALL,
) -> None:
@@ -47,7 +49,7 @@ class Flag:
return input_flag_value in self.possible_values
return True
@property
def string_entity(self) -> str:
"""
@@ -56,17 +58,17 @@ class Flag:
"""
string_entity: str = self.prefix + self.name
return string_entity
@override
def __str__(self) -> str:
return self.string_entity
@override
def __repr__(self) -> str:
return f'Flag<name={self.name}, prefix={self.prefix}>'
@override
def __eq__(self, other: object) -> bool:
def __eq__(self, other: object) -> bool:
if isinstance(other, Flag):
return self.string_entity == other.string_entity
else:
@@ -91,7 +93,7 @@ class InputFlag:
self.prefix: Literal['-', '--', '---'] = prefix
self.input_value: str | None = input_value
self.status: ValidationStatus | None = status
@property
def string_entity(self) -> str:
"""
@@ -104,13 +106,13 @@ class InputFlag:
@override
def __str__(self) -> str:
return f'{self.string_entity} {self.input_value}'
@override
def __repr__(self) -> str:
return f'InputFlag<name={self.name}, prefix={self.prefix}, value={self.input_value}, status={self.status}>'
@override
def __eq__(self, other: object) -> bool:
def __eq__(self, other: object) -> bool:
if isinstance(other, InputFlag):
return (
self.name == other.name