Skip to content

Commit

Permalink
chore: Upgrade dependencies (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol authored Feb 28, 2024
1 parent ff5a869 commit d0461d0
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 63 deletions.
9 changes: 3 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.287
rev: v0.2.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies: [
Expand Down
1 change: 1 addition & 0 deletions changes/26.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update dependencies including pyzmq ('>=23' → '>=25.1.1' to support Python 3.12) and development tools including ruff to replace the black formatter
1 change: 1 addition & 0 deletions examples/simple-consumer-redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
whether each consumer gets only the messages
which have not been obtained by others so far.
"""

import asyncio
import json
import logging
Expand Down
1 change: 1 addition & 0 deletions examples/simple-publisher-redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
simultaneously, so as to check whether messages from
multiple publishers are distributed among the consumers.
"""

import asyncio
import json
import logging
Expand Down
20 changes: 8 additions & 12 deletions examples/simple-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,14 @@ async def handle_output(request):

async def handle_show_memory_stat(request):
global last_snapshot, scheduler
last_snapshot = last_snapshot.filter_traces(
(
tracemalloc.Filter(False, "<frozen importlib._bootstrap>"),
tracemalloc.Filter(False, tracemalloc.__file__),
)
)
new_snapshot = tracemalloc.take_snapshot().filter_traces(
(
tracemalloc.Filter(False, "<frozen importlib._bootstrap>"),
tracemalloc.Filter(False, tracemalloc.__file__),
)
)
last_snapshot = last_snapshot.filter_traces((
tracemalloc.Filter(False, "<frozen importlib._bootstrap>"),
tracemalloc.Filter(False, tracemalloc.__file__),
))
new_snapshot = tracemalloc.take_snapshot().filter_traces((
tracemalloc.Filter(False, "<frozen importlib._bootstrap>"),
tracemalloc.Filter(False, tracemalloc.__file__),
))
top_stats = new_snapshot.compare_to(last_snapshot, "lineno")
last_snapshot = new_snapshot
print("[ Top 10 differences ]")
Expand Down
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ underlines = ["", "", ""]
[tool.ruff]
line-length = 85
src = ["src"]
preview = true
target-version = "py311"

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
Expand All @@ -58,14 +62,11 @@ select = [
]
ignore = ["E203","E731","E501"]

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["callosum"]
known-local-folder = ["src"]
split-on-trailing-comma = true

[tool.black]
line-length = 85

[tool.mypy]
ignore_missing_imports = true

Expand Down
15 changes: 7 additions & 8 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ python_requires = >=3.11
install_requires =
attrs>=21.3.0
python-dateutil>=2.8.2
msgpack>=1.0.4
msgpack>=1.0.7
temporenc>=0.1
yarl>=1.8.2
yarl>=1.9.4
zip_safe = false
include_package_data = true

Expand All @@ -65,19 +65,18 @@ test =
dev =
pre-commit
lint =
black~=23.9.1
ruff>=0.0.287
ruff-lsp>=0.0.38
ruff>=0.2.2
ruff-lsp>=0.0.52
typecheck =
mypy~=1.5.1
mypy~=1.8.0
types-python-dateutil
docs =
sphinx~=4.3
sphinx-autodoc-typehints
thrift =
thriftpy2>=0.4.16
thriftpy2>=0.4.20
zeromq =
pyzmq>=23.0.0
pyzmq>=25.1.1
redis =
redis>=4.6.0
snappy =
Expand Down
1 change: 0 additions & 1 deletion src/callosum/lower/dispatch_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ async def __aexit__(self, exc_type, exc_obj, exc_tb):


class DispatchRedisTransport(BaseTransport):

"""
Implementation for unidirectional transport backend by Redis Streams.
"""
Expand Down
1 change: 0 additions & 1 deletion src/callosum/lower/rpc_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ async def __aexit__(self, exc_type, exc_obj, exc_tb):


class RPCRedisTransport(BaseTransport):

"""
Implementation for bidirectional transport backend by Redis Streams.
"""
Expand Down
41 changes: 17 additions & 24 deletions src/callosum/lower/zeromq.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,12 @@ async def recv_message(self) -> AsyncGenerator[Optional[RawHeaderBody], None]:
multipart_msg = await self.transport._sock.recv_multipart()
*pre, zmsg_type, raw_header, raw_body = multipart_msg
if zmsg_type == b"PING":
await self.transport._sock.send_multipart(
[
*pre,
b"PONG",
raw_header,
raw_body,
]
)
await self.transport._sock.send_multipart([
*pre,
b"PONG",
raw_header,
raw_body,
])
elif zmsg_type == b"UPPER":
if len(pre) > 0:
# server
Expand All @@ -250,23 +248,19 @@ async def send_message(self, raw_msg: RawHeaderBody) -> None:
peer_id = raw_msg.peer_id
if peer_id is not None:
# server
await self.transport._sock.send_multipart(
[
peer_id,
b"UPPER",
raw_msg.header,
raw_msg.body,
]
)
await self.transport._sock.send_multipart([
peer_id,
b"UPPER",
raw_msg.header,
raw_msg.body,
])
else:
# client
await self.transport._sock.send_multipart(
[
b"UPPER",
raw_msg.header,
raw_msg.body,
]
)
await self.transport._sock.send_multipart([
b"UPPER",
raw_msg.header,
raw_msg.body,
])


class ZeroMQMonitorMixin:
Expand Down Expand Up @@ -469,7 +463,6 @@ class ZeroMQSubConnector(ZeroMQBaseConnector):


class ZeroMQBaseTransport(BaseTransport):

"""
Implementation for the ZeorMQ-backed transport.
Expand Down
1 change: 0 additions & 1 deletion src/callosum/ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ def cleanup(self, request_id) -> None:
self._tasks.pop(request_id, None)

async def cancel(self, request_id) -> None:
method, okey, seq = request_id
if request_id in self._futures:
task = self._tasks.get(request_id, None)
if task is None:
Expand Down
6 changes: 3 additions & 3 deletions src/callosum/rpc/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ async def _recv_loop(self) -> None:
client_request_id[1],
server_seq_id,
)
self._req_idmap[
(request.peer_id, client_request_id)
] = server_request_id
self._req_idmap[(request.peer_id, client_request_id)] = (
server_request_id
)
func_handler = self._lookup_func(request.method)
task = asyncio.create_task(
self._func_task(
Expand Down
6 changes: 3 additions & 3 deletions tests/test_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def dummy_client(
async def test_messaging(scheduler_cls) -> None:
done = asyncio.Event()
total = 50
call_results: List[int] = []
call_results: List[int | BaseException] = []
return_results: List[int] = []
# a list of events to make fucntions to return in the reversed order
order_events = [asyncio.Event() for _ in range(total)]
Expand Down Expand Up @@ -159,7 +159,7 @@ async def test_messaging_server_cancellation(scheduler_cls) -> None:
total = 200
cancel_idxs = [False] * 130 + [True] * 70
random.shuffle(cancel_idxs)
call_results: List[int] = []
call_results: List[int | BaseException] = []
return_results: List[int] = []
# a list of events to make fucntions to return in the reversed order
order_events = [asyncio.Event() for _ in range(total)]
Expand Down Expand Up @@ -232,7 +232,7 @@ async def test_messaging_server_error(scheduler_cls) -> None:
total = 200
error_idxs = [False] * 130 + [True] * 70
random.shuffle(error_idxs)
call_results: List[int] = []
call_results: List[int | BaseException] = []
return_results: List[int] = []
# a list of events to make fucntions to return in the reversed order
order_events = [asyncio.Event() for _ in range(total)]
Expand Down

0 comments on commit d0461d0

Please sign in to comment.