Skip to content

Commit

Permalink
Correctly overide map method in ValueMappers
Browse files Browse the repository at this point in the history
The name of a parameter is significant unless it's a positional-only
parameter.
  • Loading branch information
hashhar committed Feb 7, 2024
1 parent c5c99c5 commit 9e6c986
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions trino/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,22 +176,22 @@ class ArrayValueMapper(ValueMapper[List[Optional[Any]]]):
def __init__(self, mapper: ValueMapper[Any]):
self.mapper = mapper

def map(self, values: List[Any]) -> Optional[List[Any]]:
if values is None:
def map(self, value: List[Any]) -> Optional[List[Any]]:
if value is None:
return None
return [self.mapper.map(value) for value in values]
return [self.mapper.map(v) for v in value]


class MapValueMapper(ValueMapper[Dict[Any, Optional[Any]]]):
def __init__(self, key_mapper: ValueMapper[Any], value_mapper: ValueMapper[Any]):
self.key_mapper = key_mapper
self.value_mapper = value_mapper

def map(self, values: Any) -> Optional[Dict[Any, Optional[Any]]]:
if values is None:
def map(self, value: Any) -> Optional[Dict[Any, Optional[Any]]]:
if value is None:
return None
return {
self.key_mapper.map(key): self.value_mapper.map(value) for key, value in values.items()
self.key_mapper.map(k): self.value_mapper.map(v) for k, v in value.items()
}


Expand All @@ -201,11 +201,11 @@ def __init__(self, mappers: List[ValueMapper[Any]], names: List[str], types: Lis
self.names = names
self.types = types

def map(self, values: List[Any]) -> Optional[Tuple[Optional[Any], ...]]:
if values is None:
def map(self, value: List[Any]) -> Optional[Tuple[Optional[Any], ...]]:
if value is None:
return None
return NamedRowTuple(
list(self.mappers[index].map(value) for index, value in enumerate(values)),
list(self.mappers[i].map(v) for i, v in enumerate(value)),
self.names,
self.types
)
Expand Down

0 comments on commit 9e6c986

Please sign in to comment.