8
8
from typing import TYPE_CHECKING
9
9
import warnings
10
10
11
- import six
12
-
13
11
from kazoo .exceptions import (
14
12
AuthFailedError ,
15
13
ConfigurationError ,
69
67
if TYPE_CHECKING :
70
68
from typing import Any
71
69
72
- string_types = six .string_types
73
- bytes_types = (six .binary_type ,)
74
-
75
70
CLOSED_STATES = (
76
71
KeeperState .EXPIRED_SESSION ,
77
72
KeeperState .AUTH_FAILED ,
@@ -417,10 +412,10 @@ def _reset(self):
417
412
418
413
def _reset_watchers (self ):
419
414
watchers = []
420
- for child_watchers in six . itervalues ( self ._child_watchers ):
415
+ for child_watchers in self ._child_watchers . values ( ):
421
416
watchers .extend (child_watchers )
422
417
423
- for data_watchers in six . itervalues ( self ._data_watchers ):
418
+ for data_watchers in self ._data_watchers . values ( ):
424
419
watchers .extend (data_watchers )
425
420
426
421
self ._child_watchers = defaultdict (set )
@@ -823,7 +818,7 @@ def _is_valid(version):
823
818
version = _try_fetch ()
824
819
if _is_valid (version ):
825
820
return version
826
- for _i in six . moves . range (0 , retries ):
821
+ for _i in range (0 , retries ):
827
822
version = _try_fetch ()
828
823
if _is_valid (version ):
829
824
return version
@@ -856,9 +851,9 @@ def add_auth_async(self, scheme, credential):
856
851
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
857
852
858
853
"""
859
- if not isinstance (scheme , string_types ):
854
+ if not isinstance (scheme , str ):
860
855
raise TypeError ("Invalid type for 'scheme' (string expected)" )
861
- if not isinstance (credential , string_types ):
856
+ if not isinstance (credential , str ):
862
857
raise TypeError ("Invalid type for 'credential' (string expected)" )
863
858
864
859
# we need this auth data to re-authenticate on reconnect
@@ -1036,15 +1031,15 @@ def create_async(
1036
1031
if acl is None and self .default_acl :
1037
1032
acl = self .default_acl
1038
1033
1039
- if not isinstance (path , string_types ):
1034
+ if not isinstance (path , str ):
1040
1035
raise TypeError ("Invalid type for 'path' (string expected)" )
1041
1036
if acl and (
1042
1037
isinstance (acl , ACL ) or not isinstance (acl , (tuple , list ))
1043
1038
):
1044
1039
raise TypeError (
1045
1040
"Invalid type for 'acl' (acl must be a tuple/list" " of ACL's"
1046
1041
)
1047
- if value is not None and not isinstance (value , bytes_types ):
1042
+ if value is not None and not isinstance (value , bytes ):
1048
1043
raise TypeError ("Invalid type for 'value' (must be a byte string)" )
1049
1044
if not isinstance (ephemeral , bool ):
1050
1045
raise TypeError ("Invalid type for 'ephemeral' (bool expected)" )
@@ -1207,7 +1202,7 @@ def exists_async(self, path, watch=None):
1207
1202
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
1208
1203
1209
1204
"""
1210
- if not isinstance (path , string_types ):
1205
+ if not isinstance (path , str ):
1211
1206
raise TypeError ("Invalid type for 'path' (string expected)" )
1212
1207
if watch and not callable (watch ):
1213
1208
raise TypeError ("Invalid type for 'watch' (must be a callable)" )
@@ -1250,7 +1245,7 @@ def get_async(self, path, watch=None):
1250
1245
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
1251
1246
1252
1247
"""
1253
- if not isinstance (path , string_types ):
1248
+ if not isinstance (path , str ):
1254
1249
raise TypeError ("Invalid type for 'path' (string expected)" )
1255
1250
if watch and not callable (watch ):
1256
1251
raise TypeError ("Invalid type for 'watch' (must be a callable)" )
@@ -1306,7 +1301,7 @@ def get_children_async(self, path, watch=None, include_data=False):
1306
1301
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
1307
1302
1308
1303
"""
1309
- if not isinstance (path , string_types ):
1304
+ if not isinstance (path , str ):
1310
1305
raise TypeError ("Invalid type for 'path' (string expected)" )
1311
1306
if watch and not callable (watch ):
1312
1307
raise TypeError ("Invalid type for 'watch' (must be a callable)" )
@@ -1348,7 +1343,7 @@ def get_acls_async(self, path):
1348
1343
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
1349
1344
1350
1345
"""
1351
- if not isinstance (path , string_types ):
1346
+ if not isinstance (path , str ):
1352
1347
raise TypeError ("Invalid type for 'path' (string expected)" )
1353
1348
1354
1349
async_result = self .handler .async_result ()
@@ -1391,7 +1386,7 @@ def set_acls_async(self, path, acls, version=-1):
1391
1386
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
1392
1387
1393
1388
"""
1394
- if not isinstance (path , string_types ):
1389
+ if not isinstance (path , str ):
1395
1390
raise TypeError ("Invalid type for 'path' (string expected)" )
1396
1391
if isinstance (acls , ACL ) or not isinstance (acls , (tuple , list )):
1397
1392
raise TypeError (
@@ -1449,9 +1444,9 @@ def set_async(self, path, value, version=-1):
1449
1444
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
1450
1445
1451
1446
"""
1452
- if not isinstance (path , string_types ):
1447
+ if not isinstance (path , str ):
1453
1448
raise TypeError ("Invalid type for 'path' (string expected)" )
1454
- if value is not None and not isinstance (value , bytes_types ):
1449
+ if value is not None and not isinstance (value , bytes ):
1455
1450
raise TypeError ("Invalid type for 'value' (must be a byte string)" )
1456
1451
if not isinstance (version , int ):
1457
1452
raise TypeError ("Invalid type for 'version' (int expected)" )
@@ -1525,7 +1520,7 @@ def delete_async(self, path, version=-1):
1525
1520
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
1526
1521
1527
1522
"""
1528
- if not isinstance (path , string_types ):
1523
+ if not isinstance (path , str ):
1529
1524
raise TypeError ("Invalid type for 'path' (string expected)" )
1530
1525
if not isinstance (version , int ):
1531
1526
raise TypeError ("Invalid type for 'version' (int expected)" )
@@ -1634,11 +1629,11 @@ def reconfig_async(self, joining, leaving, new_members, from_config):
1634
1629
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
1635
1630
1636
1631
"""
1637
- if joining and not isinstance (joining , string_types ):
1632
+ if joining and not isinstance (joining , str ):
1638
1633
raise TypeError ("Invalid type for 'joining' (string expected)" )
1639
- if leaving and not isinstance (leaving , string_types ):
1634
+ if leaving and not isinstance (leaving , str ):
1640
1635
raise TypeError ("Invalid type for 'leaving' (string expected)" )
1641
- if new_members and not isinstance (new_members , string_types ):
1636
+ if new_members and not isinstance (new_members , str ):
1642
1637
raise TypeError (
1643
1638
"Invalid type for 'new_members' (string " "expected)"
1644
1639
)
@@ -1692,13 +1687,13 @@ def create(
1692
1687
if acl is None and self .client .default_acl :
1693
1688
acl = self .client .default_acl
1694
1689
1695
- if not isinstance (path , string_types ):
1690
+ if not isinstance (path , str ):
1696
1691
raise TypeError ("Invalid type for 'path' (string expected)" )
1697
1692
if acl and not isinstance (acl , (tuple , list )):
1698
1693
raise TypeError (
1699
1694
"Invalid type for 'acl' (acl must be a tuple/list" " of ACL's"
1700
1695
)
1701
- if not isinstance (value , bytes_types ):
1696
+ if not isinstance (value , bytes ):
1702
1697
raise TypeError ("Invalid type for 'value' (must be a byte string)" )
1703
1698
if not isinstance (ephemeral , bool ):
1704
1699
raise TypeError ("Invalid type for 'ephemeral' (bool expected)" )
@@ -1724,7 +1719,7 @@ def delete(self, path, version=-1):
1724
1719
`recursive`.
1725
1720
1726
1721
"""
1727
- if not isinstance (path , string_types ):
1722
+ if not isinstance (path , str ):
1728
1723
raise TypeError ("Invalid type for 'path' (string expected)" )
1729
1724
if not isinstance (version , int ):
1730
1725
raise TypeError ("Invalid type for 'version' (int expected)" )
@@ -1735,9 +1730,9 @@ def set_data(self, path, value, version=-1):
1735
1730
arguments as :meth:`KazooClient.set`.
1736
1731
1737
1732
"""
1738
- if not isinstance (path , string_types ):
1733
+ if not isinstance (path , str ):
1739
1734
raise TypeError ("Invalid type for 'path' (string expected)" )
1740
- if not isinstance (value , bytes_types ):
1735
+ if not isinstance (value , bytes ):
1741
1736
raise TypeError ("Invalid type for 'value' (must be a byte string)" )
1742
1737
if not isinstance (version , int ):
1743
1738
raise TypeError ("Invalid type for 'version' (int expected)" )
@@ -1752,7 +1747,7 @@ def check(self, path, version):
1752
1747
does not match the specified version.
1753
1748
1754
1749
"""
1755
- if not isinstance (path , string_types ):
1750
+ if not isinstance (path , str ):
1756
1751
raise TypeError ("Invalid type for 'path' (string expected)" )
1757
1752
if not isinstance (version , int ):
1758
1753
raise TypeError ("Invalid type for 'version' (int expected)" )
0 commit comments