77import re
88import warnings
99
10- import six
11-
1210from kazoo .exceptions import (
1311 AuthFailedError ,
1412 ConfigurationError ,
6664from kazoo .recipe .watchers import ChildrenWatch , DataWatch
6765
6866
69- string_types = six .string_types
70- bytes_types = (six .binary_type ,)
71-
7267CLOSED_STATES = (
7368 KeeperState .EXPIRED_SESSION ,
7469 KeeperState .AUTH_FAILED ,
@@ -415,10 +410,10 @@ def _reset(self):
415410
416411 def _reset_watchers (self ):
417412 watchers = []
418- for child_watchers in six . itervalues ( self ._child_watchers ):
413+ for child_watchers in self ._child_watchers . values ( ):
419414 watchers .extend (child_watchers )
420415
421- for data_watchers in six . itervalues ( self ._data_watchers ):
416+ for data_watchers in self ._data_watchers . values ( ):
422417 watchers .extend (data_watchers )
423418
424419 self ._child_watchers = defaultdict (set )
@@ -821,7 +816,7 @@ def _is_valid(version):
821816 version = _try_fetch ()
822817 if _is_valid (version ):
823818 return version
824- for _i in six . moves . range (0 , retries ):
819+ for _i in range (0 , retries ):
825820 version = _try_fetch ()
826821 if _is_valid (version ):
827822 return version
@@ -854,9 +849,9 @@ def add_auth_async(self, scheme, credential):
854849 :rtype: :class:`~kazoo.interfaces.IAsyncResult`
855850
856851 """
857- if not isinstance (scheme , string_types ):
852+ if not isinstance (scheme , str ):
858853 raise TypeError ("Invalid type for 'scheme' (string expected)" )
859- if not isinstance (credential , string_types ):
854+ if not isinstance (credential , str ):
860855 raise TypeError ("Invalid type for 'credential' (string expected)" )
861856
862857 # we need this auth data to re-authenticate on reconnect
@@ -1034,15 +1029,15 @@ def create_async(
10341029 if acl is None and self .default_acl :
10351030 acl = self .default_acl
10361031
1037- if not isinstance (path , string_types ):
1032+ if not isinstance (path , str ):
10381033 raise TypeError ("Invalid type for 'path' (string expected)" )
10391034 if acl and (
10401035 isinstance (acl , ACL ) or not isinstance (acl , (tuple , list ))
10411036 ):
10421037 raise TypeError (
10431038 "Invalid type for 'acl' (acl must be a tuple/list" " of ACL's"
10441039 )
1045- if value is not None and not isinstance (value , bytes_types ):
1040+ if value is not None and not isinstance (value , bytes ):
10461041 raise TypeError ("Invalid type for 'value' (must be a byte string)" )
10471042 if not isinstance (ephemeral , bool ):
10481043 raise TypeError ("Invalid type for 'ephemeral' (bool expected)" )
@@ -1205,7 +1200,7 @@ def exists_async(self, path, watch=None):
12051200 :rtype: :class:`~kazoo.interfaces.IAsyncResult`
12061201
12071202 """
1208- if not isinstance (path , string_types ):
1203+ if not isinstance (path , str ):
12091204 raise TypeError ("Invalid type for 'path' (string expected)" )
12101205 if watch and not callable (watch ):
12111206 raise TypeError ("Invalid type for 'watch' (must be a callable)" )
@@ -1248,7 +1243,7 @@ def get_async(self, path, watch=None):
12481243 :rtype: :class:`~kazoo.interfaces.IAsyncResult`
12491244
12501245 """
1251- if not isinstance (path , string_types ):
1246+ if not isinstance (path , str ):
12521247 raise TypeError ("Invalid type for 'path' (string expected)" )
12531248 if watch and not callable (watch ):
12541249 raise TypeError ("Invalid type for 'watch' (must be a callable)" )
@@ -1304,7 +1299,7 @@ def get_children_async(self, path, watch=None, include_data=False):
13041299 :rtype: :class:`~kazoo.interfaces.IAsyncResult`
13051300
13061301 """
1307- if not isinstance (path , string_types ):
1302+ if not isinstance (path , str ):
13081303 raise TypeError ("Invalid type for 'path' (string expected)" )
13091304 if watch and not callable (watch ):
13101305 raise TypeError ("Invalid type for 'watch' (must be a callable)" )
@@ -1346,7 +1341,7 @@ def get_acls_async(self, path):
13461341 :rtype: :class:`~kazoo.interfaces.IAsyncResult`
13471342
13481343 """
1349- if not isinstance (path , string_types ):
1344+ if not isinstance (path , str ):
13501345 raise TypeError ("Invalid type for 'path' (string expected)" )
13511346
13521347 async_result = self .handler .async_result ()
@@ -1389,7 +1384,7 @@ def set_acls_async(self, path, acls, version=-1):
13891384 :rtype: :class:`~kazoo.interfaces.IAsyncResult`
13901385
13911386 """
1392- if not isinstance (path , string_types ):
1387+ if not isinstance (path , str ):
13931388 raise TypeError ("Invalid type for 'path' (string expected)" )
13941389 if isinstance (acls , ACL ) or not isinstance (acls , (tuple , list )):
13951390 raise TypeError (
@@ -1447,9 +1442,9 @@ def set_async(self, path, value, version=-1):
14471442 :rtype: :class:`~kazoo.interfaces.IAsyncResult`
14481443
14491444 """
1450- if not isinstance (path , string_types ):
1445+ if not isinstance (path , str ):
14511446 raise TypeError ("Invalid type for 'path' (string expected)" )
1452- if value is not None and not isinstance (value , bytes_types ):
1447+ if value is not None and not isinstance (value , bytes ):
14531448 raise TypeError ("Invalid type for 'value' (must be a byte string)" )
14541449 if not isinstance (version , int ):
14551450 raise TypeError ("Invalid type for 'version' (int expected)" )
@@ -1523,7 +1518,7 @@ def delete_async(self, path, version=-1):
15231518 :rtype: :class:`~kazoo.interfaces.IAsyncResult`
15241519
15251520 """
1526- if not isinstance (path , string_types ):
1521+ if not isinstance (path , str ):
15271522 raise TypeError ("Invalid type for 'path' (string expected)" )
15281523 if not isinstance (version , int ):
15291524 raise TypeError ("Invalid type for 'version' (int expected)" )
@@ -1632,11 +1627,11 @@ def reconfig_async(self, joining, leaving, new_members, from_config):
16321627 :rtype: :class:`~kazoo.interfaces.IAsyncResult`
16331628
16341629 """
1635- if joining and not isinstance (joining , string_types ):
1630+ if joining and not isinstance (joining , str ):
16361631 raise TypeError ("Invalid type for 'joining' (string expected)" )
1637- if leaving and not isinstance (leaving , string_types ):
1632+ if leaving and not isinstance (leaving , str ):
16381633 raise TypeError ("Invalid type for 'leaving' (string expected)" )
1639- if new_members and not isinstance (new_members , string_types ):
1634+ if new_members and not isinstance (new_members , str ):
16401635 raise TypeError (
16411636 "Invalid type for 'new_members' (string " "expected)"
16421637 )
@@ -1690,13 +1685,13 @@ def create(
16901685 if acl is None and self .client .default_acl :
16911686 acl = self .client .default_acl
16921687
1693- if not isinstance (path , string_types ):
1688+ if not isinstance (path , str ):
16941689 raise TypeError ("Invalid type for 'path' (string expected)" )
16951690 if acl and not isinstance (acl , (tuple , list )):
16961691 raise TypeError (
16971692 "Invalid type for 'acl' (acl must be a tuple/list" " of ACL's"
16981693 )
1699- if not isinstance (value , bytes_types ):
1694+ if not isinstance (value , bytes ):
17001695 raise TypeError ("Invalid type for 'value' (must be a byte string)" )
17011696 if not isinstance (ephemeral , bool ):
17021697 raise TypeError ("Invalid type for 'ephemeral' (bool expected)" )
@@ -1722,7 +1717,7 @@ def delete(self, path, version=-1):
17221717 `recursive`.
17231718
17241719 """
1725- if not isinstance (path , string_types ):
1720+ if not isinstance (path , str ):
17261721 raise TypeError ("Invalid type for 'path' (string expected)" )
17271722 if not isinstance (version , int ):
17281723 raise TypeError ("Invalid type for 'version' (int expected)" )
@@ -1733,9 +1728,9 @@ def set_data(self, path, value, version=-1):
17331728 arguments as :meth:`KazooClient.set`.
17341729
17351730 """
1736- if not isinstance (path , string_types ):
1731+ if not isinstance (path , str ):
17371732 raise TypeError ("Invalid type for 'path' (string expected)" )
1738- if not isinstance (value , bytes_types ):
1733+ if not isinstance (value , bytes ):
17391734 raise TypeError ("Invalid type for 'value' (must be a byte string)" )
17401735 if not isinstance (version , int ):
17411736 raise TypeError ("Invalid type for 'version' (int expected)" )
@@ -1750,7 +1745,7 @@ def check(self, path, version):
17501745 does not match the specified version.
17511746
17521747 """
1753- if not isinstance (path , string_types ):
1748+ if not isinstance (path , str ):
17541749 raise TypeError ("Invalid type for 'path' (string expected)" )
17551750 if not isinstance (version , int ):
17561751 raise TypeError ("Invalid type for 'version' (int expected)" )
0 commit comments