Skip to content

Commit 43b09f1

Browse files
committed
refactor(datatypes): fully remove unused DataType.name
1 parent 66ab2a5 commit 43b09f1

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

ibis/backends/sql/compilers/impala.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def visit_NonNullLiteral(self, op, *, value, dtype):
173173
)
174174
elif dtype.is_array() or dtype.is_map() or dtype.is_struct():
175175
raise com.UnsupportedBackendType(
176-
f"Impala does not support {dtype.name.lower()} literals"
176+
f"Impala does not support {dtype.__class__.__name__.lower()} literals"
177177
)
178178
elif dtype.is_uuid():
179179
return sge.convert(str(value))

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

+5-8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from public import public
2525
from typing_extensions import Self, get_args, get_origin
2626

27+
from ibis import util
2728
from ibis.common.annotations import attribute
2829
from ibis.common.collections import FrozenOrderedDict, MapSet
2930
from ibis.common.dispatch import lazy_singledispatch
@@ -189,12 +190,6 @@ def column(self): ...
189190
def _pretty_piece(self) -> str:
190191
return ""
191192

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-
198193
@classmethod
199194
def __coerce__(cls, value, **kwargs):
200195
if isinstance(value, cls):
@@ -209,7 +204,8 @@ def __call__(self, **kwargs):
209204

210205
def __str__(self) -> str:
211206
prefix = "!" * (not self.nullable)
212-
return f"{prefix}{self.name.lower()}{self._pretty_piece}"
207+
name = self.__class__.__name__.lower()
208+
return f"{prefix}{name}{self._pretty_piece}"
213209

214210
def equals(self, other: DataType) -> bool:
215211
if not isinstance(other, DataType):
@@ -962,7 +958,8 @@ def __getitem__(self, key: str) -> DataType:
962958
return self.fields[key]
963959

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

967964
@property
968965
def _pretty_piece(self) -> str:

0 commit comments

Comments
 (0)