Skip to content

Commit 2dcadec

Browse files
authored
Merge branch 'master' into refactor/type_some_recipes
2 parents 755c416 + 491cab3 commit 2dcadec

File tree

16 files changed

+93
-209
lines changed

16 files changed

+93
-209
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Handle the code
14-
uses: actions/checkout@v2
14+
uses: actions/checkout@v3
1515

1616
- name: Set up Python 3.10
17-
uses: actions/setup-python@v2
17+
uses: actions/setup-python@v4
1818
with:
1919
python-version: "3.10"
2020

.github/workflows/testing.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ jobs:
1818

1919
steps:
2020
- name: Handle the code
21-
uses: actions/checkout@v2
21+
uses: actions/checkout@v3
2222

2323
- name: "Set up Python 3.10"
24-
uses: actions/setup-python@v2
24+
uses: actions/setup-python@v4
2525
with:
2626
python-version: "3.10"
2727

2828
- name: Handle pip cache
29-
uses: actions/cache@v2
29+
uses: actions/cache@v3
3030
with:
3131
path: ~/.cache/pip
3232
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
@@ -36,7 +36,7 @@ jobs:
3636
- name: Install required dependencies
3737
run: |
3838
python3 -m pip install --upgrade pip
39-
pip install tox tox-wheel
39+
pip install tox
4040
4141
- name: Code check
4242
run: tox -e ${TOX_VENV}
@@ -70,23 +70,23 @@ jobs:
7070
tox-env: pypy3
7171
steps:
7272
- name: Handle the code
73-
uses: actions/checkout@v2
73+
uses: actions/checkout@v3
7474

7575
- name: Set up Python ${{ matrix.python-version }}
76-
uses: actions/setup-python@v2
76+
uses: actions/setup-python@v4
7777
with:
7878
python-version: ${{ matrix.python-version }}
7979

8080
- name: Handle pip cache
81-
uses: actions/cache@v2
81+
uses: actions/cache@v3
8282
with:
8383
path: ~/.cache/pip
8484
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
8585
restore-keys: |
8686
${{ runner.os }}-pip-
8787
8888
- name: Handle ZK installation cache
89-
uses: actions/cache@v2
89+
uses: actions/cache@v3
9090
with:
9191
path: zookeeper
9292
key: ${{ runner.os }}-zookeeper
@@ -110,4 +110,4 @@ jobs:
110110
ZOOKEEPER_LIB: "${{ !contains(matrix.zk-version, '3.4') && 'lib' || '' }}"
111111

112112
- name: Publish Codecov report
113-
uses: codecov/codecov-action@v2
113+
uses: codecov/codecov-action@v3

kazoo/client.py

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from typing import TYPE_CHECKING
99
import warnings
1010

11-
import six
12-
1311
from kazoo.exceptions import (
1412
AuthFailedError,
1513
ConfigurationError,
@@ -69,9 +67,6 @@
6967
if TYPE_CHECKING:
7068
from typing import Any
7169

72-
string_types = six.string_types
73-
bytes_types = (six.binary_type,)
74-
7570
CLOSED_STATES = (
7671
KeeperState.EXPIRED_SESSION,
7772
KeeperState.AUTH_FAILED,
@@ -417,10 +412,10 @@ def _reset(self):
417412

418413
def _reset_watchers(self):
419414
watchers = []
420-
for child_watchers in six.itervalues(self._child_watchers):
415+
for child_watchers in self._child_watchers.values():
421416
watchers.extend(child_watchers)
422417

423-
for data_watchers in six.itervalues(self._data_watchers):
418+
for data_watchers in self._data_watchers.values():
424419
watchers.extend(data_watchers)
425420

426421
self._child_watchers = defaultdict(set)
@@ -823,7 +818,7 @@ def _is_valid(version):
823818
version = _try_fetch()
824819
if _is_valid(version):
825820
return version
826-
for _i in six.moves.range(0, retries):
821+
for _i in range(0, retries):
827822
version = _try_fetch()
828823
if _is_valid(version):
829824
return version
@@ -856,9 +851,9 @@ def add_auth_async(self, scheme, credential):
856851
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
857852
858853
"""
859-
if not isinstance(scheme, string_types):
854+
if not isinstance(scheme, str):
860855
raise TypeError("Invalid type for 'scheme' (string expected)")
861-
if not isinstance(credential, string_types):
856+
if not isinstance(credential, str):
862857
raise TypeError("Invalid type for 'credential' (string expected)")
863858

864859
# we need this auth data to re-authenticate on reconnect
@@ -1036,15 +1031,15 @@ def create_async(
10361031
if acl is None and self.default_acl:
10371032
acl = self.default_acl
10381033

1039-
if not isinstance(path, string_types):
1034+
if not isinstance(path, str):
10401035
raise TypeError("Invalid type for 'path' (string expected)")
10411036
if acl and (
10421037
isinstance(acl, ACL) or not isinstance(acl, (tuple, list))
10431038
):
10441039
raise TypeError(
10451040
"Invalid type for 'acl' (acl must be a tuple/list" " of ACL's"
10461041
)
1047-
if value is not None and not isinstance(value, bytes_types):
1042+
if value is not None and not isinstance(value, bytes):
10481043
raise TypeError("Invalid type for 'value' (must be a byte string)")
10491044
if not isinstance(ephemeral, bool):
10501045
raise TypeError("Invalid type for 'ephemeral' (bool expected)")
@@ -1207,7 +1202,7 @@ def exists_async(self, path, watch=None):
12071202
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
12081203
12091204
"""
1210-
if not isinstance(path, string_types):
1205+
if not isinstance(path, str):
12111206
raise TypeError("Invalid type for 'path' (string expected)")
12121207
if watch and not callable(watch):
12131208
raise TypeError("Invalid type for 'watch' (must be a callable)")
@@ -1250,7 +1245,7 @@ def get_async(self, path, watch=None):
12501245
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
12511246
12521247
"""
1253-
if not isinstance(path, string_types):
1248+
if not isinstance(path, str):
12541249
raise TypeError("Invalid type for 'path' (string expected)")
12551250
if watch and not callable(watch):
12561251
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):
13061301
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
13071302
13081303
"""
1309-
if not isinstance(path, string_types):
1304+
if not isinstance(path, str):
13101305
raise TypeError("Invalid type for 'path' (string expected)")
13111306
if watch and not callable(watch):
13121307
raise TypeError("Invalid type for 'watch' (must be a callable)")
@@ -1348,7 +1343,7 @@ def get_acls_async(self, path):
13481343
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
13491344
13501345
"""
1351-
if not isinstance(path, string_types):
1346+
if not isinstance(path, str):
13521347
raise TypeError("Invalid type for 'path' (string expected)")
13531348

13541349
async_result = self.handler.async_result()
@@ -1391,7 +1386,7 @@ def set_acls_async(self, path, acls, version=-1):
13911386
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
13921387
13931388
"""
1394-
if not isinstance(path, string_types):
1389+
if not isinstance(path, str):
13951390
raise TypeError("Invalid type for 'path' (string expected)")
13961391
if isinstance(acls, ACL) or not isinstance(acls, (tuple, list)):
13971392
raise TypeError(
@@ -1449,9 +1444,9 @@ def set_async(self, path, value, version=-1):
14491444
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
14501445
14511446
"""
1452-
if not isinstance(path, string_types):
1447+
if not isinstance(path, str):
14531448
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):
14551450
raise TypeError("Invalid type for 'value' (must be a byte string)")
14561451
if not isinstance(version, int):
14571452
raise TypeError("Invalid type for 'version' (int expected)")
@@ -1525,7 +1520,7 @@ def delete_async(self, path, version=-1):
15251520
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
15261521
15271522
"""
1528-
if not isinstance(path, string_types):
1523+
if not isinstance(path, str):
15291524
raise TypeError("Invalid type for 'path' (string expected)")
15301525
if not isinstance(version, int):
15311526
raise TypeError("Invalid type for 'version' (int expected)")
@@ -1634,11 +1629,11 @@ def reconfig_async(self, joining, leaving, new_members, from_config):
16341629
:rtype: :class:`~kazoo.interfaces.IAsyncResult`
16351630
16361631
"""
1637-
if joining and not isinstance(joining, string_types):
1632+
if joining and not isinstance(joining, str):
16381633
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):
16401635
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):
16421637
raise TypeError(
16431638
"Invalid type for 'new_members' (string " "expected)"
16441639
)
@@ -1692,13 +1687,13 @@ def create(
16921687
if acl is None and self.client.default_acl:
16931688
acl = self.client.default_acl
16941689

1695-
if not isinstance(path, string_types):
1690+
if not isinstance(path, str):
16961691
raise TypeError("Invalid type for 'path' (string expected)")
16971692
if acl and not isinstance(acl, (tuple, list)):
16981693
raise TypeError(
16991694
"Invalid type for 'acl' (acl must be a tuple/list" " of ACL's"
17001695
)
1701-
if not isinstance(value, bytes_types):
1696+
if not isinstance(value, bytes):
17021697
raise TypeError("Invalid type for 'value' (must be a byte string)")
17031698
if not isinstance(ephemeral, bool):
17041699
raise TypeError("Invalid type for 'ephemeral' (bool expected)")
@@ -1724,7 +1719,7 @@ def delete(self, path, version=-1):
17241719
`recursive`.
17251720
17261721
"""
1727-
if not isinstance(path, string_types):
1722+
if not isinstance(path, str):
17281723
raise TypeError("Invalid type for 'path' (string expected)")
17291724
if not isinstance(version, int):
17301725
raise TypeError("Invalid type for 'version' (int expected)")
@@ -1735,9 +1730,9 @@ def set_data(self, path, value, version=-1):
17351730
arguments as :meth:`KazooClient.set`.
17361731
17371732
"""
1738-
if not isinstance(path, string_types):
1733+
if not isinstance(path, str):
17391734
raise TypeError("Invalid type for 'path' (string expected)")
1740-
if not isinstance(value, bytes_types):
1735+
if not isinstance(value, bytes):
17411736
raise TypeError("Invalid type for 'value' (must be a byte string)")
17421737
if not isinstance(version, int):
17431738
raise TypeError("Invalid type for 'version' (int expected)")
@@ -1752,7 +1747,7 @@ def check(self, path, version):
17521747
does not match the specified version.
17531748
17541749
"""
1755-
if not isinstance(path, string_types):
1750+
if not isinstance(path, str):
17561751
raise TypeError("Invalid type for 'path' (string expected)")
17571752
if not isinstance(version, int):
17581753
raise TypeError("Invalid type for 'version' (int expected)")

kazoo/handlers/eventlet.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""A eventlet based handler."""
22
from __future__ import absolute_import
33

4+
import atexit
45
import contextlib
56
import logging
67

@@ -12,7 +13,6 @@
1213
from eventlet import queue as green_queue
1314

1415
from kazoo.handlers import utils
15-
import kazoo.python2atexit as python2atexit
1616
from kazoo.handlers.utils import selector_select
1717

1818
LOG = logging.getLogger(__name__)
@@ -140,15 +140,15 @@ def start(self):
140140
w = eventlet.spawn(self._process_callback_queue)
141141
self._workers.append((w, self.callback_queue))
142142
self._started = True
143-
python2atexit.register(self.stop)
143+
atexit.register(self.stop)
144144

145145
def stop(self):
146146
while self._workers:
147147
w, q = self._workers.pop()
148148
q.put(_STOP)
149149
w.wait()
150150
self._started = False
151-
python2atexit.unregister(self.stop)
151+
atexit.unregister(self.stop)
152152

153153
def socket(self, *args, **kwargs):
154154
return utils.create_tcp_socket(green_socket)

kazoo/handlers/gevent.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""A gevent based handler."""
22
from __future__ import absolute_import
33

4+
import atexit
45
import logging
56

67
import gevent
@@ -13,13 +14,9 @@
1314

1415
from kazoo.handlers.utils import selector_select
1516

16-
try:
17-
from gevent.lock import Semaphore, RLock
18-
except ImportError:
19-
from gevent.coros import Semaphore, RLock
17+
from gevent.lock import Semaphore, RLock
2018

2119
from kazoo.handlers import utils
22-
from kazoo import python2atexit
2320

2421
_using_libevent = gevent.__version__.startswith("0.")
2522

@@ -104,7 +101,7 @@ def start(self):
104101
for queue in (self.callback_queue,):
105102
w = self._create_greenlet_worker(queue)
106103
self._workers.append(w)
107-
python2atexit.register(self.stop)
104+
atexit.register(self.stop)
108105

109106
def stop(self):
110107
"""Stop the greenlet workers and empty all queues."""
@@ -124,7 +121,7 @@ def stop(self):
124121
# Clear the queues
125122
self.callback_queue = self.queue_impl() # pragma: nocover
126123

127-
python2atexit.unregister(self.stop)
124+
atexit.unregister(self.stop)
128125

129126
def select(self, *args, **kwargs):
130127
return selector_select(

0 commit comments

Comments
 (0)