Skip to content

Commit 0b092b4

Browse files
committed
fixes
1 parent c773bc3 commit 0b092b4

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

uncoder-core/app/translator/core/models/query_tokens/keyword.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,16 @@
22

33
from app.translator.core.custom_types.tokens import OperatorType
44
from app.translator.core.models.query_tokens.identifier import Identifier
5+
from app.translator.core.models.query_tokens.value import Value
56

67

7-
class Keyword:
8+
class Keyword(Value):
89
def __init__(self, value: Union[str, list[str]]):
10+
super().__init__(value)
911
self.operator: Identifier = Identifier(token_type=OperatorType.KEYWORD)
1012
self.name = "keyword"
11-
self.values = []
12-
self.__add_value(value=value)
1313

14-
@property
15-
def value(self) -> Union[str, list[str]]:
16-
if isinstance(self.values, list) and len(self.values) == 1:
17-
return self.values[0]
18-
return self.values
19-
20-
def __add_value(self, value: Union[str, list[str]]) -> None:
14+
def _add_value(self, value: Union[str, list[str]]) -> None:
2115
if value and isinstance(value, (list, tuple)):
2216
self.values.extend(value)
2317
elif value and isinstance(value, str):

uncoder-core/app/translator/core/models/query_tokens/value.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Value:
77
def __init__(self, value: Union[bool, int, str, StrValue, list, tuple], cast_to_int: bool = False):
88
self.values = []
99
self.__cast_to_int = cast_to_int
10-
self.__add_value(value)
10+
self._add_value(value)
1111

1212
@property
1313
def value(self) -> Union[bool, int, str, StrValue, list[Union[int, str, StrValue]]]:
@@ -18,12 +18,12 @@ def value(self) -> Union[bool, int, str, StrValue, list[Union[int, str, StrValue
1818
@value.setter
1919
def value(self, new_value: Union[bool, int, str, StrValue, list[Union[int, str, StrValue]]]) -> None:
2020
self.values = []
21-
self.__add_value(new_value)
21+
self._add_value(new_value)
2222

23-
def __add_value(self, value: Optional[Union[bool, int, str, StrValue, list, tuple]]) -> None:
23+
def _add_value(self, value: Optional[Union[bool, int, str, StrValue, list, tuple]]) -> None:
2424
if value and isinstance(value, (list, tuple)):
2525
for v in value:
26-
self.__add_value(v)
26+
self._add_value(v)
2727
elif value and isinstance(value, str) and value.isnumeric() and self.__cast_to_int:
2828
self.values.append(int(value))
2929
elif value is not None and isinstance(value, (bool, int, str)):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy