Skip to content

Commit

Permalink
fix: bump ruff dep and format files
Browse files Browse the repository at this point in the history
  • Loading branch information
woile committed Oct 9, 2024
1 parent f470dcf commit 2be69a0
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 110 deletions.
3 changes: 1 addition & 2 deletions kstreams/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ def __str__(self) -> str:
return "Engine has not been started. Try with `await engine.start()`"


class BackendNotSet(StreamException):
...
class BackendNotSet(StreamException): ...
6 changes: 2 additions & 4 deletions kstreams/middleware/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ def __init__(
send: types.Send,
stream: "Stream",
**kwargs: typing.Any,
) -> None:
... # pragma: no cover
) -> None: ... # pragma: no cover

async def __call__(self, cr: ConsumerRecord) -> typing.Any:
... # pragma: no cover
async def __call__(self, cr: ConsumerRecord) -> typing.Any: ... # pragma: no cover


class Middleware:
Expand Down
3 changes: 1 addition & 2 deletions kstreams/test_utils/test_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@


class Base:
async def start(self):
...
async def start(self): ...


class TestProducer(Base, Producer):
Expand Down
18 changes: 6 additions & 12 deletions kstreams/test_utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,17 @@
class TestMonitor(PrometheusMonitor):
__test__ = False

async def start(self, *args, **kwargs) -> None:
...
async def start(self, *args, **kwargs) -> None: ...

async def stop(self, *args, **kwargs) -> None:
...
async def stop(self, *args, **kwargs) -> None: ...

def add_topic_partition_offset(self, *args, **kwargs) -> None:
...
def add_topic_partition_offset(self, *args, **kwargs) -> None: ...

def clean_stream_consumer_metrics(self, *args, **kwargs) -> None:
...
def clean_stream_consumer_metrics(self, *args, **kwargs) -> None: ...

def add_producer(self, *args, **kwargs):
...
def add_producer(self, *args, **kwargs): ...

def add_streams(self, *args, **kwargs):
...
def add_streams(self, *args, **kwargs): ...


class TestStreamClient:
Expand Down
3 changes: 1 addition & 2 deletions kstreams/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ def __call__(
headers: typing.Optional[Headers] = None,
serializer: typing.Optional["Serializer"] = None,
serializer_kwargs: typing.Optional[typing.Dict] = None,
) -> typing.Awaitable[RecordMetadata]:
...
) -> typing.Awaitable[RecordMetadata]: ...
39 changes: 20 additions & 19 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 5 additions & 26 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pydantic = ">=2.0.0,<3.0.0"
[tool.poetry.group.dev.dependencies]
pytest = "^8.3.3"
mypy = "^1.11.2"
ruff = "^0.1.9"
ruff = "^0.6.9"
aiorun = "^2024.5.1"
pytest-httpserver = "^1.1.0"
pytest-cov = "^5.0.0"
Expand Down Expand Up @@ -82,30 +82,6 @@ ignore_missing_imports = true
module = "prometheus_client.*"
ignore_missing_imports = true

[tool.ruff]
line-length = 88
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
".venv",
]

[tool.ruff.lint]
select = [
# pycodestyle"
Expand All @@ -116,5 +92,8 @@ select = [
# Pyflakes
"F",
# isort
"I001"
"I",
]

[tool.ruff.lint.isort]
known-first-party = ["kstreams", "tests"]
4 changes: 2 additions & 2 deletions scripts/format
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ fi

set -x

${PREFIX}ruff format .
${PREFIX}ruff kstreams tests --fix
${PREFIX}ruff format kstreams tests examples
${PREFIX}ruff check kstreams tests --fix
3 changes: 2 additions & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ if [ -d '.venv' ] ; then
fi

${PREFIX}pytest -x --cov-report term-missing --cov-report=xml:coverage.xml --cov=kstreams ${1-"./tests"} $2
${PREFIX}ruff kstreams tests
${PREFIX}ruff check kstreams tests
${PREFIX}ruff format --check kstreams tests examples
${PREFIX}mypy kstreams/
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ def subscribe(
) -> None:
self.topics = topics

def unsubscribe(self) -> None:
...
def unsubscribe(self) -> None: ...

def assignment(self):
return self._assigments
Expand Down
12 changes: 4 additions & 8 deletions tests/middleware/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ async def test_middleware_stack_from_stream(
name=stream_name,
middlewares=[middleware.Middleware(dlq_middleware.middleware)],
)
async def consume(cr: ConsumerRecord):
...
async def consume(cr: ConsumerRecord): ...

@stream_engine.stream(
"kstreams-topic-local",
name=stream_name_local,
middlewares=[middleware.Middleware(dlq_middleware.middleware)],
)
async def process(cr: ConsumerRecord, stream: Stream):
...
async def process(cr: ConsumerRecord, stream: Stream): ...

my_stream = stream_engine.get_stream(stream_name)
if my_stream is None:
Expand Down Expand Up @@ -65,8 +63,7 @@ async def test_middleware_stack_order(
middleware.Middleware(elastic_middleware.middleware),
],
)
async def consume(cr: ConsumerRecord):
...
async def consume(cr: ConsumerRecord): ...

my_stream = stream_engine.get_stream(stream_name)
if my_stream is None:
Expand Down Expand Up @@ -184,8 +181,7 @@ async def test_base_middleware_exception(stream_engine: StreamEngine):
name=stream_name,
middlewares=[middleware.Middleware(middleware.BaseMiddleware)],
)
async def stream(cr: ConsumerRecord):
...
async def stream(cr: ConsumerRecord): ...

async with client:
await client.send(topic, value=b"test")
Expand Down
8 changes: 4 additions & 4 deletions tests/test_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ async def test_add_stream_with_rebalance_listener(stream_engine: StreamEngine):
topic = "local--hello-kpn"

class MyRebalanceListener(RebalanceListener):
async def on_partitions_revoked(self, revoked: Set[TopicPartition]) -> None:
...
async def on_partitions_revoked(self, revoked: Set[TopicPartition]) -> None: ...

async def on_partitions_assigned(self, assigned: Set[TopicPartition]) -> None:
...
async def on_partitions_assigned(
self, assigned: Set[TopicPartition]
) -> None: ...

rebalance_listener = MyRebalanceListener()

Expand Down
12 changes: 4 additions & 8 deletions tests/test_engine_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ async def test_hook_on_startup(stream_engine: StreamEngine, consumer_record_fact
assert stream_engine._on_startup == []

@stream_engine.stream("local--kstreams")
async def stream(cr: ConsumerRecord):
...
async def stream(cr: ConsumerRecord): ...

@stream_engine.on_startup
async def init_db():
Expand Down Expand Up @@ -66,8 +65,7 @@ async def test_hook_after_startup(stream_engine: StreamEngine, consumer_record_f
assert stream_engine._after_startup == []

@stream_engine.stream("local--kstreams")
async def stream(cr: ConsumerRecord):
...
async def stream(cr: ConsumerRecord): ...

@stream_engine.after_startup
async def healthy():
Expand Down Expand Up @@ -113,8 +111,7 @@ async def test_hook_on_stop(stream_engine: StreamEngine, consumer_record_factory
assert stream_engine._on_stop == []

@stream_engine.stream("local--kstreams")
async def stream(cr: ConsumerRecord):
...
async def stream(cr: ConsumerRecord): ...

@stream_engine.on_stop
async def close_db():
Expand Down Expand Up @@ -160,8 +157,7 @@ async def test_hook_after_stop(stream_engine: StreamEngine, consumer_record_fact
assert stream_engine._after_stop == []

@stream_engine.stream("local--kstreams")
async def stream(cr: ConsumerRecord):
...
async def stream(cr: ConsumerRecord): ...

@stream_engine.after_stop
async def delete_files():
Expand Down
15 changes: 5 additions & 10 deletions tests/test_stream_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ async def my_stream(_):
async def test_add_stream_as_instance(stream_engine: StreamEngine):
topics = ["local--hello-kpn", "local--hello-kpn-2"]

class MyDeserializer:
...
class MyDeserializer: ...

deserializer = MyDeserializer()

Expand Down Expand Up @@ -74,8 +73,7 @@ async def processor(stream: Stream):
async def test_remove_existing_stream(stream_engine: StreamEngine):
topic = "local--hello-kpn"

class MyDeserializer:
...
class MyDeserializer: ...

deserializer = MyDeserializer()

Expand All @@ -99,8 +97,7 @@ async def processor(stream: Stream):
async def test_remove_missing_stream(stream_engine: StreamEngine):
topic = "local--hello-kpn"

class MyDeserializer:
...
class MyDeserializer: ...

deserializer = MyDeserializer()

Expand All @@ -122,8 +119,7 @@ async def processor(stream: Stream):
async def test_remove_existing_stream_stops_stream(stream_engine: StreamEngine):
topic = "local--hello-kpn"

class MyDeserializer:
...
class MyDeserializer: ...

deserializer = MyDeserializer()

Expand All @@ -148,8 +144,7 @@ async def test_start_stop_stream_engine(stream_engine: StreamEngine):
topic = "local--hello-kpn"

@stream_engine.stream(topic)
async def stream(_):
...
async def stream(_): ...

with mock.patch.multiple(Consumer, start=mock.DEFAULT, stop=mock.DEFAULT):
with mock.patch.multiple(Producer, start=mock.DEFAULT, stop=mock.DEFAULT):
Expand Down
12 changes: 4 additions & 8 deletions tests/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ async def test_stream_multiple_topics(stream_engine: StreamEngine):
):

@stream_engine.stream(topics, name="my-stream")
async def stream(_):
...
async def stream(_): ...

assert stream.topics == topics

Expand All @@ -187,8 +186,7 @@ async def test_stream_subscribe_topics_pattern(stream_engine: StreamEngine):
):

@stream_engine.stream(topics=pattern, subscribe_by_pattern=True)
async def stream(_):
...
async def stream(_): ...

assert stream.topics == [pattern]
assert stream.subscribe_by_pattern
Expand All @@ -214,8 +212,7 @@ async def test_stream_subscribe_topics_only_one_pattern(stream_engine: StreamEng
):

@stream_engine.stream(topics=patterns, subscribe_by_pattern=True)
async def stream(_):
...
async def stream(_): ...

assert stream.topics == patterns
assert stream.subscribe_by_pattern
Expand All @@ -234,8 +231,7 @@ async def test_stream_custom_conf(stream_engine: StreamEngine):
auto_offset_reset="earliest",
enable_auto_commit=False,
)
async def stream(_):
...
async def stream(_): ...

with mock.patch.multiple(
Consumer, start=mock.DEFAULT, stop=mock.DEFAULT
Expand Down

0 comments on commit 2be69a0

Please sign in to comment.