ruff format

This commit is contained in:
2025-05-09 23:25:21 +03:00
parent 9a78aa9263
commit 13f7e33db1
29 changed files with 471 additions and 298 deletions
+17 -10
View File
@@ -8,17 +8,24 @@ class PredefinedFlags:
"""
Public. A dataclass with predefined flags and most frequently used flags for quick use
"""
HELP = Flag(name='help', possible_values=False)
SHORT_HELP = Flag(name='H', prefix='-', possible_values=False)
INFO = Flag(name='info', possible_values=False)
SHORT_INFO = Flag(name='I', prefix='-', possible_values=False)
HELP = Flag(name="help", possible_values=False)
SHORT_HELP = Flag(name="H", prefix="-", possible_values=False)
ALL = Flag(name='all', possible_values=False)
SHORT_ALL = Flag(name='A', prefix='-', possible_values=False)
INFO = Flag(name="info", possible_values=False)
SHORT_INFO = Flag(name="I", prefix="-", possible_values=False)
HOST = Flag(name='host', possible_values=re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$'))
SHORT_HOST = Flag(name='H', prefix='-', possible_values=re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$'))
ALL = Flag(name="all", possible_values=False)
SHORT_ALL = Flag(name="A", prefix="-", possible_values=False)
PORT = Flag(name='port', possible_values=re.compile(r'^\d{1,5}$'))
SHORT_PORT = Flag(name='P', prefix='-', possible_values=re.compile(r'^\d{1,5}$'))
HOST = Flag(
name="host", possible_values=re.compile(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")
)
SHORT_HOST = Flag(
name="H",
prefix="-",
possible_values=re.compile(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"),
)
PORT = Flag(name="port", possible_values=re.compile(r"^\d{1,5}$"))
SHORT_PORT = Flag(name="P", prefix="-", possible_values=re.compile(r"^\d{1,5}$"))
+14 -11
View File
@@ -1,10 +1,8 @@
from typing import Literal, Pattern
class BaseFlag:
def __init__(self, name: str,
prefix: Literal['-', '--', '---'] = '--') -> None:
def __init__(self, name: str, prefix: Literal["-", "--", "---"] = "--") -> None:
"""
Private. Base class for flags
:param name: the name of the flag
@@ -41,9 +39,12 @@ class BaseFlag:
class Flag(BaseFlag):
def __init__(self, name: str,
prefix: Literal['-', '--', '---'] = '--',
possible_values: list[str] | Pattern[str] | False = True) -> None:
def __init__(
self,
name: str,
prefix: Literal["-", "--", "---"] = "--",
possible_values: list[str] | Pattern[str] | False = True,
) -> None:
"""
Public. The entity of the flag being registered for subsequent processing
:param name: The name of the flag
@@ -85,9 +86,9 @@ class Flag(BaseFlag):
class InputFlag(BaseFlag):
def __init__(self, name: str,
prefix: Literal['-', '--', '---'] = '--',
value: str = None):
def __init__(
self, name: str, prefix: Literal["-", "--", "---"] = "--", value: str = None
):
"""
Public. The entity of the flag of the entered command
:param name: the name of the input flag
@@ -114,5 +115,7 @@ class InputFlag(BaseFlag):
self._flag_value = value
def __eq__(self, other) -> bool:
return self.get_string_entity() == other.get_string_entity() and self.get_value() == other.get_value()
return (
self.get_string_entity() == other.get_string_entity()
and self.get_value() == other.get_value()
)