Skip to content

Commit c24234d

Browse files
convert SchemaItem to dataclass (unfrozen by default)
1 parent 59633e5 commit c24234d

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed
Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
from src.service.payloads.values.data_type import DataType
2+
from dataclasses import dataclass
23

3-
4+
@dataclass
45
class SchemaItem:
5-
def __init__(self, type: DataType, name: str, column_index: int) -> None:
6-
self.type: DataType = type
7-
self.name: str = name
8-
self.column_index: int = column_index
6+
type: DataType
7+
name: str
8+
column_index: int
99

10+
# Keeping these methods for backward compatibility
1011
def get_type(self) -> DataType:
1112
return self.type
1213

@@ -23,19 +24,4 @@ def get_column_index(self) -> int:
2324
return self.column_index
2425

2526
def set_column_index(self, column_index: int) -> None:
26-
self.column_index = column_index
27-
28-
def __eq__(self, other: object) -> bool:
29-
if not isinstance(other, SchemaItem):
30-
return False
31-
return (
32-
self.type == other.type
33-
and self.name == other.name
34-
and self.column_index == other.column_index
35-
)
36-
37-
def __hash__(self) -> int:
38-
return hash((self.type, self.name, self.column_index))
39-
40-
def __str__(self) -> str:
41-
return f"SchemaItem(type={self.type}, name='{self.name}', column_index={self.column_index})"
27+
self.column_index = column_index

0 commit comments

Comments
 (0)