Skip to content

Commit b669f59

Browse files
committed
v1.20.10 Prefer NamedTuple over namedtuple
1 parent 3b1f65b commit b669f59

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

tableschema/VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.20.9
1+
1.20.10

tableschema/types/geopoint.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import six
88
import json
9-
from collections import namedtuple
9+
from typing import NamedTuple
1010
from decimal import Decimal
1111
from ..config import ERROR
1212

@@ -50,5 +50,9 @@ def cast_geopoint(format, value, **options):
5050

5151
# Internal
5252

53-
_geopoint = namedtuple('geopoint', ['lon', 'lat'])
54-
_geopoint.__repr__ = lambda self: str([float(self[0]), float(self[1])])
53+
class _geopoint(NamedTuple):
54+
lon: Decimal
55+
lat: Decimal
56+
57+
def __repr__(self):
58+
return '[%s, %s]' % (self.lon, self.lat)

tableschema/types/yearmonth.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from __future__ import unicode_literals
66

77
import six
8-
from collections import namedtuple
8+
from typing import NamedTuple
99
from ..config import ERROR
1010

1111

@@ -32,5 +32,6 @@ def cast_yearmonth(format, value, **options):
3232

3333

3434
# Internal
35-
36-
_yearmonth = namedtuple('yearmonth', ['year', 'month'])
35+
class _yearmonth(NamedTuple):
36+
year: int
37+
month: int

0 commit comments

Comments
 (0)