Skip to content

Commit 1647805

Browse files
NickCrewscpcloud
authored andcommitted
refactor(datatypes): fully remove unused DataType.name
1 parent 66ab2a5 commit 1647805

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

ibis/backends/sql/datatypes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def to_ibis(cls, typ: sge.DataType, nullable: bool | None = None) -> dt.DataType
173173
def from_ibis(cls, dtype: dt.DataType) -> sge.DataType:
174174
"""Convert an Ibis dtype to an sqlglot dtype."""
175175

176-
if method := getattr(cls, f"_from_ibis_{dtype.name}", None):
176+
if method := getattr(cls, f"_from_ibis_{dtype.__class__.__name__}", None):
177177
return method(dtype)
178178
else:
179179
return sge.DataType(this=_to_sqlglot_types[type(dtype)])

ibis/expr/datatypes/core.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,6 @@ def column(self): ...
189189
def _pretty_piece(self) -> str:
190190
return ""
191191

192-
# TODO(kszucs): should remove it, only used internally
193-
@property
194-
def name(self) -> str:
195-
"""Return the name of the data type."""
196-
return self.__class__.__name__
197-
198192
@classmethod
199193
def __coerce__(cls, value, **kwargs):
200194
if isinstance(value, cls):
@@ -209,7 +203,8 @@ def __call__(self, **kwargs):
209203

210204
def __str__(self) -> str:
211205
prefix = "!" * (not self.nullable)
212-
return f"{prefix}{self.name.lower()}{self._pretty_piece}"
206+
name = self.__class__.__name__.lower()
207+
return f"{prefix}{name}{self._pretty_piece}"
213208

214209
def equals(self, other: DataType) -> bool:
215210
if not isinstance(other, DataType):
@@ -962,7 +957,8 @@ def __getitem__(self, key: str) -> DataType:
962957
return self.fields[key]
963958

964959
def __repr__(self) -> str:
965-
return f"'{self.name}({list(self.items())}, nullable={self.nullable})"
960+
name = self.__class__.__name__
961+
return f"{name}({list(self.items())}, nullable={self.nullable})"
966962

967963
@property
968964
def _pretty_piece(self) -> str:

0 commit comments

Comments
 (0)