Skip to content

Commit 2ebe5ff

Browse files
committed
replace usage of six.string_types by plain str
1 parent afd3d56 commit 2ebe5ff

File tree

12 files changed

+15
-30
lines changed

12 files changed

+15
-30
lines changed

nixio/block.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from sys import maxsize as maxint
1414
import numpy as np
1515
from inspect import isclass
16-
from six import string_types
1716
try:
1817
from collections.abc import OrderedDict
1918
except ImportError:
@@ -358,8 +357,7 @@ def create_data_frame(self, name="", type_="", col_dict=None,
358357
if col_dict is not None:
359358
for nam, dt in col_dict.items():
360359
if isclass(dt):
361-
if any(issubclass(dt, st) for st in string_types) \
362-
or issubclass(dt, np.string_):
360+
if issubclass(dt, str) or issubclass(dt, np.string_):
363361
col_dict[nam] = util.vlen_str_dtype
364362
if 'U' in str(dt) or dt == np.string_:
365363
col_dict[nam] = util.vlen_str_dtype

nixio/data_frame.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from .data_set import DataSet
2020
from .datatype import DataType
2121
from .section import Section
22-
from six import string_types
2322
import csv
2423

2524

@@ -55,8 +54,7 @@ def append_column(self, column, name, datatype=None):
5554
raise ValueError("Too much entries for column in this dataframe")
5655
if datatype is None:
5756
datatype = DataType.get_dtype(column[0])
58-
if isclass(datatype) and any(issubclass(datatype, st)
59-
for st in string_types):
57+
if isclass(datatype) and issubclass(datatype, str):
6058
datatype = util.vlen_str_dtype
6159
dt_arr = [(n, dty) for n, dty in zip(self.column_names, self.dtype)]
6260
dt_arr.append((name, datatype))

nixio/datatype.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# modification, are permitted under the terms of the BSD License. See
88
# LICENSE file in the root of the Project.
99
from numbers import Integral, Real
10-
from six import string_types
1110

1211
import numpy as np
1312

@@ -41,7 +40,7 @@ def get_dtype(cls, value):
4140
return cls.Int64
4241
elif isinstance(value, Real):
4342
return cls.Double
44-
elif isinstance(value, string_types):
43+
elif isinstance(value, str):
4544
return cls.String
4645
else:
4746
raise ValueError("Unknown type for value {}".format(value))

nixio/feature.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from .data_frame import DataFrame
1111
from .link_type import LinkType
1212
from .exceptions import UnsupportedLinkType
13-
from six import string_types
1413
from .util import util
1514

1615

@@ -53,7 +52,7 @@ def link_type(self):
5352

5453
@link_type.setter
5554
def link_type(self, link_type):
56-
if isinstance(link_type, string_types):
55+
if isinstance(link_type, str):
5756
link_type = link_type.lower()
5857
link_type = LinkType(link_type)
5958
self._h5group.set_attr("link_type", link_type.value)

nixio/property.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from collections import Sequence, Iterable
1414
from enum import Enum
1515
from numbers import Number
16-
from six import string_types, ensure_str, ensure_text
16+
from six import ensure_str, ensure_text
1717
import numpy as np
1818

1919
from .datatype import DataType
@@ -268,7 +268,7 @@ def values(self, vals):
268268
self.delete_values()
269269
return
270270

271-
if not isinstance(vals, (Sequence, Iterable)) or isinstance(vals, string_types):
271+
if not isinstance(vals, (Sequence, Iterable)) or isinstance(vals, str):
272272
vals = [vals]
273273

274274
# Make sure all values are of the same data type
@@ -294,7 +294,7 @@ def extend_values(self, data):
294294
dataset.write_data(arr, slc=np.s_[src_len: src_len + dlen])
295295

296296
def _check_new_value_types(self, data):
297-
if isinstance(data, (Sequence, Iterable)) and not isinstance(data, string_types):
297+
if isinstance(data, (Sequence, Iterable)) and not isinstance(data, str):
298298
single_val = data[0]
299299
else:
300300
single_val = data

nixio/section.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from collections.abc import Sequence, Iterable
1515
except ImportError:
1616
from collections import Sequence, Iterable
17-
from six import string_types
1817
import numpy as np
1918
from .container import Container, SectionContainer
2019
from .datatype import DataType
@@ -147,7 +146,7 @@ def create_property(self, name="", values_or_dtype=0, oid=None,
147146
# Make sure all values are of the same data type
148147
single_val = vals
149148
if (isinstance(vals, (Sequence, Iterable)) and
150-
not isinstance(vals, string_types)):
149+
not isinstance(vals, str)):
151150
single_val = vals[0]
152151
else:
153152
# Make sure the data will always be created with an array.

nixio/tag.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import warnings
1010

1111
import numpy as np
12-
from six import string_types
1312

1413
from .entity import Entity
1514
from .source_link_container import SourceLinkContainer
@@ -107,7 +106,7 @@ def create_feature(self, data, link_type):
107106
:returns: The created feature object.
108107
:rtype: nixio.Feature
109108
"""
110-
if isinstance(link_type, string_types):
109+
if isinstance(link_type, str):
111110
link_type = link_type.lower()
112111
link_type = LinkType(link_type)
113112
features = self._h5group.open_group("features")

nixio/test/test_data_array.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
# LICENSE file in the root of the Project.
99
import os
1010
import time
11-
from six import string_types
1211
import sys
1312
import unittest
1413
import numpy as np
@@ -307,8 +306,8 @@ def test_data_array_dimensions(self):
307306
self.assertRaises(IndexError, lambda: self.array.dimensions[-4])
308307
self.assertRaises(IndexError, lambda: self.array.dimensions[3])
309308

310-
assert isinstance(str(self.array.dimensions), string_types)
311-
assert isinstance(repr(self.array.dimensions), string_types)
309+
assert isinstance(str(self.array.dimensions), str)
310+
assert isinstance(repr(self.array.dimensions), str)
312311

313312
dims = list(self.array.dimensions)
314313
for i in range(3):

nixio/test/test_data_frame.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import os
66
import time
77
import numpy as np
8-
from six import string_types
98
try:
109
from collections.abc import OrderedDict
1110
except ImportError:
@@ -65,7 +64,7 @@ def test_create_with_list(self):
6564
assert df_li.column_names == self.df1.column_names
6665
assert df_li.dtype == self.df1.dtype
6766
for i in df_li[:]:
68-
self.assertIsInstance(i['id'], string_types)
67+
self.assertIsInstance(i['id'], str)
6968
self.assertIsInstance(i['sig2'], np.int32)
7069

7170
def test_column_name_collision(self):

nixio/test/test_nix_compatibility.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
except ImportError:
1313
from collections import Iterable
1414
from collections import OrderedDict
15-
from six import string_types
1615
from subprocess import Popen, PIPE
1716
import numpy as np
1817
import pytest
@@ -725,7 +724,7 @@ def check_group_children_counts(group, nda, ntg, nmt):
725724
def compare(expected, actual):
726725
if (isinstance(expected, Iterable) and
727726
isinstance(actual, Iterable) and not
728-
isinstance(expected, string_types)):
727+
isinstance(expected, str)):
729728
assert len(expected) == len(actual), "Expected {}, got {}".format(expected, actual)
730729
for exp, act in zip(expected, actual):
731730
compare(exp, act)

0 commit comments

Comments
 (0)