From 307f4fdda8d597c3d7872c0d9d891ba4b9b4dfec Mon Sep 17 00:00:00 2001 From: Timothy Thomas Date: Fri, 16 Feb 2024 12:59:35 -0600 Subject: [PATCH] Run black and fix setup.cfg to add E701 and E704 to flake8 ignore --- faust/__main__.py | 1 + faust/agents/__init__.py | 1 + faust/agents/actor.py | 1 + faust/agents/agent.py | 4 +- faust/agents/manager.py | 1 + faust/agents/models.py | 1 + faust/agents/replies.py | 4 +- faust/app/__init__.py | 1 + faust/app/_attached.py | 4 +- faust/app/base.py | 13 +- faust/app/router.py | 1 + faust/assignor/client_assignment.py | 1 + faust/assignor/cluster_assignment.py | 1 + faust/assignor/copartitioned_assignor.py | 1 + faust/assignor/leader_assignor.py | 1 + faust/assignor/partition_assignor.py | 1 + faust/auth.py | 1 + faust/channels.py | 1 + faust/cli/__init__.py | 1 + faust/cli/agents.py | 1 + faust/cli/base.py | 4 +- faust/cli/clean_versions.py | 1 + faust/cli/completion.py | 1 + faust/cli/livecheck.py | 1 + faust/cli/model.py | 1 + faust/cli/models.py | 1 + faust/cli/params.py | 1 + faust/cli/reset.py | 1 + faust/cli/send.py | 1 + faust/cli/tables.py | 1 + faust/cli/worker.py | 1 + faust/contrib/sentry.py | 3 +- faust/events.py | 4 +- faust/exceptions.py | 4 +- faust/fixups/__init__.py | 1 + faust/fixups/base.py | 1 + faust/fixups/django.py | 7 +- faust/joins.py | 1 + faust/livecheck/__init__.py | 1 + faust/livecheck/app.py | 1 + faust/livecheck/case.py | 7 +- faust/livecheck/locals.py | 4 +- faust/livecheck/models.py | 1 + faust/livecheck/patches/__init__.py | 1 + faust/livecheck/patches/aiohttp.py | 4 +- faust/livecheck/runners.py | 4 +- faust/livecheck/signals.py | 4 +- faust/models/__init__.py | 1 + faust/models/base.py | 1 + faust/models/record.py | 1 + faust/models/tags.py | 21 +- faust/models/typing.py | 7 +- faust/sensors/__init__.py | 1 + faust/sensors/base.py | 4 +- faust/sensors/datadog.py | 4 +- faust/sensors/monitor.py | 1 + faust/sensors/prometheus.py | 1 + faust/sensors/statsd.py | 4 +- faust/serializers/__init__.py | 1 + faust/serializers/codecs.py | 1 + faust/serializers/registry.py | 1 + faust/serializers/schemas.py | 3 +- faust/stores/__init__.py | 1 + faust/stores/aerospike.py | 1 + faust/stores/base.py | 1 + faust/stores/memory.py | 1 + faust/stores/rocksdb.py | 1 + faust/streams.py | 1 + faust/tables/__init__.py | 1 + faust/tables/base.py | 1 + faust/tables/manager.py | 4 +- faust/tables/objects.py | 1 + faust/tables/recovery.py | 7 +- faust/tables/sets.py | 1 + faust/tables/table.py | 1 + faust/tables/wrappers.py | 4 +- faust/topics.py | 4 +- faust/transport/__init__.py | 1 + faust/transport/base.py | 1 + faust/transport/conductor.py | 4 +- faust/transport/consumer.py | 28 +- faust/transport/drivers/__init__.py | 1 + faust/transport/drivers/aiokafka.py | 1 + faust/transport/producer.py | 1 + faust/transport/utils.py | 1 + faust/types/__init__.py | 1 + faust/types/_env.py | 1 + faust/types/agents.py | 108 +++----- faust/types/app.py | 219 +++++---------- faust/types/assignor.py | 36 +-- faust/types/channels.py | 104 +++----- faust/types/codecs.py | 17 +- faust/types/core.py | 3 +- faust/types/events.py | 21 +- faust/types/fixups.py | 15 +- faust/types/joins.py | 6 +- faust/types/models.py | 71 ++--- faust/types/router.py | 28 +- faust/types/sensors.py | 78 ++---- faust/types/serializers.py | 48 ++-- faust/types/settings/base.py | 12 +- faust/types/settings/params.py | 9 +- faust/types/settings/sections.py | 3 +- faust/types/settings/settings.py | 6 +- faust/types/stores.py | 39 +-- faust/types/streams.py | 95 +++---- faust/types/tables.py | 252 ++++++------------ faust/types/topics.py | 30 +-- faust/types/transports.py | 194 +++++--------- faust/types/tuples.py | 6 +- faust/types/web.py | 51 ++-- faust/types/windows.py | 16 +- faust/utils/__init__.py | 1 + faust/utils/_iso8601_python.py | 1 + faust/utils/agent_stopper.py | 1 + faust/utils/codegen.py | 1 + faust/utils/cron.py | 1 + faust/utils/functional.py | 1 + faust/utils/iso8601.py | 1 + faust/utils/json.py | 1 + faust/utils/kafka/protocol/admin.py | 1 + faust/utils/kafka/protocol/api.py | 1 + faust/utils/platforms.py | 1 + faust/utils/terminal/__init__.py | 1 + faust/utils/terminal/spinners.py | 1 + faust/utils/terminal/tables.py | 1 + faust/utils/tracing.py | 1 + faust/utils/urls.py | 1 + faust/utils/venusian.py | 4 +- faust/web/__init__.py | 1 + faust/web/apps/graph.py | 1 + faust/web/apps/production_index.py | 1 + faust/web/apps/router.py | 1 + faust/web/apps/stats.py | 1 + faust/web/apps/tables.py | 1 + faust/web/base.py | 1 + faust/web/blueprints.py | 1 + faust/web/cache/__init__.py | 1 + faust/web/cache/backends/__init__.py | 1 + faust/web/cache/backends/base.py | 10 +- faust/web/cache/backends/memory.py | 1 + faust/web/cache/backends/redis.py | 4 +- faust/web/cache/cache.py | 1 + faust/web/drivers/__init__.py | 1 + faust/web/drivers/aiohttp.py | 1 + faust/web/exceptions.py | 1 + faust/web/views.py | 1 + faust/windows.py | 1 + faust/worker.py | 4 +- setup.cfg | 2 +- tests/conftest.py | 3 +- tests/functional/agents/helpers.py | 3 +- tests/functional/test_app.py | 3 +- tests/functional/test_models.py | 8 +- tests/functional/web/test_cache.py | 3 +- tests/unit/agents/test_agent.py | 12 +- tests/unit/app/test_base.py | 45 ++-- tests/unit/app/test_service.py | 3 +- tests/unit/cli/test_base.py | 6 +- tests/unit/serializers/test_codecs.py | 3 +- tests/unit/stores/test_aerospike.py | 3 +- tests/unit/stores/test_base.py | 36 +-- tests/unit/transport/drivers/test_aiokafka.py | 3 +- tests/unit/transport/test_consumer.py | 66 ++--- tests/unit/web/test_base.py | 30 +-- 165 files changed, 749 insertions(+), 1227 deletions(-) diff --git a/faust/__main__.py b/faust/__main__.py index 6d3aa93b6..f68f971a2 100644 --- a/faust/__main__.py +++ b/faust/__main__.py @@ -1,4 +1,5 @@ """Command-line entry point.""" + # pragma: no cover from faust.cli.faust import cli diff --git a/faust/agents/__init__.py b/faust/agents/__init__.py index ed16385bd..aa720f3b8 100644 --- a/faust/agents/__init__.py +++ b/faust/agents/__init__.py @@ -1,4 +1,5 @@ """Agents.""" + from .agent import Agent, AgentFun, AgentT, SinkT, current_agent from .manager import AgentManager, AgentManagerT from .replies import ReplyConsumer diff --git a/faust/agents/actor.py b/faust/agents/actor.py index c8d743233..34c0f9d70 100644 --- a/faust/agents/actor.py +++ b/faust/agents/actor.py @@ -1,4 +1,5 @@ """Actor - Individual Agent instances.""" + from typing import Any, AsyncGenerator, AsyncIterator, Coroutine, Optional, Set, cast from mode import Service diff --git a/faust/agents/agent.py b/faust/agents/agent.py index 9ebd896af..036b0c46d 100644 --- a/faust/agents/agent.py +++ b/faust/agents/agent.py @@ -1,4 +1,5 @@ """Agent implementation.""" + import asyncio import typing from contextlib import suppress @@ -79,8 +80,7 @@ from faust.app.base import App as _App else: - class _App: - ... # noqa + class _App: ... # noqa __all__ = ["Agent"] diff --git a/faust/agents/manager.py b/faust/agents/manager.py index 8ab0e3618..b1e164383 100644 --- a/faust/agents/manager.py +++ b/faust/agents/manager.py @@ -1,4 +1,5 @@ """Agent manager.""" + import asyncio from collections import defaultdict from typing import Any, Dict, List, Mapping, MutableMapping, MutableSet, Set diff --git a/faust/agents/models.py b/faust/agents/models.py index 4fec41a39..f3ca72930 100644 --- a/faust/agents/models.py +++ b/faust/agents/models.py @@ -1,4 +1,5 @@ """Models used by agents internally.""" + from typing import Any from faust.models import Record diff --git a/faust/agents/replies.py b/faust/agents/replies.py index 69e87c953..b4e4247c8 100644 --- a/faust/agents/replies.py +++ b/faust/agents/replies.py @@ -1,4 +1,5 @@ """Agent replies: waiting for replies, sending them, etc.""" + import asyncio from collections import defaultdict from typing import Any, AsyncIterator, MutableMapping, MutableSet, NamedTuple, Optional @@ -33,8 +34,7 @@ def __init__(self, reply_to: str, correlation_id: str = "", **kwargs: Any) -> No self.__post_init__() super().__init__(**kwargs) - def __post_init__(self) -> None: - ... + def __post_init__(self) -> None: ... def _verify_correlation_id(self, correlation_id: str) -> None: if not correlation_id: diff --git a/faust/app/__init__.py b/faust/app/__init__.py index 1a6fc5109..db178690d 100644 --- a/faust/app/__init__.py +++ b/faust/app/__init__.py @@ -1,4 +1,5 @@ """Application.""" + from .base import App, BootStrategy __all__ = ["App", "BootStrategy"] diff --git a/faust/app/_attached.py b/faust/app/_attached.py index da696727a..2295f6afa 100644 --- a/faust/app/_attached.py +++ b/faust/app/_attached.py @@ -2,6 +2,7 @@ Attachments were used before transactions support. """ + import asyncio import typing from collections import defaultdict @@ -29,8 +30,7 @@ from faust.events import Event as _Event else: - class _Event: - ... # noqa + class _Event: ... # noqa __all__ = ["Attachment", "Attachments"] diff --git a/faust/app/base.py b/faust/app/base.py index bc99f99a7..5205e3968 100644 --- a/faust/app/base.py +++ b/faust/app/base.py @@ -4,6 +4,7 @@ Everything starts here. """ + import asyncio import importlib import inspect @@ -113,17 +114,13 @@ from faust.worker import Worker as _Worker else: - class _AppCommand: - ... # noqa + class _AppCommand: ... # noqa - class _LiveCheck: - ... # noqa + class _LiveCheck: ... # noqa - class _Fetcher: - ... # noqa + class _Fetcher: ... # noqa - class _Worker: - ... # noqa + class _Worker: ... # noqa __all__ = ["App", "BootStrategy"] diff --git a/faust/app/router.py b/faust/app/router.py index 2b5164db6..e15f6efb7 100644 --- a/faust/app/router.py +++ b/faust/app/router.py @@ -1,4 +1,5 @@ """Route messages to Faust nodes by partitioning.""" + from typing import Tuple from yarl import URL diff --git a/faust/assignor/client_assignment.py b/faust/assignor/client_assignment.py index 218ed528f..36069b127 100644 --- a/faust/assignor/client_assignment.py +++ b/faust/assignor/client_assignment.py @@ -1,4 +1,5 @@ """Client Assignment.""" + import copy from typing import List, Mapping, MutableMapping, Sequence, Set, Tuple, cast diff --git a/faust/assignor/cluster_assignment.py b/faust/assignor/cluster_assignment.py index d9ff6b66d..433359746 100644 --- a/faust/assignor/cluster_assignment.py +++ b/faust/assignor/cluster_assignment.py @@ -1,4 +1,5 @@ """Cluster assignment.""" + from typing import List, MutableMapping, Sequence, Set, cast from faust.models import Record diff --git a/faust/assignor/copartitioned_assignor.py b/faust/assignor/copartitioned_assignor.py index a06c8d8f4..093781afd 100644 --- a/faust/assignor/copartitioned_assignor.py +++ b/faust/assignor/copartitioned_assignor.py @@ -1,4 +1,5 @@ """Copartitioned Assignor.""" + from itertools import cycle from math import ceil, floor from typing import Iterable, Iterator, MutableMapping, Optional, Sequence, Set diff --git a/faust/assignor/leader_assignor.py b/faust/assignor/leader_assignor.py index 535667250..9e6ba3366 100644 --- a/faust/assignor/leader_assignor.py +++ b/faust/assignor/leader_assignor.py @@ -1,4 +1,5 @@ """Leader assignor.""" + from typing import Any from mode import Service diff --git a/faust/assignor/partition_assignor.py b/faust/assignor/partition_assignor.py index 705079620..d8988b5c6 100644 --- a/faust/assignor/partition_assignor.py +++ b/faust/assignor/partition_assignor.py @@ -1,4 +1,5 @@ """Partition assignor.""" + import socket import zlib from collections import defaultdict diff --git a/faust/auth.py b/faust/auth.py index 0c97e6a60..57e6919dd 100644 --- a/faust/auth.py +++ b/faust/auth.py @@ -1,4 +1,5 @@ """Authentication Credentials.""" + import ssl from typing import Any, Optional, Union diff --git a/faust/channels.py b/faust/channels.py index a338831b1..4ef013cfe 100644 --- a/faust/channels.py +++ b/faust/channels.py @@ -5,6 +5,7 @@ The stream will iterate over incoming events in the channel. """ + import asyncio from typing import ( Any, diff --git a/faust/cli/__init__.py b/faust/cli/__init__.py index f3ce191b8..71a737ac6 100644 --- a/faust/cli/__init__.py +++ b/faust/cli/__init__.py @@ -1,4 +1,5 @@ """Command-line Interface.""" + from .base import AppCommand, Command, argument, call_command, option __all__ = ["AppCommand", "Command", "argument", "call_command", "option"] diff --git a/faust/cli/agents.py b/faust/cli/agents.py index b5c08503a..cb021e49e 100644 --- a/faust/cli/agents.py +++ b/faust/cli/agents.py @@ -1,4 +1,5 @@ """Program ``faust agents`` used to list agents.""" + from operator import attrgetter from typing import Any, Callable, Optional, Sequence, Type, cast diff --git a/faust/cli/base.py b/faust/cli/base.py index cc5ef4f8b..5715176e8 100644 --- a/faust/cli/base.py +++ b/faust/cli/base.py @@ -1,4 +1,5 @@ """Command-line programs using :pypi:`click`.""" + import abc import asyncio import inspect @@ -49,8 +50,7 @@ from faust.app import App as _App else: - class _App: - ... # noqa + class _App: ... # noqa try: diff --git a/faust/cli/clean_versions.py b/faust/cli/clean_versions.py index 8c1e8d396..785598efb 100644 --- a/faust/cli/clean_versions.py +++ b/faust/cli/clean_versions.py @@ -1,4 +1,5 @@ """Program ``faust reset`` used to delete local table state.""" + from shutil import rmtree from .base import AppCommand diff --git a/faust/cli/completion.py b/faust/cli/completion.py index d9f18b126..afc8ac109 100644 --- a/faust/cli/completion.py +++ b/faust/cli/completion.py @@ -2,6 +2,7 @@ Supports ``bash``, ``ksh``, ``zsh``, etc. """ + import os from pathlib import Path diff --git a/faust/cli/livecheck.py b/faust/cli/livecheck.py index 5bf263754..514b796c1 100644 --- a/faust/cli/livecheck.py +++ b/faust/cli/livecheck.py @@ -1,4 +1,5 @@ """Program ``faust worker`` used to start application from console.""" + from typing import Any from .worker import worker diff --git a/faust/cli/model.py b/faust/cli/model.py index 67a1ecd9c..8000d68b3 100644 --- a/faust/cli/model.py +++ b/faust/cli/model.py @@ -1,4 +1,5 @@ """Program ``faust model`` used to list details about a model.""" + from datetime import datetime from typing import Any, Optional, Sequence, Type diff --git a/faust/cli/models.py b/faust/cli/models.py index 03b94cc63..6aa8c2b02 100644 --- a/faust/cli/models.py +++ b/faust/cli/models.py @@ -1,4 +1,5 @@ """Program ``faust models`` used to list models available.""" + from operator import attrgetter from typing import Any, Callable, Sequence, Type, cast diff --git a/faust/cli/params.py b/faust/cli/params.py index ed67cf058..ec62d5f23 100644 --- a/faust/cli/params.py +++ b/faust/cli/params.py @@ -1,4 +1,5 @@ """Python :pypi:`click` parameter types.""" + from typing import Any, Iterable, Optional import click diff --git a/faust/cli/reset.py b/faust/cli/reset.py index 76fa72ad5..d0ffe78e2 100644 --- a/faust/cli/reset.py +++ b/faust/cli/reset.py @@ -1,4 +1,5 @@ """Program ``faust reset`` used to delete local table state.""" + from .base import AppCommand __all__ = ["reset"] diff --git a/faust/cli/send.py b/faust/cli/send.py index cc996f589..ab1f4eacd 100644 --- a/faust/cli/send.py +++ b/faust/cli/send.py @@ -1,4 +1,5 @@ """Program ``faust send`` used to send events to agents and topics.""" + import asyncio import random from typing import Any, Optional diff --git a/faust/cli/tables.py b/faust/cli/tables.py index 1b7c558f2..6801180d8 100644 --- a/faust/cli/tables.py +++ b/faust/cli/tables.py @@ -1,4 +1,5 @@ """Program ``faust tables`` used to list tables.""" + from .base import AppCommand DEFAULT_TABLE_HELP = 'Missing description: use Table(.., help="str")' diff --git a/faust/cli/worker.py b/faust/cli/worker.py index ae22b6980..9c6ad1e96 100644 --- a/faust/cli/worker.py +++ b/faust/cli/worker.py @@ -1,4 +1,5 @@ """Program ``faust worker`` used to start application from console.""" + import asyncio import os import platform diff --git a/faust/contrib/sentry.py b/faust/contrib/sentry.py index 04d260329..6a527ac29 100644 --- a/faust/contrib/sentry.py +++ b/faust/contrib/sentry.py @@ -31,8 +31,7 @@ from raven.handlers.logging import SentryHandler as _SentryHandler else: - class _SentryHandler: - ... # noqa: E701 + class _SentryHandler: ... # noqa: E701 __all__ = ["handler_from_dsn", "setup"] diff --git a/faust/events.py b/faust/events.py index 3e218a16c..e45dd4fe1 100644 --- a/faust/events.py +++ b/faust/events.py @@ -1,4 +1,5 @@ """Events received in streams.""" + import typing from types import TracebackType from typing import Any, Awaitable, Optional, Type, Union, cast @@ -21,8 +22,7 @@ from .app.base import App as _App else: - class _App: - ... # noqa + class _App: ... # noqa USE_EXISTING_KEY = object() diff --git a/faust/exceptions.py b/faust/exceptions.py index b2ea924a0..dfe4a5e48 100644 --- a/faust/exceptions.py +++ b/faust/exceptions.py @@ -1,4 +1,5 @@ """Faust exceptions.""" + import typing __all__ = [ @@ -25,8 +26,7 @@ from .types.models import FieldDescriptorT as _FieldDescriptorT else: - class _FieldDescriptorT: - ... # noqa + class _FieldDescriptorT: ... # noqa class FaustError(Exception): diff --git a/faust/fixups/__init__.py b/faust/fixups/__init__.py index f6466d7b1..2887f93b1 100644 --- a/faust/fixups/__init__.py +++ b/faust/fixups/__init__.py @@ -1,4 +1,5 @@ """Transport registry.""" + from typing import Iterator, Type from mode.utils.imports import FactoryMapping diff --git a/faust/fixups/base.py b/faust/fixups/base.py index e0a8fe8f6..6be82f2d7 100644 --- a/faust/fixups/base.py +++ b/faust/fixups/base.py @@ -1,4 +1,5 @@ """Fixups - Base implementation.""" + from typing import Iterable from faust.types import AppT, FixupT diff --git a/faust/fixups/django.py b/faust/fixups/django.py index 804d9018a..dddc69bf3 100644 --- a/faust/fixups/django.py +++ b/faust/fixups/django.py @@ -1,4 +1,5 @@ """Django Fixups - Integration with Django.""" + import os import typing import warnings @@ -14,11 +15,9 @@ from django.settings import Settings as _Settings else: - class _Apps: - ... # noqa + class _Apps: ... # noqa - class _Settings: - ... # noqa + class _Settings: ... # noqa __all__ = ["Fixup"] diff --git a/faust/joins.py b/faust/joins.py index 761b411cc..8767df13e 100644 --- a/faust/joins.py +++ b/faust/joins.py @@ -1,4 +1,5 @@ """Join strategies.""" + from typing import Any, Optional, Tuple from .types import EventT, FieldDescriptorT, JoinableT, JoinT diff --git a/faust/livecheck/__init__.py b/faust/livecheck/__init__.py index 661457a80..847423a11 100644 --- a/faust/livecheck/__init__.py +++ b/faust/livecheck/__init__.py @@ -1,4 +1,5 @@ """LiveCheck - End-to-end testing of asynchronous systems.""" + from .app import LiveCheck from .case import Case from .locals import current_test diff --git a/faust/livecheck/app.py b/faust/livecheck/app.py index 35126a0ad..b2fab3ae8 100644 --- a/faust/livecheck/app.py +++ b/faust/livecheck/app.py @@ -1,4 +1,5 @@ """LiveCheck - Faust Application.""" + import asyncio from datetime import timedelta from typing import ( diff --git a/faust/livecheck/case.py b/faust/livecheck/case.py index 38061a729..5c8cc4d68 100644 --- a/faust/livecheck/case.py +++ b/faust/livecheck/case.py @@ -1,4 +1,5 @@ """LiveCheck - Test cases.""" + import traceback import typing from collections import deque @@ -29,8 +30,7 @@ from .app import LiveCheck as _LiveCheck else: - class _LiveCheck: - ... # noqa + class _LiveCheck: ... # noqa __all__ = ["Case"] @@ -318,8 +318,7 @@ async def _send_frequency(self) -> None: if self.app.is_leader(): await self.make_fake_request() - async def make_fake_request(self) -> None: - ... + async def make_fake_request(self) -> None: ... @Service.task async def _check_frequency(self) -> None: diff --git a/faust/livecheck/locals.py b/faust/livecheck/locals.py index 8a940d732..a7e53e727 100644 --- a/faust/livecheck/locals.py +++ b/faust/livecheck/locals.py @@ -1,4 +1,5 @@ """Locals - Current test & execution context.""" + import typing from typing import Optional @@ -10,8 +11,7 @@ from .runners import TestRunner as _TestRunner else: # pragma: no cover - class _TestRunner: - ... # noqa + class _TestRunner: ... # noqa __all__ = [ diff --git a/faust/livecheck/models.py b/faust/livecheck/models.py index f2ce41f68..a49c1299a 100644 --- a/faust/livecheck/models.py +++ b/faust/livecheck/models.py @@ -1,4 +1,5 @@ """LiveCheck - Models.""" + from datetime import datetime, timezone from enum import Enum from typing import Any, Dict, List, Mapping, Optional diff --git a/faust/livecheck/patches/__init__.py b/faust/livecheck/patches/__init__.py index ecbc6e1af..3ee96a513 100644 --- a/faust/livecheck/patches/__init__.py +++ b/faust/livecheck/patches/__init__.py @@ -1,4 +1,5 @@ """Patches - LiveCheck integration with other frameworks/libraries.""" + from . import aiohttp __all__ = ["aiohttp", "patch_all"] diff --git a/faust/livecheck/patches/aiohttp.py b/faust/livecheck/patches/aiohttp.py index 023248436..29aa3b39f 100644 --- a/faust/livecheck/patches/aiohttp.py +++ b/faust/livecheck/patches/aiohttp.py @@ -1,4 +1,5 @@ """LiveCheck :pypi:`aiohttp` integration.""" + from contextlib import ExitStack from types import SimpleNamespace from typing import Any, List, Optional, no_type_check @@ -26,8 +27,7 @@ def patch_aiohttp_session() -> None: from aiohttp import TraceConfig, client # monkeypatch to remove ridiculous "do not subclass" warning. - def __init_subclass__() -> None: - ... + def __init_subclass__() -> None: ... client.ClientSession.__init_subclass__ = __init_subclass__ # type: ignore diff --git a/faust/livecheck/runners.py b/faust/livecheck/runners.py index 6a9306395..a1d26fb1d 100644 --- a/faust/livecheck/runners.py +++ b/faust/livecheck/runners.py @@ -1,4 +1,5 @@ """LiveCheck - Test runner.""" + import asyncio import logging import traceback @@ -27,8 +28,7 @@ from .case import Case as _Case else: - class _Case: - ... # noqa + class _Case: ... # noqa __all__ = ["TestRunner"] diff --git a/faust/livecheck/signals.py b/faust/livecheck/signals.py index d7aa9b974..020767da0 100644 --- a/faust/livecheck/signals.py +++ b/faust/livecheck/signals.py @@ -1,4 +1,5 @@ """LiveCheck Signals - Test communication and synchronization.""" + import asyncio import typing from time import monotonic @@ -16,8 +17,7 @@ from .case import Case as _Case else: - class _Case: - ... # noqa + class _Case: ... # noqa __all__ = ["BaseSignal", "Signal"] diff --git a/faust/models/__init__.py b/faust/models/__init__.py index 2534d5279..1c14af735 100644 --- a/faust/models/__init__.py +++ b/faust/models/__init__.py @@ -1,4 +1,5 @@ """Models.""" + from .base import Model, ModelOptions, maybe_model, registry from .fields import FieldDescriptor, StringField from .record import Record diff --git a/faust/models/base.py b/faust/models/base.py index 6193f115c..6b7c552a6 100644 --- a/faust/models/base.py +++ b/faust/models/base.py @@ -27,6 +27,7 @@ Models are mainly used for describing the data in messages: both keys and values can be described as models. """ + import abc import warnings from datetime import datetime diff --git a/faust/models/record.py b/faust/models/record.py index 1d8fd3a54..dbfd65a5e 100644 --- a/faust/models/record.py +++ b/faust/models/record.py @@ -1,4 +1,5 @@ """Record - Dictionary Model.""" + from datetime import datetime from decimal import Decimal from itertools import chain diff --git a/faust/models/tags.py b/faust/models/tags.py index ed0a3cc7c..528287f68 100644 --- a/faust/models/tags.py +++ b/faust/models/tags.py @@ -47,12 +47,10 @@ def __repr__(self) -> str: return f"<{self._name}: {self.field}@{id(self):#x}>" @abc.abstractmethod - def __str__(self) -> str: - ... + def __str__(self) -> str: ... @abc.abstractmethod - def __format__(self, format_spec: str) -> str: - ... + def __format__(self, format_spec: str) -> str: ... @property def _name(self) -> str: @@ -190,21 +188,16 @@ def __class_getitem__(self, params: Any) -> Any: return sup(params) -class _PIIstr(str): - ... +class _PIIstr(str): ... -class _PIIbytes(bytes): - ... +class _PIIbytes(bytes): ... -class _PIIint(int): - ... +class _PIIint(int): ... -class _PIIfloat(float): - ... +class _PIIfloat(float): ... -class _PIIDecimal(Decimal): - ... +class _PIIDecimal(Decimal): ... diff --git a/faust/models/typing.py b/faust/models/typing.py index 4c44deb75..dc9ff0d88 100644 --- a/faust/models/typing.py +++ b/faust/models/typing.py @@ -6,6 +6,7 @@ to deserialize such a structure. """ + import abc import os import random @@ -280,8 +281,7 @@ def random_identifier(self, n: int = 8) -> str: ) @abc.abstractmethod - def build(self, var: Variable, *args: Type) -> str: - ... + def build(self, var: Variable, *args: Type) -> str: ... def __repr__(self) -> str: return f"<{type(self).__name__}: {self.expr!r}>" @@ -604,8 +604,7 @@ class RootNode(Node): found_types: Dict[NodeType, Set[Type]] @classmethod - def _register(cls) -> None: - ... # we do not register root nodes. + def _register(cls) -> None: ... # we do not register root nodes. def add_closure(self, local_name: str, global_name: str, obj: Any) -> None: self.globals[global_name] = obj diff --git a/faust/sensors/__init__.py b/faust/sensors/__init__.py index 6a48926b7..6c7dc41cd 100644 --- a/faust/sensors/__init__.py +++ b/faust/sensors/__init__.py @@ -1,4 +1,5 @@ """Sensors.""" + from .base import Sensor, SensorDelegate from .monitor import Monitor, TableState diff --git a/faust/sensors/base.py b/faust/sensors/base.py index f81fac758..46f679e67 100644 --- a/faust/sensors/base.py +++ b/faust/sensors/base.py @@ -1,4 +1,5 @@ """Base-interface for sensors.""" + from time import monotonic from typing import Any, Dict, Iterator, Mapping, Optional, Set @@ -143,8 +144,7 @@ def on_web_request_end( """Web server finished working on request.""" ... - def on_threaded_producer_buffer_processed(self, app: AppT, size: int) -> None: - ... + def on_threaded_producer_buffer_processed(self, app: AppT, size: int) -> None: ... def asdict(self) -> Mapping: """Convert sensor state to dictionary.""" diff --git a/faust/sensors/datadog.py b/faust/sensors/datadog.py index 3c79174c4..5db905957 100644 --- a/faust/sensors/datadog.py +++ b/faust/sensors/datadog.py @@ -1,4 +1,5 @@ """Monitor using datadog.""" + import re from typing import Any, Dict, List, Optional, cast @@ -26,8 +27,7 @@ except ImportError: # pragma: no cover datadog = None # type: ignore - class DogStatsD: - ... # noqa + class DogStatsD: ... # noqa __all__ = ["DatadogMonitor"] diff --git a/faust/sensors/monitor.py b/faust/sensors/monitor.py index efacca358..44d7da1e1 100644 --- a/faust/sensors/monitor.py +++ b/faust/sensors/monitor.py @@ -1,4 +1,5 @@ """Monitor - sensor tracking metrics.""" + import asyncio import re import weakref diff --git a/faust/sensors/prometheus.py b/faust/sensors/prometheus.py index dca750752..022dea146 100644 --- a/faust/sensors/prometheus.py +++ b/faust/sensors/prometheus.py @@ -1,4 +1,5 @@ """Monitor using Prometheus.""" + import typing from typing import Any, NamedTuple, Optional, cast diff --git a/faust/sensors/statsd.py b/faust/sensors/statsd.py index 26b24fc9a..a9ec1d055 100644 --- a/faust/sensors/statsd.py +++ b/faust/sensors/statsd.py @@ -1,4 +1,5 @@ """Monitor using Statsd.""" + import typing from typing import Any, Dict, Optional, cast @@ -30,8 +31,7 @@ from statsd import StatsClient else: - class StatsClient: - ... # noqa + class StatsClient: ... # noqa __all__ = ["StatsdMonitor"] diff --git a/faust/serializers/__init__.py b/faust/serializers/__init__.py index 1c9b5e327..6720ef950 100644 --- a/faust/serializers/__init__.py +++ b/faust/serializers/__init__.py @@ -1,4 +1,5 @@ """Serializers and Codecs.""" + from .codecs import Codec from .registry import Registry from .schemas import Schema diff --git a/faust/serializers/codecs.py b/faust/serializers/codecs.py index e642f3be4..1d0a15570 100644 --- a/faust/serializers/codecs.py +++ b/faust/serializers/codecs.py @@ -159,6 +159,7 @@ def msgpack() -> codecs.Codec: At this point may want to publish this on PyPI to share the extension with other Faust users. """ + import pickle as _pickle # nosec B403 from base64 import b64decode, b64encode from types import ModuleType diff --git a/faust/serializers/registry.py b/faust/serializers/registry.py index be56984e8..5f2f46e43 100644 --- a/faust/serializers/registry.py +++ b/faust/serializers/registry.py @@ -1,4 +1,5 @@ """Registry of supported codecs (serializers, compressors, etc.).""" + import sys from decimal import Decimal from typing import Any, Optional, Tuple, Type, cast diff --git a/faust/serializers/schemas.py b/faust/serializers/schemas.py index 8192cd2b1..aad969e2f 100644 --- a/faust/serializers/schemas.py +++ b/faust/serializers/schemas.py @@ -27,8 +27,7 @@ OnValueDecodeErrorFun = Callable[[Exception, Message], Awaitable[None]] -async def _noop_decode_error(exc: Exception, message: Message) -> None: - ... +async def _noop_decode_error(exc: Exception, message: Message) -> None: ... class Schema(SchemaT): diff --git a/faust/stores/__init__.py b/faust/stores/__init__.py index 3f536427b..56cc0dc61 100644 --- a/faust/stores/__init__.py +++ b/faust/stores/__init__.py @@ -1,4 +1,5 @@ """Storage registry.""" + from typing import Type from mode.utils.imports import FactoryMapping diff --git a/faust/stores/aerospike.py b/faust/stores/aerospike.py index e713b4068..291ccbe9f 100644 --- a/faust/stores/aerospike.py +++ b/faust/stores/aerospike.py @@ -1,4 +1,5 @@ """Aerospike storage.""" + import time import typing from typing import Any, Dict, Iterator, Optional, Tuple, Union diff --git a/faust/stores/base.py b/faust/stores/base.py index 62b55fda1..011259825 100644 --- a/faust/stores/base.py +++ b/faust/stores/base.py @@ -1,4 +1,5 @@ """Base class for table storage drivers.""" + import abc from collections.abc import ItemsView, KeysView, ValuesView from typing import ( diff --git a/faust/stores/memory.py b/faust/stores/memory.py index 484517628..3966ded60 100644 --- a/faust/stores/memory.py +++ b/faust/stores/memory.py @@ -1,4 +1,5 @@ """In-memory table storage.""" + from typing import Any, Callable, Iterable, MutableMapping, Optional, Set, Tuple, Union from faust.types import TP, EventT diff --git a/faust/stores/rocksdb.py b/faust/stores/rocksdb.py index d614b32c4..d17ba750e 100644 --- a/faust/stores/rocksdb.py +++ b/faust/stores/rocksdb.py @@ -1,4 +1,5 @@ """RocksDB storage.""" + import asyncio import gc import math diff --git a/faust/streams.py b/faust/streams.py index f23d874ad..d2faf482a 100644 --- a/faust/streams.py +++ b/faust/streams.py @@ -1,4 +1,5 @@ """Streams.""" + import asyncio import os import reprlib diff --git a/faust/tables/__init__.py b/faust/tables/__init__.py index d86876531..3e7486ec0 100644 --- a/faust/tables/__init__.py +++ b/faust/tables/__init__.py @@ -1,4 +1,5 @@ """Tables: Distributed object K/V-store.""" + from .base import Collection, CollectionT from .globaltable import GlobalTable, GlobalTableT from .manager import TableManager, TableManagerT diff --git a/faust/tables/base.py b/faust/tables/base.py index 7f90672fa..e3574ee21 100644 --- a/faust/tables/base.py +++ b/faust/tables/base.py @@ -1,4 +1,5 @@ """Base class Collection for Table and future data structures.""" + import abc import time from collections import defaultdict diff --git a/faust/tables/manager.py b/faust/tables/manager.py index c26622319..9b4952555 100644 --- a/faust/tables/manager.py +++ b/faust/tables/manager.py @@ -1,4 +1,5 @@ """Tables (changelog stream).""" + import asyncio import typing from typing import Any, MutableMapping, Optional, Set, Tuple, cast @@ -16,8 +17,7 @@ from faust.app import App as _App else: - class _App: - ... # noqa + class _App: ... # noqa __all__ = [ diff --git a/faust/tables/objects.py b/faust/tables/objects.py index 3fb7d92a2..a9c0de12d 100644 --- a/faust/tables/objects.py +++ b/faust/tables/objects.py @@ -3,6 +3,7 @@ This is also used to store data structures such as sets/lists. """ + import abc from typing import ( Any, diff --git a/faust/tables/recovery.py b/faust/tables/recovery.py index 51ec3cb9c..41bb20c18 100644 --- a/faust/tables/recovery.py +++ b/faust/tables/recovery.py @@ -1,4 +1,5 @@ """Table recovery after rebalancing.""" + import asyncio import statistics import typing @@ -39,11 +40,9 @@ from .manager import TableManager as _TableManager else: - class _App: - ... # noqa + class _App: ... # noqa - class _TableManager: - ... # noqa + class _TableManager: ... # noqa E_PERSISTED_OFFSET = """\ diff --git a/faust/tables/sets.py b/faust/tables/sets.py index 8da417a62..7876b5da8 100644 --- a/faust/tables/sets.py +++ b/faust/tables/sets.py @@ -1,4 +1,5 @@ """Storing sets in tables.""" + from enum import Enum from typing import ( Any, diff --git a/faust/tables/table.py b/faust/tables/table.py index a38d32859..a9d2f48f5 100644 --- a/faust/tables/table.py +++ b/faust/tables/table.py @@ -1,4 +1,5 @@ """Table (key/value changelog stream).""" + from typing import Any, ClassVar, Optional, Type from mode import Seconds diff --git a/faust/tables/wrappers.py b/faust/tables/wrappers.py index 5d400d3bd..0650c59e6 100644 --- a/faust/tables/wrappers.py +++ b/faust/tables/wrappers.py @@ -1,4 +1,5 @@ """Wrappers for windowed tables.""" + import operator import typing from datetime import datetime @@ -40,8 +41,7 @@ from .table import Table as _Table else: - class _Table: - ... # noqa + class _Table: ... # noqa __all__ = [ diff --git a/faust/topics.py b/faust/topics.py index 90b5e1bd6..b09a8d22d 100644 --- a/faust/topics.py +++ b/faust/topics.py @@ -1,4 +1,5 @@ """Topic - Named channel using Kafka.""" + import asyncio import re import typing @@ -46,8 +47,7 @@ from .app import App as _App else: - class _App: - ... # noqa + class _App: ... # noqa __all__ = ["Topic"] diff --git a/faust/transport/__init__.py b/faust/transport/__init__.py index 7346eb0cd..2d862c19c 100644 --- a/faust/transport/__init__.py +++ b/faust/transport/__init__.py @@ -1,4 +1,5 @@ """Transports.""" + from .drivers import by_name, by_url __all__ = ["by_name", "by_url"] diff --git a/faust/transport/base.py b/faust/transport/base.py index ac70afb3e..b3e478379 100644 --- a/faust/transport/base.py +++ b/faust/transport/base.py @@ -8,6 +8,7 @@ To see a reference transport implementation go to: :file:`faust/transport/drivers/aiokafka.py` """ + import asyncio from typing import Any, ClassVar, List, Optional, Type diff --git a/faust/transport/conductor.py b/faust/transport/conductor.py index ff7d3d99f..0bda03b02 100644 --- a/faust/transport/conductor.py +++ b/faust/transport/conductor.py @@ -1,4 +1,5 @@ """The conductor delegates messages from the consumer to the streams.""" + import asyncio import os import typing @@ -30,8 +31,7 @@ from faust.topics import Topic as _Topic else: - class _Topic: - ... # noqa + class _Topic: ... # noqa NO_CYTHON = bool(os.environ.get("NO_CYTHON", False)) diff --git a/faust/transport/consumer.py b/faust/transport/consumer.py index 0feba69c0..d5a82b1b8 100644 --- a/faust/transport/consumer.py +++ b/faust/transport/consumer.py @@ -43,6 +43,7 @@ _new_offset). """ + import abc import asyncio import gc @@ -101,8 +102,7 @@ from faust.app import App as _App else: - class _App: - ... # noqa: E701 + class _App: ... # noqa: E701 __all__ = ["Consumer", "Fetcher"] @@ -580,8 +580,7 @@ async def seek(self, partition: TP, offset: int) -> None: self._read_offset[ensure_TP(partition)] = offset if offset else None @abc.abstractmethod - async def _seek(self, partition: TP, offset: int) -> None: - ... + async def _seek(self, partition: TP, offset: int) -> None: ... def stop_flow(self) -> None: """Block consumer from processing any more messages.""" @@ -676,8 +675,7 @@ async def on_partitions_assigned( @abc.abstractmethod async def _getmany( self, active_partitions: Optional[Set[TP]], timeout: float - ) -> RecordMap: - ... + ) -> RecordMap: ... async def getmany(self, timeout: float) -> AsyncIterator[Tuple[TP, Message]]: """Fetch batch of messages from server.""" @@ -797,8 +795,7 @@ async def _wait_next_records( self.not_waiting_next_records.set() @abc.abstractmethod - def _to_message(self, tp: TP, record: Any) -> ConsumerMessage: - ... + def _to_message(self, tp: TP, record: Any) -> ConsumerMessage: ... def track_message(self, message: Message) -> None: """Track message and mark it as pending ack.""" @@ -908,11 +905,9 @@ async def verify_all_partitions_active(self) -> None: if not self.should_stop: self.verify_event_path(now, tp) - def verify_event_path(self, now: float, tp: TP) -> None: - ... + def verify_event_path(self, now: float, tp: TP) -> None: ... - def verify_recovery_event_path(self, now: float, tp: TP) -> None: - ... + def verify_recovery_event_path(self, now: float, tp: TP) -> None: ... async def commit( self, topics: TPorTopicSet = None, start_new_transaction: bool = True @@ -1302,8 +1297,7 @@ def topic_partitions(self, topic: str) -> Optional[int]: ... @abc.abstractmethod - def close(self) -> None: - ... + def close(self) -> None: ... @abc.abstractmethod async def earliest_offsets(self, *partitions: TP) -> Mapping[TP, int]: @@ -1358,8 +1352,7 @@ def key_partition( """Hash key to determine partition number.""" ... - def verify_recovery_event_path(self, now: float, tp: TP) -> None: - ... + def verify_recovery_event_path(self, now: float, tp: TP) -> None: ... class ThreadDelegateConsumer(Consumer): @@ -1381,8 +1374,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.add_dependency(self._thread) @abc.abstractmethod - def _new_consumer_thread(self) -> ConsumerThread: - ... + def _new_consumer_thread(self) -> ConsumerThread: ... async def threadsafe_partitions_revoked( self, receiver_loop: asyncio.AbstractEventLoop, revoked: Set[TP] diff --git a/faust/transport/drivers/__init__.py b/faust/transport/drivers/__init__.py index 203a8907c..8deec0196 100644 --- a/faust/transport/drivers/__init__.py +++ b/faust/transport/drivers/__init__.py @@ -1,4 +1,5 @@ """Transport registry.""" + from yarl import URL from .aiokafka import Transport as AIOKafkaTransport diff --git a/faust/transport/drivers/aiokafka.py b/faust/transport/drivers/aiokafka.py index 2bfc84078..f69c532db 100644 --- a/faust/transport/drivers/aiokafka.py +++ b/faust/transport/drivers/aiokafka.py @@ -1,4 +1,5 @@ """Message transport using :pypi:`aiokafka`.""" + import asyncio import typing from asyncio import Lock, QueueEmpty diff --git a/faust/transport/producer.py b/faust/transport/producer.py index e36803a52..d70eb0aa6 100644 --- a/faust/transport/producer.py +++ b/faust/transport/producer.py @@ -6,6 +6,7 @@ - ... and the app via ``self.transport.app``. - Sending messages. """ + import asyncio import time from typing import Any, Awaitable, Mapping, Optional, cast diff --git a/faust/transport/utils.py b/faust/transport/utils.py index d09bf9c24..0b0c7b213 100644 --- a/faust/transport/utils.py +++ b/faust/transport/utils.py @@ -1,4 +1,5 @@ """Transport utils - scheduling.""" + from typing import ( Any, Dict, diff --git a/faust/types/__init__.py b/faust/types/__init__.py index 3727f36d6..d705b1aa2 100644 --- a/faust/types/__init__.py +++ b/faust/types/__init__.py @@ -1,4 +1,5 @@ """Abstract types for static typing.""" + from mode import ServiceT from .agents import AgentManagerT, AgentT diff --git a/faust/types/_env.py b/faust/types/_env.py index edabffd85..0f9e10dfc 100644 --- a/faust/types/_env.py +++ b/faust/types/_env.py @@ -1,4 +1,5 @@ """Faust environment variables.""" + import os from typing import Any, Sequence diff --git a/faust/types/agents.py b/faust/types/agents.py index 4c533c9e7..70491c20f 100644 --- a/faust/types/agents.py +++ b/faust/types/agents.py @@ -38,8 +38,7 @@ from .app import AppT as _AppT else: - class _AppT: - ... # noqa + class _AppT: ... # noqa __all__ = [ @@ -89,24 +88,19 @@ def __init__( it: _T, active_partitions: Optional[Set[TP]] = None, **kwargs: Any, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def cancel(self) -> None: - ... + def cancel(self) -> None: ... @abc.abstractmethod - async def on_isolated_partition_revoked(self, tp: TP) -> None: - ... + async def on_isolated_partition_revoked(self, tp: TP) -> None: ... @abc.abstractmethod - async def on_isolated_partition_assigned(self, tp: TP) -> None: - ... + async def on_isolated_partition_assigned(self, tp: TP) -> None: ... @abc.abstractmethod - def traceback(self) -> str: - ... + def traceback(self) -> str: ... class AsyncIterableActorT(ActorT[AsyncIterable], AsyncIterable): @@ -150,8 +144,7 @@ def __init__( self.fun: AgentFun = fun @abc.abstractmethod - def actor_tracebacks(self) -> List[str]: - ... + def actor_tracebacks(self) -> List[str]: ... @abc.abstractmethod def __call__( @@ -161,8 +154,7 @@ def __call__( active_partitions: Optional[Set[TP]] = None, stream: Optional[StreamT] = None, channel: Optional[ChannelT] = None, - ) -> ActorRefT: - ... + ) -> ActorRefT: ... @abc.abstractmethod def test_context( @@ -170,24 +162,19 @@ def test_context( channel: Optional[ChannelT] = None, supervisor_strategy: SupervisorStrategyT = None, **kwargs: Any, - ) -> "AgentTestWrapperT": - ... + ) -> "AgentTestWrapperT": ... @abc.abstractmethod - def add_sink(self, sink: SinkT) -> None: - ... + def add_sink(self, sink: SinkT) -> None: ... @abc.abstractmethod - def stream(self, **kwargs: Any) -> StreamT: - ... + def stream(self, **kwargs: Any) -> StreamT: ... @abc.abstractmethod - async def on_partitions_assigned(self, assigned: Set[TP]) -> None: - ... + async def on_partitions_assigned(self, assigned: Set[TP]) -> None: ... @abc.abstractmethod - async def on_partitions_revoked(self, revoked: Set[TP]) -> None: - ... + async def on_partitions_revoked(self, revoked: Set[TP]) -> None: ... @abc.abstractmethod async def cast( @@ -198,8 +185,7 @@ async def cast( partition: Optional[int] = None, timestamp: Optional[float] = None, headers: HeadersArg = None, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod async def ask( @@ -212,8 +198,7 @@ async def ask( headers: HeadersArg = None, reply_to: ReplyToArg = None, correlation_id: Optional[str] = None, - ) -> Any: - ... + ) -> Any: ... @abc.abstractmethod async def send( @@ -228,8 +213,7 @@ async def send( value_serializer: CodecArg = None, reply_to: ReplyToArg = None, correlation_id: Optional[str] = None, - ) -> Awaitable[RecordMetadata]: - ... + ) -> Awaitable[RecordMetadata]: ... @abc.abstractmethod @no_type_check # XXX mypy bugs out on this @@ -238,8 +222,7 @@ async def map( values: Union[AsyncIterable, Iterable], key: K = None, reply_to: ReplyToArg = None, - ) -> AsyncIterator: - ... + ) -> AsyncIterator: ... @abc.abstractmethod @no_type_check # XXX mypy bugs out on this @@ -247,8 +230,7 @@ async def kvmap( self, items: Union[AsyncIterable[Tuple[K, V]], Iterable[Tuple[K, V]]], reply_to: ReplyToArg = None, - ) -> AsyncIterator[str]: - ... + ) -> AsyncIterator[str]: ... @abc.abstractmethod async def join( @@ -256,70 +238,56 @@ async def join( values: Union[AsyncIterable[V], Iterable[V]], key: K = None, reply_to: ReplyToArg = None, - ) -> List[Any]: - ... + ) -> List[Any]: ... @abc.abstractmethod async def kvjoin( self, items: Union[AsyncIterable[Tuple[K, V]], Iterable[Tuple[K, V]]], reply_to: ReplyToArg = None, - ) -> List[Any]: - ... + ) -> List[Any]: ... @abc.abstractmethod - def info(self) -> Mapping: - ... + def info(self) -> Mapping: ... @abc.abstractmethod - def clone(self, *, cls: Type["AgentT"] = None, **kwargs: Any) -> "AgentT": - ... + def clone(self, *, cls: Type["AgentT"] = None, **kwargs: Any) -> "AgentT": ... @abc.abstractmethod - def get_topic_names(self) -> Iterable[str]: - ... + def get_topic_names(self) -> Iterable[str]: ... @property @abc.abstractmethod - def channel(self) -> ChannelT: - ... + def channel(self) -> ChannelT: ... @channel.setter - def channel(self, channel: ChannelT) -> None: - ... + def channel(self, channel: ChannelT) -> None: ... @property @abc.abstractmethod - def channel_iterator(self) -> AsyncIterator: - ... + def channel_iterator(self) -> AsyncIterator: ... @channel_iterator.setter - def channel_iterator(self, channel: AsyncIterator) -> None: - ... + def channel_iterator(self, channel: AsyncIterator) -> None: ... @abc.abstractmethod - def _agent_label(self, name_suffix: str = "") -> str: - ... + def _agent_label(self, name_suffix: str = "") -> str: ... class AgentManagerT(ServiceT, ManagedUserDict[str, AgentT]): app: _AppT @abc.abstractmethod - async def wait_until_agents_started(self) -> None: - ... + async def wait_until_agents_started(self) -> None: ... @abc.abstractmethod - async def on_rebalance(self, revoked: Set[TP], newly_assigned: Set[TP]) -> None: - ... + async def on_rebalance(self, revoked: Set[TP], newly_assigned: Set[TP]) -> None: ... @abc.abstractmethod - def actor_tracebacks(self) -> Mapping[str, List[str]]: - ... + def actor_tracebacks(self) -> Mapping[str, List[str]]: ... @abc.abstractmethod - def human_tracebacks(self) -> str: - ... + def human_tracebacks(self) -> str: ... class AgentTestWrapperT(AgentT, AsyncIterable): @@ -332,8 +300,7 @@ class AgentTestWrapperT(AgentT, AsyncIterable): @abc.abstractmethod def __init__( self, *args: Any, original_channel: Optional[ChannelT] = None, **kwargs: Any - ) -> None: - ... + ) -> None: ... @abc.abstractmethod async def put( @@ -349,8 +316,7 @@ async def put( reply_to: ReplyToArg = None, correlation_id: Optional[str] = None, wait: bool = True, - ) -> EventT: - ... + ) -> EventT: ... @abc.abstractmethod def to_message( @@ -363,9 +329,7 @@ def to_message( timestamp: Optional[float] = None, timestamp_type: int = 0, headers: HeadersArg = None, - ) -> Message: - ... + ) -> Message: ... @abc.abstractmethod - async def throw(self, exc: BaseException) -> None: - ... + async def throw(self, exc: BaseException) -> None: ... diff --git a/faust/types/app.py b/faust/types/app.py index da9fdf407..c62858dcb 100644 --- a/faust/types/app.py +++ b/faust/types/app.py @@ -66,29 +66,21 @@ from .settings import Settings as _Settings else: - class _AppCommand: - ... # noqa + class _AppCommand: ... # noqa - class _SchemaT: - ... # noqa + class _SchemaT: ... # noqa - class _LiveCheck: - ... # noqa + class _LiveCheck: ... # noqa - class _Monitor: - ... # noqa + class _Monitor: ... # noqa - class _Worker: - ... # noqa + class _Worker: ... # noqa - class _EventT: - ... # noqa + class _EventT: ... # noqa - class _ModelArg: - ... # noqa + class _ModelArg: ... # noqa - class _Settings: - ... # noqa + class _Settings: ... # noqa __all__ = [ @@ -103,18 +95,15 @@ class _Settings: class TracerT(abc.ABC): @property @abc.abstractmethod - def default_tracer(self) -> opentracing.Tracer: - ... + def default_tracer(self) -> opentracing.Tracer: ... @abc.abstractmethod def trace( self, name: str, sample_rate: Optional[float] = None, **extra_context: Any - ) -> ContextManager: - ... + ) -> ContextManager: ... @abc.abstractmethod - def get_tracer(self, service_name: str) -> opentracing.Tracer: - ... + def get_tracer(self, service_name: str) -> opentracing.Tracer: ... class BootStrategyT: @@ -142,20 +131,16 @@ def __init__( enable_kafka_producer: Optional[bool] = None, enable_kafka_consumer: Optional[bool] = None, enable_sensors: bool = True, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def server(self) -> Iterable[ServiceT]: - ... + def server(self) -> Iterable[ServiceT]: ... @abc.abstractmethod - def client_only(self) -> Iterable[ServiceT]: - ... + def client_only(self) -> Iterable[ServiceT]: ... @abc.abstractmethod - def producer_only(self) -> Iterable[ServiceT]: - ... + def producer_only(self) -> Iterable[ServiceT]: ... class AppT(ServiceT): @@ -224,24 +209,19 @@ def __init__( @abc.abstractmethod def config_from_object( self, obj: Any, *, silent: bool = False, force: bool = False - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def finalize(self) -> None: - ... + def finalize(self) -> None: ... @abc.abstractmethod - def main(self) -> NoReturn: - ... + def main(self) -> NoReturn: ... @abc.abstractmethod - def worker_init(self) -> None: - ... + def worker_init(self) -> None: ... @abc.abstractmethod - def worker_init_post_autodiscover(self) -> None: - ... + def worker_init_post_autodiscover(self) -> None: ... @abc.abstractmethod def discover( @@ -249,8 +229,7 @@ def discover( *extra_modules: str, categories: Iterable[str] = ("a", "b", "c"), ignore: Iterable[Any] = ("foo", "bar"), - ) -> None: - ... + ) -> None: ... @abc.abstractmethod def topic( @@ -274,8 +253,7 @@ def topic( allow_empty: bool = False, has_prefix: bool = False, loop: Optional[asyncio.AbstractEventLoop] = None, - ) -> TopicT: - ... + ) -> TopicT: ... @abc.abstractmethod def channel( @@ -286,8 +264,7 @@ def channel( value_type: _ModelArg = None, maxsize: Optional[int] = None, loop: Optional[asyncio.AbstractEventLoop] = None, - ) -> ChannelT: - ... + ) -> ChannelT: ... @abc.abstractmethod def agent( @@ -301,15 +278,13 @@ def agent( isolated_partitions: bool = False, use_reply_headers: bool = True, **kwargs: Any, - ) -> Callable[[AgentFun[_T]], AgentT[_T]]: - ... + ) -> Callable[[AgentFun[_T]], AgentT[_T]]: ... @abc.abstractmethod @no_type_check def task( self, fun: TaskArg, *, on_leader: bool = False, traced: bool = True - ) -> Callable: - ... + ) -> Callable: ... @abc.abstractmethod def timer( @@ -319,8 +294,7 @@ def timer( traced: bool = True, name: Optional[str] = None, max_drift_correction: float = 0.1, - ) -> Callable: - ... + ) -> Callable: ... @abc.abstractmethod def crontab( @@ -330,18 +304,15 @@ def crontab( timezone: tzinfo = None, on_leader: bool = False, traced: bool = True, - ) -> Callable: - ... + ) -> Callable: ... @abc.abstractmethod - def service(self, cls: Type[ServiceT]) -> Type[ServiceT]: - ... + def service(self, cls: Type[ServiceT]) -> Type[ServiceT]: ... @abc.abstractmethod def stream( self, channel: AsyncIterable, beacon: Optional[NodeT] = None, **kwargs: Any - ) -> StreamT: - ... + ) -> StreamT: ... @abc.abstractmethod def Table( @@ -353,8 +324,7 @@ def Table( partitions: Optional[int] = None, help: Optional[str] = None, **kwargs: Any, - ) -> TableT: - ... + ) -> TableT: ... @abc.abstractmethod def GlobalTable( @@ -366,8 +336,7 @@ def GlobalTable( partitions: Optional[int] = None, help: Optional[str] = None, **kwargs: Any, - ) -> TableT: - ... + ) -> TableT: ... @abc.abstractmethod def SetTable( @@ -379,8 +348,7 @@ def SetTable( start_manager: bool = False, help: Optional[str] = None, **kwargs: Any, - ) -> TableT: - ... + ) -> TableT: ... @abc.abstractmethod def SetGlobalTable( @@ -392,8 +360,7 @@ def SetGlobalTable( start_manager: bool = False, help: Optional[str] = None, **kwargs: Any, - ) -> TableT: - ... + ) -> TableT: ... @abc.abstractmethod def page( @@ -403,8 +370,7 @@ def page( base: Type[View] = View, cors_options: Mapping[str, ResourceOptions] = None, name: Optional[str] = None, - ) -> Callable[[PageArg], Type[View]]: - ... + ) -> Callable[[PageArg], Type[View]]: ... @abc.abstractmethod def table_route( @@ -415,34 +381,28 @@ def table_route( query_param: Optional[str] = None, match_info: Optional[str] = None, exact_key: Optional[str] = None, - ) -> ViewDecorator: - ... + ) -> ViewDecorator: ... @abc.abstractmethod def command( self, *options: Any, base: Type[_AppCommand] = None, **kwargs: Any - ) -> Callable[[Callable], Type[_AppCommand]]: - ... + ) -> Callable[[Callable], Type[_AppCommand]]: ... @abc.abstractmethod def create_event( self, key: K, value: V, headers: HeadersArg, message: Message - ) -> _EventT: - ... + ) -> _EventT: ... @abc.abstractmethod - async def start_client(self) -> None: - ... + async def start_client(self) -> None: ... @abc.abstractmethod - async def maybe_start_client(self) -> None: - ... + async def maybe_start_client(self) -> None: ... @abc.abstractmethod def trace( self, name: str, trace_enabled: bool = True, **extra_context: Any - ) -> ContextManager: - ... + ) -> ContextManager: ... @abc.abstractmethod async def send( @@ -457,21 +417,17 @@ async def send( key_serializer: CodecArg = None, value_serializer: CodecArg = None, callback: Optional[MessageSentCallback] = None, - ) -> Awaitable[RecordMetadata]: - ... + ) -> Awaitable[RecordMetadata]: ... @abc.abstractmethod - def LiveCheck(self, **kwargs: Any) -> _LiveCheck: - ... + def LiveCheck(self, **kwargs: Any) -> _LiveCheck: ... @stampede @abc.abstractmethod - async def maybe_start_producer(self) -> ProducerT: - ... + async def maybe_start_producer(self) -> ProducerT: ... @abc.abstractmethod - def is_leader(self) -> bool: - ... + def is_leader(self) -> bool: ... @abc.abstractmethod def FlowControlQueue( @@ -479,92 +435,72 @@ def FlowControlQueue( maxsize: Optional[int] = None, *, clear_on_resume: bool = False, - ) -> ThrowableQueue: - ... + ) -> ThrowableQueue: ... @abc.abstractmethod - def Worker(self, **kwargs: Any) -> _Worker: - ... + def Worker(self, **kwargs: Any) -> _Worker: ... @abc.abstractmethod - def on_webserver_init(self, web: Web) -> None: - ... + def on_webserver_init(self, web: Web) -> None: ... @abc.abstractmethod - def on_rebalance_start(self) -> None: - ... + def on_rebalance_start(self) -> None: ... @abc.abstractmethod - def on_rebalance_return(self) -> None: - ... + def on_rebalance_return(self) -> None: ... @abc.abstractmethod - def on_rebalance_end(self) -> None: - ... + def on_rebalance_end(self) -> None: ... @property - def conf(self) -> _Settings: - ... + def conf(self) -> _Settings: ... @conf.setter - def conf(self, settings: _Settings) -> None: - ... + def conf(self, settings: _Settings) -> None: ... @property @abc.abstractmethod - def transport(self) -> TransportT: - ... + def transport(self) -> TransportT: ... @transport.setter - def transport(self, transport: TransportT) -> None: - ... + def transport(self, transport: TransportT) -> None: ... @property @abc.abstractmethod - def producer_transport(self) -> TransportT: - ... + def producer_transport(self) -> TransportT: ... @producer_transport.setter - def producer_transport(self, transport: TransportT) -> None: - ... + def producer_transport(self, transport: TransportT) -> None: ... @property @abc.abstractmethod - def cache(self) -> CacheBackendT: - ... + def cache(self) -> CacheBackendT: ... @cache.setter - def cache(self, cache: CacheBackendT) -> None: - ... + def cache(self, cache: CacheBackendT) -> None: ... @property @abc.abstractmethod - def producer(self) -> ProducerT: - ... + def producer(self) -> ProducerT: ... @property @abc.abstractmethod - def consumer(self) -> ConsumerT: - ... + def consumer(self) -> ConsumerT: ... @cached_property @abc.abstractmethod - def tables(self) -> TableManagerT: - ... + def tables(self) -> TableManagerT: ... @cached_property @abc.abstractmethod - def topics(self) -> ConductorT: - ... + def topics(self) -> ConductorT: ... @property @abc.abstractmethod - def monitor(self) -> _Monitor: - ... + def monitor(self) -> _Monitor: ... @monitor.setter - def monitor(self, value: _Monitor) -> None: - ... + def monitor(self, value: _Monitor) -> None: ... @cached_property @abc.abstractmethod @@ -573,42 +509,33 @@ def flow_control(self) -> FlowControlEvent: @property @abc.abstractmethod - def http_client(self) -> HttpClientT: - ... + def http_client(self) -> HttpClientT: ... @http_client.setter - def http_client(self, client: HttpClientT) -> None: - ... + def http_client(self, client: HttpClientT) -> None: ... @cached_property @abc.abstractmethod - def assignor(self) -> PartitionAssignorT: - ... + def assignor(self) -> PartitionAssignorT: ... @cached_property @abc.abstractmethod - def router(self) -> RouterT: - ... + def router(self) -> RouterT: ... @cached_property @abc.abstractmethod - def serializers(self) -> RegistryT: - ... + def serializers(self) -> RegistryT: ... @cached_property @abc.abstractmethod - def web(self) -> Web: - ... + def web(self) -> Web: ... @cached_property @abc.abstractmethod - def in_transaction(self) -> bool: - ... + def in_transaction(self) -> bool: ... @abc.abstractmethod - def _span_add_default_tags(self, span: opentracing.Span) -> None: - ... + def _span_add_default_tags(self, span: opentracing.Span) -> None: ... @abc.abstractmethod - def _start_span_from_rebalancing(self, name: str) -> opentracing.Span: - ... + def _start_span_from_rebalancing(self, name: str) -> opentracing.Span: ... diff --git a/faust/types/assignor.py b/faust/types/assignor.py index d00ffd412..b32a09da6 100644 --- a/faust/types/assignor.py +++ b/faust/types/assignor.py @@ -11,8 +11,7 @@ from .app import AppT as _AppT else: - class _AppT: - ... # noqa + class _AppT: ... # noqa __all__ = [ @@ -31,49 +30,38 @@ class PartitionAssignorT(abc.ABC): app: _AppT @abc.abstractmethod - def __init__(self, app: _AppT, replicas: int = 0) -> None: - ... + def __init__(self, app: _AppT, replicas: int = 0) -> None: ... @abc.abstractmethod - def group_for_topic(self, topic: str) -> int: - ... + def group_for_topic(self, topic: str) -> int: ... @abc.abstractmethod - def assigned_standbys(self) -> Set[TP]: - ... + def assigned_standbys(self) -> Set[TP]: ... @abc.abstractmethod - def assigned_actives(self) -> Set[TP]: - ... + def assigned_actives(self) -> Set[TP]: ... @abc.abstractmethod - def is_active(self, tp: TP) -> bool: - ... + def is_active(self, tp: TP) -> bool: ... @abc.abstractmethod - def is_standby(self, tp: TP) -> bool: - ... + def is_standby(self, tp: TP) -> bool: ... @abc.abstractmethod - def key_store(self, topic: str, key: bytes) -> URL: - ... + def key_store(self, topic: str, key: bytes) -> URL: ... @abc.abstractmethod - def table_metadata(self, topic: str) -> HostToPartitionMap: - ... + def table_metadata(self, topic: str) -> HostToPartitionMap: ... @abc.abstractmethod - def tables_metadata(self) -> HostToPartitionMap: - ... + def tables_metadata(self) -> HostToPartitionMap: ... class LeaderAssignorT(ServiceT): app: _AppT @abc.abstractmethod - def __init__(self, app: _AppT, **kwargs: Any) -> None: - ... + def __init__(self, app: _AppT, **kwargs: Any) -> None: ... @abc.abstractmethod - def is_leader(self) -> bool: - ... + def is_leader(self) -> bool: ... diff --git a/faust/types/channels.py b/faust/types/channels.py index 553d4f394..b717c1a68 100644 --- a/faust/types/channels.py +++ b/faust/types/channels.py @@ -22,20 +22,15 @@ from .streams import StreamT as _StreamT else: - class _AppT: - ... # noqa + class _AppT: ... # noqa - class _EventT(Generic[_T]): - ... # noqa + class _EventT(Generic[_T]): ... # noqa - class _ModelArg: - ... # noqa + class _ModelArg: ... # noqa - class _SchemaT: - ... # noqa + class _SchemaT: ... # noqa - class _StreamT: - ... # noqa + class _StreamT: ... # noqa class ChannelT(AsyncIterator[_EventT[_T]]): @@ -61,26 +56,21 @@ def __init__( root: "ChannelT" = None, active_partitions: Optional[Set[TP]] = None, loop: Optional[asyncio.AbstractEventLoop] = None, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod def clone( self, *, is_iterator: Optional[bool] = None, **kwargs: Any - ) -> "ChannelT[_T]": - ... + ) -> "ChannelT[_T]": ... @abc.abstractmethod - def clone_using_queue(self, queue: asyncio.Queue) -> "ChannelT[_T]": - ... + def clone_using_queue(self, queue: asyncio.Queue) -> "ChannelT[_T]": ... @abc.abstractmethod - def stream(self, **kwargs: Any) -> "_StreamT[_T]": - ... + def stream(self, **kwargs: Any) -> "_StreamT[_T]": ... @abc.abstractmethod - def get_topic_name(self) -> str: - ... + def get_topic_name(self) -> str: ... @abc.abstractmethod async def send( @@ -96,8 +86,7 @@ async def send( value_serializer: CodecArg = None, callback: Optional[MessageSentCallback] = None, force: bool = False, - ) -> Awaitable[RecordMetadata]: - ... + ) -> Awaitable[RecordMetadata]: ... @abc.abstractmethod def send_soon( @@ -114,8 +103,7 @@ def send_soon( callback: Optional[MessageSentCallback] = None, force: bool = False, eager_partitioning: bool = False, - ) -> FutureMessage: - ... + ) -> FutureMessage: ... @abc.abstractmethod def as_future_message( @@ -130,98 +118,78 @@ def as_future_message( value_serializer: CodecArg = None, callback: Optional[MessageSentCallback] = None, eager_partitioning: bool = False, - ) -> FutureMessage: - ... + ) -> FutureMessage: ... @abc.abstractmethod async def publish_message( self, fut: FutureMessage, wait: bool = True - ) -> Awaitable[RecordMetadata]: - ... + ) -> Awaitable[RecordMetadata]: ... @stampede @abc.abstractmethod - async def maybe_declare(self) -> None: - ... + async def maybe_declare(self) -> None: ... @abc.abstractmethod - async def declare(self) -> None: - ... + async def declare(self) -> None: ... @abc.abstractmethod def prepare_key( self, key: K, key_serializer: CodecArg, schema: Optional[_SchemaT] = None - ) -> Any: - ... + ) -> Any: ... @abc.abstractmethod def prepare_value( self, value: V, value_serializer: CodecArg, schema: Optional[_SchemaT] = None - ) -> Any: - ... + ) -> Any: ... @abc.abstractmethod - async def decode(self, message: Message, *, propagate: bool = False) -> _EventT[_T]: - ... + async def decode( + self, message: Message, *, propagate: bool = False + ) -> _EventT[_T]: ... @abc.abstractmethod - async def deliver(self, message: Message) -> None: - ... + async def deliver(self, message: Message) -> None: ... @abc.abstractmethod - async def put(self, value: _EventT[_T]) -> None: - ... + async def put(self, value: _EventT[_T]) -> None: ... @abc.abstractmethod - async def get(self, *, timeout: Optional[Seconds] = None) -> _EventT[_T]: - ... + async def get(self, *, timeout: Optional[Seconds] = None) -> _EventT[_T]: ... @abc.abstractmethod - def empty(self) -> bool: - ... + def empty(self) -> bool: ... @abc.abstractmethod - async def on_key_decode_error(self, exc: Exception, message: Message) -> None: - ... + async def on_key_decode_error(self, exc: Exception, message: Message) -> None: ... @abc.abstractmethod - async def on_value_decode_error(self, exc: Exception, message: Message) -> None: - ... + async def on_value_decode_error(self, exc: Exception, message: Message) -> None: ... @abc.abstractmethod - async def on_decode_error(self, exc: Exception, message: Message) -> None: - ... + async def on_decode_error(self, exc: Exception, message: Message) -> None: ... @abc.abstractmethod - def on_stop_iteration(self) -> None: - ... + def on_stop_iteration(self) -> None: ... @abc.abstractmethod - def __aiter__(self) -> "ChannelT": - ... + def __aiter__(self) -> "ChannelT": ... @abc.abstractmethod - def __anext__(self) -> Awaitable[_EventT[_T]]: - ... + def __anext__(self) -> Awaitable[_EventT[_T]]: ... @abc.abstractmethod - async def throw(self, exc: BaseException) -> None: - ... + async def throw(self, exc: BaseException) -> None: ... @abc.abstractmethod - def _throw(self, exc: BaseException) -> None: - ... + def _throw(self, exc: BaseException) -> None: ... @abc.abstractmethod - def derive(self, **kwargs: Any) -> "ChannelT": - ... + def derive(self, **kwargs: Any) -> "ChannelT": ... @property @abc.abstractmethod - def subscriber_count(self) -> int: - ... + def subscriber_count(self) -> int: ... @property @abc.abstractmethod - def queue(self) -> ThrowableQueue: - ... + def queue(self) -> ThrowableQueue: ... diff --git a/faust/types/codecs.py b/faust/types/codecs.py index e7f1bfb8f..32efe9cf2 100644 --- a/faust/types/codecs.py +++ b/faust/types/codecs.py @@ -12,24 +12,21 @@ class CodecT(metaclass=abc.ABCMeta): """ @abc.abstractmethod - def __init__(self, children: Tuple["CodecT", ...] = None, **kwargs: Any) -> None: - ... + def __init__( + self, children: Tuple["CodecT", ...] = None, **kwargs: Any + ) -> None: ... @abc.abstractmethod - def dumps(self, obj: Any) -> bytes: - ... + def dumps(self, obj: Any) -> bytes: ... @abc.abstractmethod - def loads(self, s: bytes) -> Any: - ... + def loads(self, s: bytes) -> Any: ... @abc.abstractmethod - def clone(self, *children: "CodecT") -> "CodecT": - ... + def clone(self, *children: "CodecT") -> "CodecT": ... @abc.abstractmethod - def __or__(self, other: Any) -> Any: - ... + def __or__(self, other: Any) -> Any: ... # `serializer` argument can be str or Codec instance. diff --git a/faust/types/core.py b/faust/types/core.py index ae3ea2103..3a79e7369 100644 --- a/faust/types/core.py +++ b/faust/types/core.py @@ -18,8 +18,7 @@ from .models import ModelT as _ModelT else: - class _ModelT: - ... # noqa + class _ModelT: ... # noqa __all__ = ["K", "V"] diff --git a/faust/types/events.py b/faust/types/events.py index 96f566ba7..11061e07b 100644 --- a/faust/types/events.py +++ b/faust/types/events.py @@ -14,14 +14,11 @@ from .serializers import SchemaT as _SchemaT else: - class _AppT: - ... # noqa + class _AppT: ... # noqa - class _ChannelT: - ... # noqa + class _ChannelT: ... # noqa - class _SchemaT: - ... # noqa + class _SchemaT: ... # noqa T = TypeVar("T") @@ -45,8 +42,7 @@ def __init__( value: V, headers: Optional[HeadersArg], message: Message, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod async def send( @@ -62,8 +58,7 @@ async def send( value_serializer: CodecArg = None, callback: Optional[MessageSentCallback] = None, force: bool = False, - ) -> Awaitable[RecordMetadata]: - ... + ) -> Awaitable[RecordMetadata]: ... @abc.abstractmethod async def forward( @@ -79,9 +74,7 @@ async def forward( value_serializer: CodecArg = None, callback: Optional[MessageSentCallback] = None, force: bool = False, - ) -> Awaitable[RecordMetadata]: - ... + ) -> Awaitable[RecordMetadata]: ... @abc.abstractmethod - def ack(self) -> bool: - ... + def ack(self) -> bool: ... diff --git a/faust/types/fixups.py b/faust/types/fixups.py index 1cbb5e3a2..fabff849d 100644 --- a/faust/types/fixups.py +++ b/faust/types/fixups.py @@ -6,8 +6,7 @@ from .app import AppT as _AppT else: - class _AppT: - ... # noqa + class _AppT: ... # noqa __all__ = ["FixupT"] @@ -17,17 +16,13 @@ class FixupT(abc.ABC): app: _AppT @abc.abstractmethod - def __init__(self, app: _AppT) -> None: - ... + def __init__(self, app: _AppT) -> None: ... @abc.abstractmethod - def enabled(self) -> bool: - ... + def enabled(self) -> bool: ... @abc.abstractmethod - def autodiscover_modules(self) -> Iterable[str]: - ... + def autodiscover_modules(self) -> Iterable[str]: ... @abc.abstractmethod - def on_worker_init(self) -> None: - ... + def on_worker_init(self) -> None: ... diff --git a/faust/types/joins.py b/faust/types/joins.py index aacd3c6ec..1aced9c47 100644 --- a/faust/types/joins.py +++ b/faust/types/joins.py @@ -15,9 +15,7 @@ class JoinT(abc.ABC): @abc.abstractmethod def __init__( self, *, stream: JoinableT, fields: Tuple[FieldDescriptorT, ...] - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - async def process(self, event: EventT) -> Optional[EventT]: - ... + async def process(self, event: EventT) -> Optional[EventT]: ... diff --git a/faust/types/models.py b/faust/types/models.py index b0a432270..f0710e42a 100644 --- a/faust/types/models.py +++ b/faust/types/models.py @@ -145,8 +145,9 @@ class ModelT(base): # type: ignore @classmethod @abc.abstractmethod - def from_data(cls, data: Any, *, preferred_type: Type["ModelT"] = None) -> "ModelT": - ... + def from_data( + cls, data: Any, *, preferred_type: Type["ModelT"] = None + ) -> "ModelT": ... @classmethod @abc.abstractmethod @@ -156,41 +157,32 @@ def loads( *, default_serializer: CodecArg = None, # XXX use serializer serializer: CodecArg = None, - ) -> "ModelT": - ... + ) -> "ModelT": ... @abc.abstractmethod - def __init__(self, *args: Any, **kwargs: Any) -> None: - ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... @abc.abstractmethod - def dumps(self, *, serializer: CodecArg = None) -> bytes: - ... + def dumps(self, *, serializer: CodecArg = None) -> bytes: ... @abc.abstractmethod - def derive(self, *objects: "ModelT", **fields: Any) -> "ModelT": - ... + def derive(self, *objects: "ModelT", **fields: Any) -> "ModelT": ... @abc.abstractmethod - def to_representation(self) -> Any: - ... + def to_representation(self) -> Any: ... @abc.abstractmethod - def is_valid(self) -> bool: - ... + def is_valid(self) -> bool: ... @abc.abstractmethod - def validate(self) -> List[ValidationError]: - ... + def validate(self) -> List[ValidationError]: ... @abc.abstractmethod - def validate_or_raise(self) -> None: - ... + def validate_or_raise(self) -> None: ... @property @abc.abstractmethod - def validation_errors(self) -> List[ValidationError]: - ... + def validation_errors(self) -> List[ValidationError]: ... class FieldDescriptorT(Generic[T]): @@ -227,59 +219,46 @@ def __init__( ) @abc.abstractmethod - def on_model_attached(self) -> None: - ... + def on_model_attached(self) -> None: ... @abc.abstractmethod - def clone(self, **kwargs: Any) -> "FieldDescriptorT": - ... + def clone(self, **kwargs: Any) -> "FieldDescriptorT": ... @abc.abstractmethod - def as_dict(self) -> Mapping[str, Any]: - ... + def as_dict(self) -> Mapping[str, Any]: ... @abc.abstractmethod - def validate_all(self, value: Any) -> Iterable[ValidationError]: - ... + def validate_all(self, value: Any) -> Iterable[ValidationError]: ... @abc.abstractmethod - def validate(self, value: T) -> Iterable[ValidationError]: - ... + def validate(self, value: T) -> Iterable[ValidationError]: ... @abc.abstractmethod - def to_python(self, value: Any) -> Optional[T]: - ... + def to_python(self, value: Any) -> Optional[T]: ... @abc.abstractmethod - def prepare_value(self, value: Any) -> Optional[T]: - ... + def prepare_value(self, value: Any) -> Optional[T]: ... @abc.abstractmethod - def should_coerce(self, value: Any) -> bool: - ... + def should_coerce(self, value: Any) -> bool: ... @abc.abstractmethod - def getattr(self, obj: ModelT) -> T: - ... + def getattr(self, obj: ModelT) -> T: ... @abc.abstractmethod - def validation_error(self, reason: str) -> ValidationError: - ... + def validation_error(self, reason: str) -> ValidationError: ... @property @abc.abstractmethod - def ident(self) -> str: - ... + def ident(self) -> str: ... @cached_property @abc.abstractmethod - def related_models(self) -> Set[Type[ModelT]]: - ... + def related_models(self) -> Set[Type[ModelT]]: ... @cached_property @abc.abstractmethod - def lazy_coercion(self) -> bool: - ... + def lazy_coercion(self) -> bool: ... # XXX See top of module! We redefine with actual ModelT for Sphinx, diff --git a/faust/types/router.py b/faust/types/router.py index 011027875..fad8b5bb0 100644 --- a/faust/types/router.py +++ b/faust/types/router.py @@ -1,4 +1,5 @@ """Types for module :mod:`faust.router`.""" + import abc import typing @@ -13,8 +14,7 @@ from .app import AppT as _AppT else: - class _AppT: - ... # noqa + class _AppT: ... # noqa class RouterT(abc.ABC): @@ -23,37 +23,29 @@ class RouterT(abc.ABC): app: _AppT @abc.abstractmethod - def __init__(self, app: _AppT) -> None: - ... + def __init__(self, app: _AppT) -> None: ... @abc.abstractmethod - def key_store(self, table_name: str, key: K) -> URL: - ... + def key_store(self, table_name: str, key: K) -> URL: ... @abc.abstractmethod - def external_topic_key_store(self, topic: TopicT, key: K) -> URL: - ... + def external_topic_key_store(self, topic: TopicT, key: K) -> URL: ... @abc.abstractmethod - def table_metadata(self, table_name: str) -> HostToPartitionMap: - ... + def table_metadata(self, table_name: str) -> HostToPartitionMap: ... @abc.abstractmethod - def tables_metadata(self) -> HostToPartitionMap: - ... + def tables_metadata(self) -> HostToPartitionMap: ... @abc.abstractmethod - def external_topics_metadata(self) -> HostToPartitionMap: - ... + def external_topics_metadata(self) -> HostToPartitionMap: ... @abc.abstractmethod async def route_req( self, table_name: str, key: K, web: web.Web, request: web.Request - ) -> web.Response: - ... + ) -> web.Response: ... @abc.abstractmethod async def route_topic_req( self, topic: TopicT, key: K, web: web.Web, request: web.Request - ) -> web.Response: - ... + ) -> web.Response: ... diff --git a/faust/types/sensors.py b/faust/types/sensors.py index 47a08f675..a55d39e52 100644 --- a/faust/types/sensors.py +++ b/faust/types/sensors.py @@ -16,8 +16,7 @@ from .app import AppT as _AppT else: - class _AppT: - ... # noqa + class _AppT: ... # noqa __all__ = ["SensorInterfaceT", "SensorT", "SensorDelegateT"] @@ -25,48 +24,38 @@ class _AppT: class SensorInterfaceT(abc.ABC): @abc.abstractmethod - def on_message_in(self, tp: TP, offset: int, message: Message) -> None: - ... + def on_message_in(self, tp: TP, offset: int, message: Message) -> None: ... @abc.abstractmethod def on_stream_event_in( self, tp: TP, offset: int, stream: StreamT, event: EventT - ) -> Optional[Dict]: - ... + ) -> Optional[Dict]: ... @abc.abstractmethod def on_stream_event_out( self, tp: TP, offset: int, stream: StreamT, event: EventT, state: Dict = None - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def on_topic_buffer_full(self, tp: TP) -> None: - ... + def on_topic_buffer_full(self, tp: TP) -> None: ... @abc.abstractmethod - def on_message_out(self, tp: TP, offset: int, message: Message) -> None: - ... + def on_message_out(self, tp: TP, offset: int, message: Message) -> None: ... @abc.abstractmethod - def on_table_get(self, table: CollectionT, key: Any) -> None: - ... + def on_table_get(self, table: CollectionT, key: Any) -> None: ... @abc.abstractmethod - def on_table_set(self, table: CollectionT, key: Any, value: Any) -> None: - ... + def on_table_set(self, table: CollectionT, key: Any, value: Any) -> None: ... @abc.abstractmethod - def on_table_del(self, table: CollectionT, key: Any) -> None: - ... + def on_table_del(self, table: CollectionT, key: Any) -> None: ... @abc.abstractmethod - def on_commit_initiated(self, consumer: ConsumerT) -> Any: - ... + def on_commit_initiated(self, consumer: ConsumerT) -> Any: ... @abc.abstractmethod - def on_commit_completed(self, consumer: ConsumerT, state: Any) -> None: - ... + def on_commit_completed(self, consumer: ConsumerT, state: Any) -> None: ... @abc.abstractmethod def on_send_initiated( @@ -76,54 +65,44 @@ def on_send_initiated( message: PendingMessage, keysize: int, valsize: int, - ) -> Any: - ... + ) -> Any: ... @abc.abstractmethod def on_send_completed( self, producer: ProducerT, state: Any, metadata: RecordMetadata - ) -> None: - ... + ) -> None: ... @abc.abstractmethod def on_send_error( self, producer: ProducerT, exc: BaseException, state: Any - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def on_assignment_start(self, assignor: PartitionAssignorT) -> Dict: - ... + def on_assignment_start(self, assignor: PartitionAssignorT) -> Dict: ... @abc.abstractmethod def on_assignment_error( self, assignor: PartitionAssignorT, state: Dict, exc: BaseException - ) -> None: - ... + ) -> None: ... @abc.abstractmethod def on_assignment_completed( self, assignor: PartitionAssignorT, state: Dict - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def on_rebalance_start(self, app: _AppT) -> Dict: - ... + def on_rebalance_start(self, app: _AppT) -> Dict: ... @abc.abstractmethod - def on_rebalance_return(self, app: _AppT, state: Dict) -> None: - ... + def on_rebalance_return(self, app: _AppT, state: Dict) -> None: ... @abc.abstractmethod - def on_rebalance_end(self, app: _AppT, state: Dict) -> None: - ... + def on_rebalance_end(self, app: _AppT, state: Dict) -> None: ... @abc.abstractmethod def on_web_request_start( self, app: _AppT, request: web.Request, *, view: web.View = None - ) -> Dict: - ... + ) -> Dict: ... @abc.abstractmethod def on_web_request_end( @@ -134,25 +113,20 @@ def on_web_request_end( state: Dict, *, view: web.View = None, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def on_threaded_producer_buffer_processed(self, app: _AppT, size: int) -> None: - ... + def on_threaded_producer_buffer_processed(self, app: _AppT, size: int) -> None: ... -class SensorT(SensorInterfaceT, ServiceT): - ... +class SensorT(SensorInterfaceT, ServiceT): ... class SensorDelegateT(SensorInterfaceT, Iterable): # Delegate calls to many sensors. @abc.abstractmethod - def add(self, sensor: SensorT) -> None: - ... + def add(self, sensor: SensorT) -> None: ... @abc.abstractmethod - def remove(self, sensor: SensorT) -> None: - ... + def remove(self, sensor: SensorT) -> None: ... diff --git a/faust/types/serializers.py b/faust/types/serializers.py index 79163045a..dd8b93756 100644 --- a/faust/types/serializers.py +++ b/faust/types/serializers.py @@ -11,14 +11,11 @@ from .tuples import Message as _Message else: - class _AppT: - ... # noqa + class _AppT: ... # noqa - class _ModelArg: - ... # noqa + class _ModelArg: ... # noqa - class _Message: - ... # noqa + class _Message: ... # noqa __all__ = ["RegistryT", "SchemaT"] @@ -34,8 +31,7 @@ class RegistryT(abc.ABC): @abc.abstractmethod def __init__( self, key_serializer: CodecArg = None, value_serializer: CodecArg = "json" - ) -> None: - ... + ) -> None: ... @abc.abstractmethod def loads_key( @@ -44,8 +40,7 @@ def loads_key( key: Optional[bytes], *, serializer: CodecArg = None, - ) -> K: - ... + ) -> K: ... @abc.abstractmethod def loads_value( @@ -54,20 +49,17 @@ def loads_value( value: Optional[bytes], *, serializer: CodecArg = None, - ) -> Any: - ... + ) -> Any: ... @abc.abstractmethod def dumps_key( self, typ: Optional[_ModelArg], key: K, *, serializer: CodecArg = None - ) -> Optional[bytes]: - ... + ) -> Optional[bytes]: ... @abc.abstractmethod def dumps_value( self, typ: Optional[_ModelArg], value: V, *, serializer: CodecArg = None - ) -> Optional[bytes]: - ... + ) -> Optional[bytes]: ... class SchemaT(Generic[KT, VT]): @@ -87,8 +79,7 @@ def __init__( key_serializer: CodecArg = None, value_serializer: CodecArg = None, allow_empty: Optional[bool] = None, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod def update( @@ -99,8 +90,7 @@ def update( key_serializer: CodecArg = None, value_serializer: CodecArg = None, allow_empty: Optional[bool] = None, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod def loads_key( @@ -110,8 +100,7 @@ def loads_key( *, loads: Optional[Callable] = None, serializer: CodecArg = None, - ) -> KT: - ... + ) -> KT: ... @abc.abstractmethod def loads_value( @@ -121,8 +110,7 @@ def loads_value( *, loads: Optional[Callable] = None, serializer: CodecArg = None, - ) -> VT: - ... + ) -> VT: ... @abc.abstractmethod def dumps_key( @@ -132,8 +120,7 @@ def dumps_key( *, serializer: CodecArg = None, headers: OpenHeadersArg, - ) -> Tuple[Any, OpenHeadersArg]: - ... + ) -> Tuple[Any, OpenHeadersArg]: ... @abc.abstractmethod def dumps_value( @@ -143,17 +130,14 @@ def dumps_value( *, serializer: CodecArg = None, headers: OpenHeadersArg, - ) -> Tuple[Any, OpenHeadersArg]: - ... + ) -> Tuple[Any, OpenHeadersArg]: ... @abc.abstractmethod def on_dumps_key_prepare_headers( self, key: V, headers: OpenHeadersArg - ) -> OpenHeadersArg: - ... + ) -> OpenHeadersArg: ... @abc.abstractmethod def on_dumps_value_prepare_headers( self, value: V, headers: OpenHeadersArg - ) -> OpenHeadersArg: - ... + ) -> OpenHeadersArg: ... diff --git a/faust/types/settings/base.py b/faust/types/settings/base.py index b87b67e72..92f09eb1c 100644 --- a/faust/types/settings/base.py +++ b/faust/types/settings/base.py @@ -13,11 +13,9 @@ from .settings import Settings as _Settings else: - class _Section: - ... # noqa: E701 + class _Section: ... # noqa: E701 - class _Settings: - ... # noqa: E701 + class _Settings: ... # noqa: E701 W_ALREADY_CONFIGURED = """\ @@ -132,12 +130,10 @@ def __init_subclass__(self) -> None: self._init_subclass_settings() @abc.abstractmethod - def on_init(self, id: str, **kwargs: Any) -> None: - ... + def on_init(self, id: str, **kwargs: Any) -> None: ... @abc.abstractmethod - def getenv(self, env_name: str) -> Any: - ... + def getenv(self, env_name: str) -> Any: ... def _init_entrypoint(self, *args: Any, **kwargs: Any) -> None: self._on_before_init() diff --git a/faust/types/settings/params.py b/faust/types/settings/params.py index 7e7e1014d..c55267cd7 100644 --- a/faust/types/settings/params.py +++ b/faust/types/settings/params.py @@ -37,11 +37,9 @@ from .settings import Settings as _Settings else: - class _Section: - ... # noqa + class _Section: ... # noqa - class _Settings: - ... # noqa + class _Settings: ... # noqa __all__ = [ @@ -534,8 +532,7 @@ def _init_options( self.number_aliases = number_aliases or {} @abc.abstractmethod - def convert(self, conf: _Settings, value: IT) -> OT: - ... + def convert(self, conf: _Settings, value: IT) -> OT: ... def to_python(self, conf: _Settings, value: IT) -> OT: """Convert given value to number.""" diff --git a/faust/types/settings/sections.py b/faust/types/settings/sections.py index 4c5cd3cae..7edbd0395 100644 --- a/faust/types/settings/sections.py +++ b/faust/types/settings/sections.py @@ -27,8 +27,7 @@ from .params import Param as _Param else: - class _Param(Generic[IT, OT]): - ... # noqa: E701 + class _Param(Generic[IT, OT]): ... # noqa: E701 class SectionType(Enum): diff --git a/faust/types/settings/settings.py b/faust/types/settings/settings.py index f2203fff5..2fbc84d17 100644 --- a/faust/types/settings/settings.py +++ b/faust/types/settings/settings.py @@ -47,8 +47,7 @@ from faust.types.worker import Worker as _WorkerT else: - class _WorkerT: - ... # noqa + class _WorkerT: ... # noqa # XXX mypy borks if we do `from faust import __version__` @@ -193,8 +192,7 @@ def __init__( stream_ack_exceptions: Optional[bool] = None, url: URLArg = None, **kwargs: Any, - ) -> None: - ... # replaced by __init_subclass__ in BaseSettings + ) -> None: ... # replaced by __init_subclass__ in BaseSettings def on_init(self, id: str, **kwargs: Any) -> None: # version is required for the id diff --git a/faust/types/stores.py b/faust/types/stores.py index 85da70f62..8d89a383d 100644 --- a/faust/types/stores.py +++ b/faust/types/stores.py @@ -16,14 +16,11 @@ from .tables import CollectionT as _CollectionT else: - class _AppT: - ... # noqa + class _AppT: ... # noqa - class _ModelArg: - ... # noqa + class _ModelArg: ... # noqa - class _CollectionT: - ... # noqa + class _CollectionT: ... # noqa __all__ = ["StoreT"] @@ -57,20 +54,16 @@ def __init__( value_serializer: CodecArg = "", options: Optional[Mapping[str, Any]] = None, **kwargs: Any, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def persisted_offset(self, tp: TP) -> Optional[int]: - ... + def persisted_offset(self, tp: TP) -> Optional[int]: ... @abc.abstractmethod - def set_persisted_offset(self, tp: TP, offset: int) -> None: - ... + def set_persisted_offset(self, tp: TP, offset: int) -> None: ... @abc.abstractmethod - async def need_active_standby_for(self, tp: TP) -> bool: - ... + async def need_active_standby_for(self, tp: TP) -> bool: ... @abc.abstractmethod def apply_changelog_batch( @@ -78,12 +71,10 @@ def apply_changelog_batch( batch: Iterable[EventT], to_key: Callable[[Any], KT], to_value: Callable[[Any], VT], - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def reset_state(self) -> None: - ... + def reset_state(self) -> None: ... @abc.abstractmethod async def on_rebalance( @@ -92,20 +83,17 @@ async def on_rebalance( revoked: Set[TP], newly_assigned: Set[TP], generation_id: int = 0, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod async def on_recovery_completed( self, active_tps: Set[TP], standby_tps: Set[TP] - ) -> None: - ... + ) -> None: ... @abc.abstractmethod async def backup_partition( self, tp: Union[TP, int], flush: bool = True, purge: bool = False, keep: int = 1 - ) -> None: - ... + ) -> None: ... @abc.abstractmethod def restore_backup( @@ -113,5 +101,4 @@ def restore_backup( tp: Union[TP, int], latest: bool = True, backup_id: int = 0, - ) -> None: - ... + ) -> None: ... diff --git a/faust/types/streams.py b/faust/types/streams.py index ebc255f72..b5ab4b1e6 100644 --- a/faust/types/streams.py +++ b/faust/types/streams.py @@ -35,14 +35,11 @@ from .serializers import SchemaT as _SchemaT else: - class _AppT: - ... # noqa + class _AppT: ... # noqa - class _JoinT: - ... # noqa + class _JoinT: ... # noqa - class _SchemaT: - ... # noqa + class _SchemaT: ... # noqa __all__ = [ @@ -67,40 +64,31 @@ class _SchemaT: class JoinableT(abc.ABC): @abc.abstractmethod - def combine(self, *nodes: "JoinableT", **kwargs: Any) -> "StreamT": - ... + def combine(self, *nodes: "JoinableT", **kwargs: Any) -> "StreamT": ... @abc.abstractmethod - def join(self, *fields: FieldDescriptorT) -> "StreamT": - ... + def join(self, *fields: FieldDescriptorT) -> "StreamT": ... @abc.abstractmethod - def left_join(self, *fields: FieldDescriptorT) -> "StreamT": - ... + def left_join(self, *fields: FieldDescriptorT) -> "StreamT": ... @abc.abstractmethod - def inner_join(self, *fields: FieldDescriptorT) -> "StreamT": - ... + def inner_join(self, *fields: FieldDescriptorT) -> "StreamT": ... @abc.abstractmethod - def outer_join(self, *fields: FieldDescriptorT) -> "StreamT": - ... + def outer_join(self, *fields: FieldDescriptorT) -> "StreamT": ... @abc.abstractmethod - def __and__(self, other: Any) -> Any: - ... + def __and__(self, other: Any) -> Any: ... @abc.abstractmethod - def contribute_to_stream(self, active: "StreamT") -> None: - ... + def contribute_to_stream(self, active: "StreamT") -> None: ... @abc.abstractmethod - async def remove_from_stream(self, stream: "StreamT") -> None: - ... + async def remove_from_stream(self, stream: "StreamT") -> None: ... @abc.abstractmethod - def _human_channel(self) -> str: - ... + def _human_channel(self) -> str: ... class StreamT(AsyncIterable[T_co], JoinableT, ServiceT): @@ -146,51 +134,42 @@ def __init__( enable_acks: bool = True, prefix: str = "", loop: Optional[asyncio.AbstractEventLoop] = None, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def get_active_stream(self) -> "StreamT": - ... + def get_active_stream(self) -> "StreamT": ... @abc.abstractmethod - def add_processor(self, processor: Processor[T]) -> None: - ... + def add_processor(self, processor: Processor[T]) -> None: ... @abc.abstractmethod - def info(self) -> Mapping[str, Any]: - ... + def info(self) -> Mapping[str, Any]: ... @abc.abstractmethod - def clone(self, **kwargs: Any) -> "StreamT": - ... + def clone(self, **kwargs: Any) -> "StreamT": ... @abc.abstractmethod @no_type_check - async def items(self) -> AsyncIterator[Tuple[K, T_co]]: - ... + async def items(self) -> AsyncIterator[Tuple[K, T_co]]: ... @abc.abstractmethod @no_type_check - async def events(self) -> AsyncIterable[EventT]: - ... + async def events(self) -> AsyncIterable[EventT]: ... @abc.abstractmethod @no_type_check - async def take(self, max_: int, within: Seconds) -> AsyncIterable[Sequence[T_co]]: - ... + async def take( + self, max_: int, within: Seconds + ) -> AsyncIterable[Sequence[T_co]]: ... @abc.abstractmethod - def enumerate(self, start: int = 0) -> AsyncIterable[Tuple[int, T_co]]: - ... + def enumerate(self, start: int = 0) -> AsyncIterable[Tuple[int, T_co]]: ... @abc.abstractmethod - def through(self, channel: Union[str, ChannelT]) -> "StreamT": - ... + def through(self, channel: Union[str, ChannelT]) -> "StreamT": ... @abc.abstractmethod - def echo(self, *channels: Union[str, ChannelT]) -> "StreamT": - ... + def echo(self, *channels: Union[str, ChannelT]) -> "StreamT": ... @abc.abstractmethod def group_by( @@ -199,8 +178,7 @@ def group_by( *, name: Optional[str] = None, topic: Optional[TopicT] = None, - ) -> "StreamT": - ... + ) -> "StreamT": ... @abc.abstractmethod def derive_topic( @@ -212,29 +190,22 @@ def derive_topic( value_type: ModelArg = None, prefix: str = "", suffix: str = "", - ) -> TopicT: - ... + ) -> TopicT: ... @abc.abstractmethod - async def throw(self, exc: BaseException) -> None: - ... + async def throw(self, exc: BaseException) -> None: ... @abc.abstractmethod - def __copy__(self) -> "StreamT": - ... + def __copy__(self) -> "StreamT": ... @abc.abstractmethod - def __iter__(self) -> Any: - ... + def __iter__(self) -> Any: ... @abc.abstractmethod - def __next__(self) -> T: - ... + def __next__(self) -> T: ... @abc.abstractmethod - def __aiter__(self) -> AsyncIterator[T_co]: - ... + def __aiter__(self) -> AsyncIterator[T_co]: ... @abc.abstractmethod - async def ack(self, event: EventT) -> bool: - ... + async def ack(self, event: EventT) -> bool: ... diff --git a/faust/types/tables.py b/faust/types/tables.py index d5eef08e3..ffde15400 100644 --- a/faust/types/tables.py +++ b/faust/types/tables.py @@ -37,17 +37,13 @@ from .serializers import SchemaT as _SchemaT else: - class _AppT: - ... # noqa + class _AppT: ... # noqa - class _FieldDescriptorT: - ... # noqa + class _FieldDescriptorT: ... # noqa - class _ModelArg: - ... # noqa + class _ModelArg: ... # noqa - class _SchemaT: - ... # noqa + class _SchemaT: ... # noqa __all__ = [ @@ -126,41 +122,32 @@ def __init__( use_partitioner: bool = False, on_window_close: Optional[WindowCloseCallback] = None, **kwargs: Any, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def clone(self, **kwargs: Any) -> Any: - ... + def clone(self, **kwargs: Any) -> Any: ... @property @abc.abstractmethod - def changelog_topic(self) -> TopicT: - ... + def changelog_topic(self) -> TopicT: ... @changelog_topic.setter - def changelog_topic(self, topic: TopicT) -> None: - ... + def changelog_topic(self, topic: TopicT) -> None: ... @abc.abstractmethod - def _changelog_topic_name(self) -> str: - ... + def _changelog_topic_name(self) -> str: ... @abc.abstractmethod - def apply_changelog_batch(self, batch: Iterable[EventT]) -> None: - ... + def apply_changelog_batch(self, batch: Iterable[EventT]) -> None: ... @abc.abstractmethod - def persisted_offset(self, tp: TP) -> Optional[int]: - ... + def persisted_offset(self, tp: TP) -> Optional[int]: ... @abc.abstractmethod - async def need_active_standby_for(self, tp: TP) -> bool: - ... + async def need_active_standby_for(self, tp: TP) -> bool: ... @abc.abstractmethod - def reset_state(self) -> None: - ... + def reset_state(self) -> None: ... @abc.abstractmethod def send_changelog( @@ -170,16 +157,13 @@ def send_changelog( value: Any, key_serializer: CodecArg = None, value_serializer: CodecArg = None, - ) -> FutureMessage: - ... + ) -> FutureMessage: ... @abc.abstractmethod - def partition_for_key(self, key: Any) -> Optional[int]: - ... + def partition_for_key(self, key: Any) -> Optional[int]: ... @abc.abstractmethod - async def on_window_close(self, key: Any, value: Any) -> None: - ... + async def on_window_close(self, key: Any, value: Any) -> None: ... @abc.abstractmethod async def on_rebalance( @@ -188,32 +172,26 @@ async def on_rebalance( revoked: Set[TP], newly_assigned: Set[TP], generation_id: int = 0, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - async def on_changelog_event(self, event: EventT) -> None: - ... + async def on_changelog_event(self, event: EventT) -> None: ... @abc.abstractmethod - def on_recover(self, fun: RecoverCallback) -> RecoverCallback: - ... + def on_recover(self, fun: RecoverCallback) -> RecoverCallback: ... @abc.abstractmethod async def on_recovery_completed( self, active_tps: Set[TP], standby_tps: Set[TP] - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - async def call_recover_callbacks(self) -> None: - ... + async def call_recover_callbacks(self) -> None: ... @abc.abstractmethod def using_window( self, window: WindowT, *, key_index: bool = False - ) -> "WindowWrapperT": - ... + ) -> "WindowWrapperT": ... @abc.abstractmethod def hopping( @@ -222,46 +200,36 @@ def hopping( step: Seconds, expires: Optional[Seconds] = None, key_index: bool = False, - ) -> "WindowWrapperT": - ... + ) -> "WindowWrapperT": ... @abc.abstractmethod def tumbling( self, size: Seconds, expires: Optional[Seconds] = None, key_index: bool = False - ) -> "WindowWrapperT": - ... + ) -> "WindowWrapperT": ... @abc.abstractmethod - def as_ansitable(self, **kwargs: Any) -> str: - ... + def as_ansitable(self, **kwargs: Any) -> str: ... @abc.abstractmethod - def _relative_now(self, event: Optional[EventT] = None) -> float: - ... + def _relative_now(self, event: Optional[EventT] = None) -> float: ... @abc.abstractmethod - def _relative_event(self, event: Optional[EventT] = None) -> float: - ... + def _relative_event(self, event: Optional[EventT] = None) -> float: ... @abc.abstractmethod - def _relative_field(self, field: _FieldDescriptorT) -> RelativeHandler: - ... + def _relative_field(self, field: _FieldDescriptorT) -> RelativeHandler: ... @abc.abstractmethod - def _relative_timestamp(self, timestamp: float) -> RelativeHandler: - ... + def _relative_timestamp(self, timestamp: float) -> RelativeHandler: ... @abc.abstractmethod - def _windowed_contains(self, key: Any, timestamp: float) -> bool: - ... + def _windowed_contains(self, key: Any, timestamp: float) -> bool: ... -class TableT(CollectionT, ManagedUserDict[KT, VT]): - ... +class TableT(CollectionT, ManagedUserDict[KT, VT]): ... -class GlobalTableT(TableT): - ... +class GlobalTableT(TableT): ... class TableManagerT(ServiceT, FastUserDict[str, CollectionT]): @@ -271,20 +239,16 @@ class TableManagerT(ServiceT, FastUserDict[str, CollectionT]): standbys_ready: bool @abc.abstractmethod - def __init__(self, app: _AppT, **kwargs: Any) -> None: - ... + def __init__(self, app: _AppT, **kwargs: Any) -> None: ... @abc.abstractmethod - def add(self, table: CollectionT) -> CollectionT: - ... + def add(self, table: CollectionT) -> CollectionT: ... @abc.abstractmethod - def persist_offset_on_commit(self, store: StoreT, tp: TP, offset: int) -> None: - ... + def persist_offset_on_commit(self, store: StoreT, tp: TP, offset: int) -> None: ... @abc.abstractmethod - def on_commit(self, offsets: MutableMapping[TP, int]) -> None: - ... + def on_commit(self, offsets: MutableMapping[TP, int]) -> None: ... @abc.abstractmethod async def on_rebalance( @@ -293,29 +257,23 @@ async def on_rebalance( revoked: Set[TP], newly_assigned: Set[TP], generation_id: int = 0, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def on_partitions_revoked(self, revoked: Set[TP]) -> None: - ... + def on_partitions_revoked(self, revoked: Set[TP]) -> None: ... @abc.abstractmethod - def on_rebalance_start(self) -> None: - ... + def on_rebalance_start(self) -> None: ... @abc.abstractmethod - async def wait_until_tables_registered(self) -> None: - ... + async def wait_until_tables_registered(self) -> None: ... @abc.abstractmethod - async def wait_until_recovery_completed(self) -> bool: - ... + async def wait_until_recovery_completed(self) -> bool: ... @property @abc.abstractmethod - def changelog_topics(self) -> Set[str]: - ... + def changelog_topics(self) -> Set[str]: ... class WindowSetT(FastUserDict[KT, VT]): @@ -330,128 +288,100 @@ def __init__( table: TableT, wrapper: "WindowWrapperT", event: Optional[EventT] = None, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod def apply( self, op: Callable[[VT, VT], VT], value: VT, event: Optional[EventT] = None - ) -> "WindowSetT": - ... + ) -> "WindowSetT": ... @abc.abstractmethod - def value(self, event: Optional[EventT] = None) -> VT: - ... + def value(self, event: Optional[EventT] = None) -> VT: ... @abc.abstractmethod - def current(self, event: Optional[EventT] = None) -> VT: - ... + def current(self, event: Optional[EventT] = None) -> VT: ... @abc.abstractmethod - def now(self) -> VT: - ... + def now(self) -> VT: ... @abc.abstractmethod - def delta(self, d: Seconds, event: Optional[EventT] = None) -> VT: - ... + def delta(self, d: Seconds, event: Optional[EventT] = None) -> VT: ... @abc.abstractmethod - def __iadd__(self, other: VT) -> "WindowSetT": - ... + def __iadd__(self, other: VT) -> "WindowSetT": ... @abc.abstractmethod - def __isub__(self, other: VT) -> "WindowSetT": - ... + def __isub__(self, other: VT) -> "WindowSetT": ... @abc.abstractmethod - def __imul__(self, other: VT) -> "WindowSetT": - ... + def __imul__(self, other: VT) -> "WindowSetT": ... @abc.abstractmethod - def __itruediv__(self, other: VT) -> "WindowSetT": - ... + def __itruediv__(self, other: VT) -> "WindowSetT": ... @abc.abstractmethod - def __ifloordiv__(self, other: VT) -> "WindowSetT": - ... + def __ifloordiv__(self, other: VT) -> "WindowSetT": ... @abc.abstractmethod - def __imod__(self, other: VT) -> "WindowSetT": - ... + def __imod__(self, other: VT) -> "WindowSetT": ... @abc.abstractmethod - def __ipow__(self, other: VT) -> "WindowSetT": - ... + def __ipow__(self, other: VT) -> "WindowSetT": ... @abc.abstractmethod - def __ilshift__(self, other: VT) -> "WindowSetT": - ... + def __ilshift__(self, other: VT) -> "WindowSetT": ... @abc.abstractmethod - def __irshift__(self, other: VT) -> "WindowSetT": - ... + def __irshift__(self, other: VT) -> "WindowSetT": ... @abc.abstractmethod - def __iand__(self, other: VT) -> "WindowSetT": - ... + def __iand__(self, other: VT) -> "WindowSetT": ... @abc.abstractmethod - def __ixor__(self, other: VT) -> "WindowSetT": - ... + def __ixor__(self, other: VT) -> "WindowSetT": ... @abc.abstractmethod - def __ior__(self, other: VT) -> "WindowSetT": - ... + def __ior__(self, other: VT) -> "WindowSetT": ... class WindowedItemsViewT(ItemsView): @abc.abstractmethod def __init__( self, mapping: "WindowWrapperT", event: Optional[EventT] = None - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def __iter__(self) -> Iterator[Tuple[Any, Any]]: - ... + def __iter__(self) -> Iterator[Tuple[Any, Any]]: ... @abc.abstractmethod - def now(self) -> Iterator[Tuple[Any, Any]]: - ... + def now(self) -> Iterator[Tuple[Any, Any]]: ... @abc.abstractmethod - def current(self, event: Optional[EventT] = None) -> Iterator[Tuple[Any, Any]]: - ... + def current(self, event: Optional[EventT] = None) -> Iterator[Tuple[Any, Any]]: ... @abc.abstractmethod def delta( self, d: Seconds, event: Optional[EventT] = None - ) -> Iterator[Tuple[Any, Any]]: - ... + ) -> Iterator[Tuple[Any, Any]]: ... class WindowedValuesViewT(ValuesView): @abc.abstractmethod def __init__( self, mapping: "WindowWrapperT", event: Optional[EventT] = None - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def __iter__(self) -> Iterator[Any]: - ... + def __iter__(self) -> Iterator[Any]: ... @abc.abstractmethod - def now(self) -> Iterator[Any]: - ... + def now(self) -> Iterator[Any]: ... @abc.abstractmethod - def current(self, event: Optional[EventT] = None) -> Iterator[Any]: - ... + def current(self, event: Optional[EventT] = None) -> Iterator[Any]: ... @abc.abstractmethod - def delta(self, d: Seconds, event: Optional[EventT] = None) -> Iterator[Any]: - ... + def delta(self, d: Seconds, event: Optional[EventT] = None) -> Iterator[Any]: ... class WindowWrapperT(MutableMapping): @@ -465,58 +395,44 @@ def __init__( relative_to: RelativeArg = None, key_index: bool = False, key_index_table: Optional[TableT] = None, - ) -> None: - ... + ) -> None: ... @property @abc.abstractmethod - def name(self) -> str: - ... + def name(self) -> str: ... @abc.abstractmethod - def clone(self, relative_to: RelativeArg) -> "WindowWrapperT": - ... + def clone(self, relative_to: RelativeArg) -> "WindowWrapperT": ... @abc.abstractmethod - def relative_to_now(self) -> "WindowWrapperT": - ... + def relative_to_now(self) -> "WindowWrapperT": ... @abc.abstractmethod - def relative_to_field(self, field: _FieldDescriptorT) -> "WindowWrapperT": - ... + def relative_to_field(self, field: _FieldDescriptorT) -> "WindowWrapperT": ... @abc.abstractmethod - def relative_to_stream(self) -> "WindowWrapperT": - ... + def relative_to_stream(self) -> "WindowWrapperT": ... @abc.abstractmethod - def get_timestamp(self, event: Optional[EventT] = None) -> float: - ... + def get_timestamp(self, event: Optional[EventT] = None) -> float: ... @abc.abstractmethod - def __getitem__(self, key: Any) -> WindowSetT: - ... + def __getitem__(self, key: Any) -> WindowSetT: ... @abc.abstractmethod - def keys(self) -> KeysView: - ... + def keys(self) -> KeysView: ... @abc.abstractmethod - def on_set_key(self, key: Any, value: Any) -> None: - ... + def on_set_key(self, key: Any, value: Any) -> None: ... @abc.abstractmethod - def on_del_key(self, key: Any) -> None: - ... + def on_del_key(self, key: Any) -> None: ... @abc.abstractmethod - def as_ansitable(self, **kwargs: Any) -> str: - ... + def as_ansitable(self, **kwargs: Any) -> str: ... @property - def get_relative_timestamp(self) -> Optional[RelativeHandler]: - ... + def get_relative_timestamp(self) -> Optional[RelativeHandler]: ... @get_relative_timestamp.setter - def get_relative_timestamp(self, relative_to: RelativeArg) -> None: - ... + def get_relative_timestamp(self, relative_to: RelativeArg) -> None: ... diff --git a/faust/types/topics.py b/faust/types/topics.py index 9250747eb..09d52d563 100644 --- a/faust/types/topics.py +++ b/faust/types/topics.py @@ -16,14 +16,11 @@ from .serializers import SchemaT as _SchemaT else: - class _AppT: - ... # noqa + class _AppT: ... # noqa - class _ModelArg: - ... # noqa + class _ModelArg: ... # noqa - class _SchemaT: - ... # noqa + class _SchemaT: ... # noqa __all__ = ["TopicT"] @@ -89,30 +86,24 @@ def __init__( allow_empty: bool = False, has_prefix: bool = False, loop: Optional[asyncio.AbstractEventLoop] = None, - ) -> None: - ... + ) -> None: ... @property @abc.abstractmethod - def pattern(self) -> Optional[Pattern]: - ... + def pattern(self) -> Optional[Pattern]: ... @pattern.setter - def pattern(self, pattern: Union[str, Pattern]) -> None: - ... + def pattern(self, pattern: Union[str, Pattern]) -> None: ... @property @abc.abstractmethod - def partitions(self) -> Optional[int]: - ... + def partitions(self) -> Optional[int]: ... @partitions.setter - def partitions(self, partitions: int) -> None: - ... + def partitions(self, partitions: int) -> None: ... @abc.abstractmethod - def derive(self, **kwargs: Any) -> ChannelT: - ... + def derive(self, **kwargs: Any) -> ChannelT: ... @abc.abstractmethod def derive_topic( @@ -131,5 +122,4 @@ def derive_topic( prefix: str = "", suffix: str = "", **kwargs: Any, - ) -> "TopicT": - ... + ) -> "TopicT": ... diff --git a/faust/types/transports.py b/faust/types/transports.py index db2030bc9..205c56e0f 100644 --- a/faust/types/transports.py +++ b/faust/types/transports.py @@ -35,8 +35,7 @@ from .app import AppT as _AppT else: - class _AppT: - ... # noqa + class _AppT: ... # noqa __all__ = [ @@ -83,25 +82,20 @@ class ProducerBufferT(ServiceT): pending: asyncio.Queue @abc.abstractmethod - def put(self, fut: FutureMessage) -> None: - ... + def put(self, fut: FutureMessage) -> None: ... @abc.abstractmethod - async def flush(self) -> None: - ... + async def flush(self) -> None: ... @abc.abstractmethod - async def flush_atmost(self, n: int) -> int: - ... + async def flush_atmost(self, n: int) -> int: ... @abc.abstractmethod - async def wait_until_ebb(self) -> None: - ... + async def wait_until_ebb(self) -> None: ... @property @abc.abstractmethod - def size(self) -> int: - ... + def size(self) -> int: ... class ProducerT(ServiceT): @@ -126,8 +120,7 @@ def __init__( transport: "TransportT", loop: Optional[asyncio.AbstractEventLoop] = None, **kwargs: Any, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod async def send( @@ -140,12 +133,10 @@ async def send( headers: Optional[HeadersArg], *, transactional_id: Optional[str] = None, - ) -> Awaitable[RecordMetadata]: - ... + ) -> Awaitable[RecordMetadata]: ... @abc.abstractmethod - def send_soon(self, fut: FutureMessage) -> None: - ... + def send_soon(self, fut: FutureMessage) -> None: ... @abc.abstractmethod async def send_and_wait( @@ -158,8 +149,7 @@ async def send_and_wait( headers: Optional[HeadersArg], *, transactional_id: Optional[str] = None, - ) -> RecordMetadata: - ... + ) -> RecordMetadata: ... @abc.abstractmethod async def create_topic( @@ -174,36 +164,28 @@ async def create_topic( compacting: Optional[bool] = None, deleting: Optional[bool] = None, ensure_created: bool = False, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def key_partition(self, topic: str, key: bytes) -> TP: - ... + def key_partition(self, topic: str, key: bytes) -> TP: ... @abc.abstractmethod - async def flush(self) -> None: - ... + async def flush(self) -> None: ... @abc.abstractmethod - async def begin_transaction(self, transactional_id: str) -> None: - ... + async def begin_transaction(self, transactional_id: str) -> None: ... @abc.abstractmethod - async def commit_transaction(self, transactional_id: str) -> None: - ... + async def commit_transaction(self, transactional_id: str) -> None: ... @abc.abstractmethod - async def abort_transaction(self, transactional_id: str) -> None: - ... + async def abort_transaction(self, transactional_id: str) -> None: ... @abc.abstractmethod - async def stop_transaction(self, transactional_id: str) -> None: - ... + async def stop_transaction(self, transactional_id: str) -> None: ... @abc.abstractmethod - async def maybe_begin_transaction(self, transactional_id: str) -> None: - ... + async def maybe_begin_transaction(self, transactional_id: str) -> None: ... @abc.abstractmethod async def commit_transactions( @@ -211,12 +193,10 @@ async def commit_transactions( tid_to_offset_map: Mapping[str, Mapping[TP, int]], group_id: str, start_new_transaction: bool = True, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def supports_headers(self) -> bool: - ... + def supports_headers(self) -> bool: ... # Probably this has to go because Transactions are supported in aiokafka @@ -233,24 +213,20 @@ def __init__( consumer: "ConsumerT", producer: "ProducerT", **kwargs: Any, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - async def on_partitions_revoked(self, revoked: Set[TP]) -> None: - ... + async def on_partitions_revoked(self, revoked: Set[TP]) -> None: ... @abc.abstractmethod async def on_rebalance( self, assigned: Set[TP], revoked: Set[TP], newly_assigned: Set[TP] - ) -> None: - ... + ) -> None: ... @abc.abstractmethod async def commit( self, offsets: Mapping[TP, int], start_new_transaction: bool = True - ) -> bool: - ... + ) -> bool: ... async def begin_transaction(self, transactional_id: str) -> None: raise NotImplementedError() @@ -278,12 +254,10 @@ async def commit_transactions( class SchedulingStrategyT: @abc.abstractmethod - def __init__(self) -> None: - ... + def __init__(self) -> None: ... @abc.abstractmethod - def iterate(self, records: Mapping[TP, List]) -> Iterator[Tuple[TP, Any]]: - ... + def iterate(self, records: Mapping[TP, List]) -> Iterator[Tuple[TP, Any]]: ... class ConsumerT(ServiceT): @@ -333,118 +307,91 @@ async def create_topic( compacting: Optional[bool] = None, deleting: Optional[bool] = None, ensure_created: bool = False, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - async def subscribe(self, topics: Iterable[str]) -> None: - ... + async def subscribe(self, topics: Iterable[str]) -> None: ... @abc.abstractmethod @no_type_check - async def getmany(self, timeout: float) -> AsyncIterator[Tuple[TP, Message]]: - ... + async def getmany(self, timeout: float) -> AsyncIterator[Tuple[TP, Message]]: ... @abc.abstractmethod - def track_message(self, message: Message) -> None: - ... + def track_message(self, message: Message) -> None: ... @abc.abstractmethod - async def perform_seek(self) -> None: - ... + async def perform_seek(self) -> None: ... @abc.abstractmethod - def ack(self, message: Message) -> bool: - ... + def ack(self, message: Message) -> bool: ... @abc.abstractmethod - async def wait_empty(self) -> None: - ... + async def wait_empty(self) -> None: ... @abc.abstractmethod - def assignment(self) -> Set[TP]: - ... + def assignment(self) -> Set[TP]: ... @abc.abstractmethod - def highwater(self, tp: TP) -> int: - ... + def highwater(self, tp: TP) -> int: ... @abc.abstractmethod - def stop_flow(self) -> None: - ... + def stop_flow(self) -> None: ... @abc.abstractmethod - def resume_flow(self) -> None: - ... + def resume_flow(self) -> None: ... @abc.abstractmethod - def pause_partitions(self, tps: Iterable[TP]) -> None: - ... + def pause_partitions(self, tps: Iterable[TP]) -> None: ... @abc.abstractmethod - def resume_partitions(self, tps: Iterable[TP]) -> None: - ... + def resume_partitions(self, tps: Iterable[TP]) -> None: ... @abc.abstractmethod - async def position(self, tp: TP) -> Optional[int]: - ... + async def position(self, tp: TP) -> Optional[int]: ... @abc.abstractmethod - async def seek(self, partition: TP, offset: int) -> None: - ... + async def seek(self, partition: TP, offset: int) -> None: ... @abc.abstractmethod - async def seek_wait(self, partitions: Mapping[TP, int]) -> None: - ... + async def seek_wait(self, partitions: Mapping[TP, int]) -> None: ... @abc.abstractmethod async def commit( self, topics: TPorTopicSet = None, start_new_transaction: bool = True - ) -> bool: - ... + ) -> bool: ... @abc.abstractmethod - async def on_task_error(self, exc: BaseException) -> None: - ... + async def on_task_error(self, exc: BaseException) -> None: ... @abc.abstractmethod - async def earliest_offsets(self, *partitions: TP) -> Mapping[TP, int]: - ... + async def earliest_offsets(self, *partitions: TP) -> Mapping[TP, int]: ... @abc.abstractmethod - async def highwaters(self, *partitions: TP) -> Mapping[TP, int]: - ... + async def highwaters(self, *partitions: TP) -> Mapping[TP, int]: ... @abc.abstractmethod - def topic_partitions(self, topic: str) -> Optional[int]: - ... + def topic_partitions(self, topic: str) -> Optional[int]: ... @abc.abstractmethod def key_partition( self, topic: str, key: Optional[bytes], partition: Optional[int] = None - ) -> Optional[int]: - ... + ) -> Optional[int]: ... @abc.abstractmethod - def close(self) -> None: - ... + def close(self) -> None: ... @abc.abstractmethod - def verify_recovery_event_path(self, now: float, tp: TP) -> None: - ... + def verify_recovery_event_path(self, now: float, tp: TP) -> None: ... @property @abc.abstractmethod - def unacked(self) -> Set[Message]: - ... + def unacked(self) -> Set[Message]: ... @abc.abstractmethod - def on_buffer_full(self, tp: TP) -> None: - ... + def on_buffer_full(self, tp: TP) -> None: ... @abc.abstractmethod - def on_buffer_drop(self, tp: TP) -> None: - ... + def on_buffer_drop(self, tp: TP) -> None: ... class ConductorT(ServiceT, MutableSet[TopicT]): @@ -458,33 +405,26 @@ def __init__(self, app: _AppT, **kwargs: Any) -> None: self.on_message: ConsumerCallback @abc.abstractmethod - async def on_client_only_start(self) -> None: - ... + async def on_client_only_start(self) -> None: ... @abc.abstractmethod - def acks_enabled_for(self, topic: str) -> bool: - ... + def acks_enabled_for(self, topic: str) -> bool: ... @abc.abstractmethod - async def commit(self, topics: TPorTopicSet) -> bool: - ... + async def commit(self, topics: TPorTopicSet) -> bool: ... @abc.abstractmethod - async def wait_for_subscriptions(self) -> None: - ... + async def wait_for_subscriptions(self) -> None: ... @abc.abstractmethod - async def maybe_wait_for_subscriptions(self) -> None: - ... + async def maybe_wait_for_subscriptions(self) -> None: ... @abc.abstractmethod - async def on_partitions_assigned(self, assigned: Set[TP]) -> None: - ... + async def on_partitions_assigned(self, assigned: Set[TP]) -> None: ... @property @abc.abstractmethod - def acking_topics(self) -> Set[str]: - ... + def acking_topics(self) -> Set[str]: ... class TransportT(abc.ABC): @@ -521,17 +461,15 @@ def __init__( url: List[URL], app: _AppT, loop: Optional[asyncio.AbstractEventLoop] = None, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def create_consumer(self, callback: ConsumerCallback, **kwargs: Any) -> ConsumerT: - ... + def create_consumer( + self, callback: ConsumerCallback, **kwargs: Any + ) -> ConsumerT: ... @abc.abstractmethod - def create_producer(self, **kwargs: Any) -> ProducerT: - ... + def create_producer(self, **kwargs: Any) -> ProducerT: ... @abc.abstractmethod - def create_conductor(self, **kwargs: Any) -> ConductorT: - ... + def create_conductor(self, **kwargs: Any) -> ConductorT: ... diff --git a/faust/types/tuples.py b/faust/types/tuples.py index 73142370f..ba8fb940e 100644 --- a/faust/types/tuples.py +++ b/faust/types/tuples.py @@ -22,11 +22,9 @@ from .transports import ConsumerT as _ConsumerT else: - class _ChannelT: - ... # noqa + class _ChannelT: ... # noqa - class _ConsumerT: - ... # noqa + class _ConsumerT: ... # noqa __all__ = [ diff --git a/faust/types/web.py b/faust/types/web.py index 6027a4aa1..62bc32a42 100644 --- a/faust/types/web.py +++ b/faust/types/web.py @@ -24,20 +24,15 @@ from faust.web.views import View else: - class _AppT: - ... # noqa + class _AppT: ... # noqa - class Request: - ... # noqa + class Request: ... # noqa - class Response: - ... # noqa + class Response: ... # noqa - class Web: - ... # noqa + class Web: ... # noqa - class View: - ... # noqa + class View: ... # noqa __all__ = [ @@ -101,22 +96,18 @@ class CacheBackendT(ServiceT): @abc.abstractmethod def __init__( self, app: _AppT, url: Union[URL, str] = "memory://", **kwargs: Any - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - async def get(self, key: str) -> Optional[bytes]: - ... + async def get(self, key: str) -> Optional[bytes]: ... @abc.abstractmethod async def set( self, key: str, value: bytes, timeout: Optional[float] = None - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - async def delete(self, key: str) -> None: - ... + async def delete(self, key: str) -> None: ... class CacheT(abc.ABC): @@ -132,8 +123,7 @@ def __init__( key_prefix: Optional[str] = None, backend: Union[Type[CacheBackendT], str] = None, **kwargs: Any, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod def view( @@ -142,8 +132,7 @@ def view( include_headers: bool = False, key_prefix: Optional[str] = None, **kwargs: Any, - ) -> Callable[[Callable], Callable]: - ... + ) -> Callable[[Callable], Callable]: ... class BlueprintT(abc.ABC): @@ -157,14 +146,12 @@ def cache( include_headers: bool = False, key_prefix: Optional[str] = None, backend: Union[Type[CacheBackendT], str] = None, - ) -> CacheT: - ... + ) -> CacheT: ... @abc.abstractmethod def route( self, uri: str, *, name: Optional[str] = None, base: Type[View] = View - ) -> RouteDecoratorRet: - ... + ) -> RouteDecoratorRet: ... @abc.abstractmethod def static( @@ -173,17 +160,13 @@ def static( file_or_directory: Union[str, Path], *, name: Optional[str] = None, - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - def register(self, app: _AppT, *, url_prefix: Optional[str] = None) -> None: - ... + def register(self, app: _AppT, *, url_prefix: Optional[str] = None) -> None: ... @abc.abstractmethod - def init_webserver(self, web: Web) -> None: - ... + def init_webserver(self, web: Web) -> None: ... @abc.abstractmethod - def on_webserver_init(self, web: Web) -> None: - ... + def on_webserver_init(self, web: Web) -> None: ... diff --git a/faust/types/windows.py b/faust/types/windows.py index 94b9f7bb1..5f5457f44 100644 --- a/faust/types/windows.py +++ b/faust/types/windows.py @@ -1,4 +1,5 @@ """Types related to windowing.""" + import abc from datetime import timezone from typing import List, Optional, Tuple @@ -24,21 +25,16 @@ class WindowT(abc.ABC): tz: Optional[timezone] = None @abc.abstractmethod - def ranges(self, timestamp: float) -> List[WindowRange]: - ... + def ranges(self, timestamp: float) -> List[WindowRange]: ... @abc.abstractmethod - def stale(self, timestamp: float, latest_timestamp: float) -> bool: - ... + def stale(self, timestamp: float, latest_timestamp: float) -> bool: ... @abc.abstractmethod - def current(self, timestamp: float) -> WindowRange: - ... + def current(self, timestamp: float) -> WindowRange: ... @abc.abstractmethod - def earliest(self, timestamp: float) -> WindowRange: - ... + def earliest(self, timestamp: float) -> WindowRange: ... @abc.abstractmethod - def delta(self, timestamp: float, d: Seconds) -> WindowRange: - ... + def delta(self, timestamp: float, d: Seconds) -> WindowRange: ... diff --git a/faust/utils/__init__.py b/faust/utils/__init__.py index 132e8edfa..e376096f1 100644 --- a/faust/utils/__init__.py +++ b/faust/utils/__init__.py @@ -1,4 +1,5 @@ """Utilities.""" + from uuid import uuid4 __all__ = ["uuid"] diff --git a/faust/utils/_iso8601_python.py b/faust/utils/_iso8601_python.py index 3732abd2b..c63390bd3 100644 --- a/faust/utils/_iso8601_python.py +++ b/faust/utils/_iso8601_python.py @@ -32,6 +32,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ + import re from datetime import datetime, timedelta, timezone, tzinfo from typing import Mapping, Match, Optional, Pattern, cast diff --git a/faust/utils/agent_stopper.py b/faust/utils/agent_stopper.py index 820ae4d20..e5db7322b 100644 --- a/faust/utils/agent_stopper.py +++ b/faust/utils/agent_stopper.py @@ -1,4 +1,5 @@ """agent_stopper for Faust when app fails""" + import logging import traceback diff --git a/faust/utils/codegen.py b/faust/utils/codegen.py index 1999eb777..ef3c9f93f 100644 --- a/faust/utils/codegen.py +++ b/faust/utils/codegen.py @@ -1,4 +1,5 @@ """Utilities for generating code at runtime.""" + from typing import Any, Callable, Dict, List, Mapping, Tuple, cast __all__ = [ diff --git a/faust/utils/cron.py b/faust/utils/cron.py index f1b583981..ed96191f2 100644 --- a/faust/utils/cron.py +++ b/faust/utils/cron.py @@ -1,4 +1,5 @@ """Crontab Utilities.""" + import time from datetime import datetime, tzinfo diff --git a/faust/utils/functional.py b/faust/utils/functional.py index 729630ea3..98d4ad764 100644 --- a/faust/utils/functional.py +++ b/faust/utils/functional.py @@ -1,4 +1,5 @@ """Functional utilities.""" + from functools import reduce from itertools import groupby from typing import Iterable, Iterator, Mapping, Sequence, Tuple, TypeVar diff --git a/faust/utils/iso8601.py b/faust/utils/iso8601.py index 69560714f..b8fe293a0 100644 --- a/faust/utils/iso8601.py +++ b/faust/utils/iso8601.py @@ -1,4 +1,5 @@ """Parsing ISO-8601 string and converting to :class:`~datetime.datetime`.""" + try: # pragma: no cover import ciso8601 except ImportError: # pragma: no cover diff --git a/faust/utils/json.py b/faust/utils/json.py index 66eb5a0ca..8fb13a386 100644 --- a/faust/utils/json.py +++ b/faust/utils/json.py @@ -1,4 +1,5 @@ """JSON utilities.""" + import datetime import enum import typing diff --git a/faust/utils/kafka/protocol/admin.py b/faust/utils/kafka/protocol/admin.py index 3e418e960..f2be80d9c 100644 --- a/faust/utils/kafka/protocol/admin.py +++ b/faust/utils/kafka/protocol/admin.py @@ -1,4 +1,5 @@ """Admin related Kafka protocol extensions.""" + from aiokafka.protocol import types from .api import Request, Response diff --git a/faust/utils/kafka/protocol/api.py b/faust/utils/kafka/protocol/api.py index 523d9ef0f..74af0f466 100644 --- a/faust/utils/kafka/protocol/api.py +++ b/faust/utils/kafka/protocol/api.py @@ -1,4 +1,5 @@ """Kafka protocol extensions.""" + # pragma: no cover import abc from typing import Type diff --git a/faust/utils/platforms.py b/faust/utils/platforms.py index a1d0ec51e..506d583b5 100644 --- a/faust/utils/platforms.py +++ b/faust/utils/platforms.py @@ -1,4 +1,5 @@ """Platform/OS utilities.""" + import platform import subprocess # nosec: B404 from typing import Optional diff --git a/faust/utils/terminal/__init__.py b/faust/utils/terminal/__init__.py index ea02226bf..7dd4ad205 100644 --- a/faust/utils/terminal/__init__.py +++ b/faust/utils/terminal/__init__.py @@ -1,4 +1,5 @@ """Terminal utilities.""" + from mode.utils.compat import isatty from .spinners import Spinner, SpinnerHandler diff --git a/faust/utils/terminal/spinners.py b/faust/utils/terminal/spinners.py index 9a49c73b4..f210659f0 100644 --- a/faust/utils/terminal/spinners.py +++ b/faust/utils/terminal/spinners.py @@ -1,4 +1,5 @@ """Terminal progress bar spinners.""" + import atexit import logging import random diff --git a/faust/utils/terminal/tables.py b/faust/utils/terminal/tables.py index e37b98f3a..dc0dacf26 100644 --- a/faust/utils/terminal/tables.py +++ b/faust/utils/terminal/tables.py @@ -1,4 +1,5 @@ """Using :pypi:`terminaltables` to draw ANSI tables.""" + import sys from operator import itemgetter from typing import ( diff --git a/faust/utils/tracing.py b/faust/utils/tracing.py index f942f6ba3..9546aef9f 100644 --- a/faust/utils/tracing.py +++ b/faust/utils/tracing.py @@ -1,4 +1,5 @@ """OpenTracing utilities.""" + import asyncio import sys import typing diff --git a/faust/utils/urls.py b/faust/utils/urls.py index cad37c863..131a6c3f0 100644 --- a/faust/utils/urls.py +++ b/faust/utils/urls.py @@ -1,4 +1,5 @@ """URL utilities - Working with URLs.""" + from typing import List, Optional, Union from yarl import URL diff --git a/faust/utils/venusian.py b/faust/utils/venusian.py index e8f7e25b2..38397c4a8 100644 --- a/faust/utils/venusian.py +++ b/faust/utils/venusian.py @@ -3,6 +3,7 @@ We define our own interface so we don't have to specify the callback argument. """ + from typing import Any, Callable import venusian @@ -26,5 +27,4 @@ def attach( return _attach(fun, callback, category=category, **kwargs) -def _on_found(scanner: venusian.Scanner, name: str, obj: Any) -> None: - ... +def _on_found(scanner: venusian.Scanner, name: str, obj: Any) -> None: ... diff --git a/faust/web/__init__.py b/faust/web/__init__.py index 3d6569027..9e4902307 100644 --- a/faust/web/__init__.py +++ b/faust/web/__init__.py @@ -1,4 +1,5 @@ """Faust Web.""" + from faust.types.web import ResourceOptions from .base import Request, Response, Web diff --git a/faust/web/apps/graph.py b/faust/web/apps/graph.py index 01949bb17..4527101a2 100644 --- a/faust/web/apps/graph.py +++ b/faust/web/apps/graph.py @@ -1,4 +1,5 @@ """Web endpoint showing graph of running :pypi:`mode` services.""" + import io from faust import web diff --git a/faust/web/apps/production_index.py b/faust/web/apps/production_index.py index 7d67ef6ba..4c27be29f 100644 --- a/faust/web/apps/production_index.py +++ b/faust/web/apps/production_index.py @@ -1,4 +1,5 @@ """HTTP endpoint showing statistics from the Faust monitor.""" + from typing import List, MutableMapping from faust import web diff --git a/faust/web/apps/router.py b/faust/web/apps/router.py index d1897cbd2..a9899b0d2 100644 --- a/faust/web/apps/router.py +++ b/faust/web/apps/router.py @@ -1,4 +1,5 @@ """HTTP endpoint showing partition routing destinations.""" + from faust import web from faust.web.exceptions import ServiceUnavailable diff --git a/faust/web/apps/stats.py b/faust/web/apps/stats.py index b178912f0..a7974ab13 100644 --- a/faust/web/apps/stats.py +++ b/faust/web/apps/stats.py @@ -1,4 +1,5 @@ """HTTP endpoint showing statistics from the Faust monitor.""" + from collections import defaultdict from typing import List, MutableMapping, Set diff --git a/faust/web/apps/tables.py b/faust/web/apps/tables.py index 654ecc6dd..32344ddcb 100644 --- a/faust/web/apps/tables.py +++ b/faust/web/apps/tables.py @@ -1,4 +1,5 @@ """HTTP endpoint showing partition routing destinations.""" + from typing import Any, Mapping, cast from faust import web diff --git a/faust/web/base.py b/faust/web/base.py index 809b1a065..f62fb2955 100644 --- a/faust/web/base.py +++ b/faust/web/base.py @@ -1,4 +1,5 @@ """Base interface for Web server and views.""" + import abc import socket from datetime import datetime diff --git a/faust/web/blueprints.py b/faust/web/blueprints.py index ed24689d9..7b69c58ec 100644 --- a/faust/web/blueprints.py +++ b/faust/web/blueprints.py @@ -51,6 +51,7 @@ async def get(self, Blueprints can be registered to multiple apps at the same time. """ + from pathlib import Path from typing import List, Mapping, NamedTuple, Optional, Type, Union diff --git a/faust/web/cache/__init__.py b/faust/web/cache/__init__.py index e23ab3e66..864aa56da 100644 --- a/faust/web/cache/__init__.py +++ b/faust/web/cache/__init__.py @@ -1,4 +1,5 @@ """Caching.""" + from .cache import Cache __all__ = ["Cache"] diff --git a/faust/web/cache/backends/__init__.py b/faust/web/cache/backends/__init__.py index 3d5260977..a12e92915 100644 --- a/faust/web/cache/backends/__init__.py +++ b/faust/web/cache/backends/__init__.py @@ -1,4 +1,5 @@ """Cache backend registry.""" + from typing import Type from mode.utils.imports import FactoryMapping diff --git a/faust/web/cache/backends/base.py b/faust/web/cache/backends/base.py index 5cd18195d..06b87ec8e 100644 --- a/faust/web/cache/backends/base.py +++ b/faust/web/cache/backends/base.py @@ -1,4 +1,5 @@ """Cache backend - base implementation.""" + import abc from typing import Any, ClassVar, Optional, Tuple, Type, Union @@ -39,18 +40,15 @@ def __init__( Service.__init__(self, **kwargs) @abc.abstractmethod - async def _get(self, key: str) -> Optional[bytes]: - ... + async def _get(self, key: str) -> Optional[bytes]: ... @abc.abstractmethod async def _set( self, key: str, value: bytes, timeout: Optional[float] = None - ) -> None: - ... + ) -> None: ... @abc.abstractmethod - async def _delete(self, key: str) -> None: - ... + async def _delete(self, key: str) -> None: ... async def get(self, key: str) -> Optional[bytes]: """Get cached-value by key.""" diff --git a/faust/web/cache/backends/memory.py b/faust/web/cache/backends/memory.py index 94b8be391..4c34f0588 100644 --- a/faust/web/cache/backends/memory.py +++ b/faust/web/cache/backends/memory.py @@ -1,4 +1,5 @@ """In-memory cache backend.""" + import sys import time from contextlib import suppress diff --git a/faust/web/cache/backends/redis.py b/faust/web/cache/backends/redis.py index 3e664084c..3c27c1f26 100644 --- a/faust/web/cache/backends/redis.py +++ b/faust/web/cache/backends/redis.py @@ -1,4 +1,5 @@ """Redis cache backend.""" + import socket import typing from enum import Enum @@ -23,8 +24,7 @@ from aredis import StrictRedis as _RedisClientT else: - class _RedisClientT: - ... # noqa + class _RedisClientT: ... # noqa class RedisScheme(Enum): diff --git a/faust/web/cache/cache.py b/faust/web/cache/cache.py index 00aaacfdf..c2de50b75 100644 --- a/faust/web/cache/cache.py +++ b/faust/web/cache/cache.py @@ -1,4 +1,5 @@ """Cache interface.""" + import hashlib from contextlib import suppress from functools import wraps diff --git a/faust/web/drivers/__init__.py b/faust/web/drivers/__init__.py index 0086a7253..b3e2e2e4a 100644 --- a/faust/web/drivers/__init__.py +++ b/faust/web/drivers/__init__.py @@ -1,4 +1,5 @@ """Web server driver registry.""" + from typing import Type from mode.utils.imports import FactoryMapping diff --git a/faust/web/drivers/aiohttp.py b/faust/web/drivers/aiohttp.py index 389637d75..16c0d4fde 100644 --- a/faust/web/drivers/aiohttp.py +++ b/faust/web/drivers/aiohttp.py @@ -1,4 +1,5 @@ """Web driver using :pypi:`aiohttp`.""" + from pathlib import Path from typing import Any, Callable, Mapping, MutableMapping, Optional, Union, cast diff --git a/faust/web/exceptions.py b/faust/web/exceptions.py index e103d3695..b8f0db86a 100644 --- a/faust/web/exceptions.py +++ b/faust/web/exceptions.py @@ -1,4 +1,5 @@ """HTTP and related errors.""" + import http from typing import Any, Dict, Optional, cast diff --git a/faust/web/views.py b/faust/web/views.py index cad55413d..c4651a492 100644 --- a/faust/web/views.py +++ b/faust/web/views.py @@ -1,4 +1,5 @@ """Class-based views.""" + from functools import wraps from typing import ( Any, diff --git a/faust/windows.py b/faust/windows.py index 6e956f34e..d0944d0eb 100644 --- a/faust/windows.py +++ b/faust/windows.py @@ -1,4 +1,5 @@ """Window Types.""" + import os import typing from math import floor diff --git a/faust/worker.py b/faust/worker.py index 1cdf65444..06533b77e 100644 --- a/faust/worker.py +++ b/faust/worker.py @@ -5,6 +5,7 @@ See Also: :ref:`app-starting`: for more information. """ + import asyncio import logging import os @@ -29,8 +30,7 @@ from setproctitle import setproctitle except ImportError: # pragma: no cover - def setproctitle(title: str) -> None: - ... # noqa + def setproctitle(title: str) -> None: ... # noqa __all__ = ["Worker"] diff --git a/setup.cfg b/setup.cfg index bb412d374..f80025682 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [flake8] -ignore = W503, E203, E231, E225, B305 +ignore = W503, E203, E231, E225, B305, E701, E704 max-line-length = 88 [mypy-tests.*] diff --git a/tests/conftest.py b/tests/conftest.py index 0cd0c4b36..4ce891806 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -16,8 +16,7 @@ sentinel = object() -class DirtyTest(Exception): - ... +class DirtyTest(Exception): ... @pytest.fixture() diff --git a/tests/functional/agents/helpers.py b/tests/functional/agents/helpers.py index ca70c6955..8106873b9 100644 --- a/tests/functional/agents/helpers.py +++ b/tests/functional/agents/helpers.py @@ -97,8 +97,7 @@ async def _wait_for_success(self) -> None: async def assert_success(self) -> None: assert self.processed_total == self.num_messages - async def on_agent_event(self, stream: StreamT, event: EventT) -> None: - ... + async def on_agent_event(self, stream: StreamT, event: EventT) -> None: ... async def process(self, stream: StreamT[bytes]) -> None: self.agent_started.set() diff --git a/tests/functional/test_app.py b/tests/functional/test_app.py index 6c1b7ad57..94ebe8b86 100644 --- a/tests/functional/test_app.py +++ b/tests/functional/test_app.py @@ -35,8 +35,7 @@ TABLEDIR = Path("/var/faust/") -class OtherSchedulingStrategy(DefaultSchedulingStrategy): - ... +class OtherSchedulingStrategy(DefaultSchedulingStrategy): ... def _dummy_partitioner(a, b, c): diff --git a/tests/functional/test_models.py b/tests/functional/test_models.py index 97a655a28..816cb2abd 100644 --- a/tests/functional/test_models.py +++ b/tests/functional/test_models.py @@ -406,8 +406,9 @@ def __json__(self): def __repr__(self): return f"<{type(self).__name__}: {self.value}>" - class CanFooModel(Record, abstract=True, coercions={Foo: Foo}, serializer="json"): - ... + class CanFooModel( + Record, abstract=True, coercions={Foo: Foo}, serializer="json" + ): ... class IsFoo(CanFooModel, serializer="json"): foo: Foo @@ -1118,8 +1119,7 @@ class BaseX(Record): def test_abstract_model_repr(): - class MyBase(faust.Record, abstract=True): - ... + class MyBase(faust.Record, abstract=True): ... assert MyBase.__is_abstract__ with pytest.raises(NotImplementedError): diff --git a/tests/functional/web/test_cache.py b/tests/functional/web/test_cache.py index 92044312a..f91665af8 100644 --- a/tests/functional/web/test_cache.py +++ b/tests/functional/web/test_cache.py @@ -49,8 +49,7 @@ async def get(self, request): @blueprint.route("/C", name="c") -class CCachedView(ACachedView): - ... +class CCachedView(ACachedView): ... @blueprint.route("/D/", name="d") diff --git a/tests/unit/agents/test_agent.py b/tests/unit/agents/test_agent.py index e58d876ee..54f881f68 100644 --- a/tests/unit/agents/test_agent.py +++ b/tests/unit/agents/test_agent.py @@ -203,29 +203,25 @@ def test_init_schema_and_channel(self, *, app): with pytest.raises(AssertionError): @app.agent(app.topic("foo"), schema=faust.Schema(key_type=bytes)) - async def foo(): - ... + async def foo(): ... def test_init_key_type_and_channel(self, *, app): with pytest.raises(AssertionError): @app.agent(app.topic("foo"), key_type=bytes) - async def foo(): - ... + async def foo(): ... def test_init_value_type_and_channel(self, *, app): with pytest.raises(AssertionError): @app.agent(app.topic("foo"), value_type=bytes) - async def foo(): - ... + async def foo(): ... def test_isolated_partitions_cannot_have_concurrency(self, *, app): with pytest.raises(ImproperlyConfigured): @app.agent(isolated_partitions=True, concurrency=100) - async def foo(): - ... + async def foo(): ... def test_agent_call_reuse_stream(self, *, agent, app): stream = app.stream("foo") diff --git a/tests/unit/app/test_base.py b/tests/unit/app/test_base.py index 057668f55..c5405543b 100644 --- a/tests/unit/app/test_base.py +++ b/tests/unit/app/test_base.py @@ -603,8 +603,7 @@ def test_agent(self, *, app): with patch("faust.app.base.venusian") as venusian: @app.agent() - async def foo(stream): - ... + async def foo(stream): ... assert foo.name assert app.agents[foo.name] is foo @@ -639,8 +638,7 @@ def test_task(self, *, app): with patch("faust.app.base.venusian") as venusian: @app.task - async def foo(): - ... + async def foo(): ... venusian.attach.assert_called_once_with(foo, category=SCAN_TASK) assert foo in app._app_tasks @@ -796,8 +794,7 @@ def on_sleep(seconds, **kwargs): def test_service(self, *, app): @app.service - class Foo(Service): - ... + class Foo(Service): ... assert Foo in app._extra_services @@ -831,8 +828,7 @@ def test_page(self, *, app): with patch("faust.app.base.venusian") as venusian: @app.page("/foo") - async def view(self, request): - ... + async def view(self, request): ... assert "/foo" in app.web.views @@ -853,8 +849,7 @@ def test_page__with_cors_options(self, *, app): ), }, ) - async def view(self, request): - ... + async def view(self, request): ... assert "/foo" in app.web.views @@ -864,8 +859,7 @@ def test_page__view_class_but_not_view(self, *, app): with pytest.raises(TypeError): @app.page("/foo") - class Foo: - ... + class Foo: ... @pytest.mark.asyncio async def test_table_route__query_param(self, *, app): @@ -930,8 +924,7 @@ def test_table_route__compat_shard_param(self, *, app): with pytest.warns(DeprecationWarning): @app.table_route(table, shard_param="x") - async def view(self, request): - ... + async def view(self, request): ... def test_table_route__query_param_and_shard_param(self, *, app): table = app.Table("foo") @@ -939,16 +932,14 @@ def test_table_route__query_param_and_shard_param(self, *, app): with pytest.raises(TypeError): @app.table_route(table, query_param="q", shard_param="x") - async def view(self, request): - ... + async def view(self, request): ... def test_table_route__missing_param(self, *, app): table = app.Table("foo") with pytest.raises(TypeError): @app.table_route(table) - async def view(self, request): - ... + async def view(self, request): ... @pytest.mark.asyncio async def test_topic_route__query_param(self, *, app): @@ -1013,8 +1004,7 @@ def test_topic_route__compat_shard_param(self, *, app): with pytest.warns(DeprecationWarning): @app.topic_route(topic, shard_param="x") - async def view(self, request): - ... + async def view(self, request): ... def test_topic_route__query_param_and_shard_param(self, *, app): topic = app.topic("foo") @@ -1022,29 +1012,24 @@ def test_topic_route__query_param_and_shard_param(self, *, app): with pytest.raises(TypeError): @app.topic_route(topic, query_param="q", shard_param="x") - async def view(self, request): - ... + async def view(self, request): ... def test_topic_route__missing_param(self, *, app): topic = app.topic("foo") with pytest.raises(TypeError): @app.topic_route(topic) - async def view(self, request): - ... + async def view(self, request): ... def test_command(self, *, app): @app.command() - async def foo(): - ... + async def foo(): ... def test_command__with_base(self, *, app): - class MyBase(AppCommand): - ... + class MyBase(AppCommand): ... @app.command(base=MyBase) - async def foo(): - ... + async def foo(): ... assert issubclass(foo, MyBase) diff --git a/tests/unit/app/test_service.py b/tests/unit/app/test_service.py index 377e372e3..7348b5756 100644 --- a/tests/unit/app/test_service.py +++ b/tests/unit/app/test_service.py @@ -6,8 +6,7 @@ from tests.helpers import AsyncMock -class OtherService(Service): - ... +class OtherService(Service): ... class Test_AppService: diff --git a/tests/unit/cli/test_base.py b/tests/unit/cli/test_base.py index d2c1ac9d9..5fd3aeab0 100644 --- a/tests/unit/cli/test_base.py +++ b/tests/unit/cli/test_base.py @@ -650,9 +650,7 @@ def test_abbreviate_fqdn__no_origin(self, *, command, ctx): def test_from_handler_no_params(self, *, command): @command.from_handler() - async def takes_no_args(): - ... + async def takes_no_args(): ... @command.from_handler() - async def takes_self_arg(self): - ... + async def takes_self_arg(self): ... diff --git a/tests/unit/serializers/test_codecs.py b/tests/unit/serializers/test_codecs.py index 6abf80538..9e9aa5731 100644 --- a/tests/unit/serializers/test_codecs.py +++ b/tests/unit/serializers/test_codecs.py @@ -81,8 +81,7 @@ def test_get_codec(): def test_register(): try: - class MyCodec(Codec): - ... + class MyCodec(Codec): ... register("mine", MyCodec) assert get_codec("mine") is MyCodec diff --git a/tests/unit/stores/test_aerospike.py b/tests/unit/stores/test_aerospike.py index ebb0ee866..7f74d44c0 100644 --- a/tests/unit/stores/test_aerospike.py +++ b/tests/unit/stores/test_aerospike.py @@ -10,8 +10,7 @@ from aerospike.exception import RecordNotFound except ImportError: - class RecordNotFound(Exception): - ... + class RecordNotFound(Exception): ... m1 = MagicMock() m2 = MagicMock() diff --git a/tests/unit/stores/test_base.py b/tests/unit/stores/test_base.py index 160b19952..5f47fcb44 100644 --- a/tests/unit/stores/test_base.py +++ b/tests/unit/stores/test_base.py @@ -9,39 +9,30 @@ class MyStore(Store): - def __getitem__(self, key): - ... + def __getitem__(self, key): ... - def __setitem__(self, key, value): - ... + def __setitem__(self, key, value): ... - def __delitem__(self, key): - ... + def __delitem__(self, key): ... - def __iter__(self): - ... + def __iter__(self): ... - def __len__(self): - ... + def __len__(self): ... - def apply_changelog_batch(self, *args, **kwargs): - ... + def apply_changelog_batch(self, *args, **kwargs): ... - def reset_state(self): - ... + def reset_state(self): ... async def backup_partition( self, tp, flush: bool = True, purge: bool = False, keep: int = 1 - ) -> None: - ... + ) -> None: ... def restore_backup( self, tp, latest: bool = True, backup_id: int = 0, - ) -> None: - ... + ) -> None: ... class Test_Store: @@ -131,21 +122,18 @@ def _contains(self, key): def _clear(self): self.keep.clear() - def reset_state(self): - ... + def reset_state(self): ... async def backup_partition( self, tp, flush: bool = True, purge: bool = False, keep: int = 1 - ) -> None: - ... + ) -> None: ... def restore_backup( self, tp, latest: bool = True, backup_id: int = 0, - ) -> None: - ... + ) -> None: ... class Test_SerializedStore: diff --git a/tests/unit/transport/drivers/test_aiokafka.py b/tests/unit/transport/drivers/test_aiokafka.py index b524aac23..63a55d5d2 100644 --- a/tests/unit/transport/drivers/test_aiokafka.py +++ b/tests/unit/transport/drivers/test_aiokafka.py @@ -1288,8 +1288,7 @@ def assert_calls_thread(self, cthread, _consumer, method, *args, **kwargs): cthread.call_thread.assert_called_once_with(method, *args, **kwargs) -class MyPartitioner: - ... +class MyPartitioner: ... my_partitioner = MyPartitioner() diff --git a/tests/unit/transport/test_consumer.py b/tests/unit/transport/test_consumer.py index 89c33ae21..070066984 100644 --- a/tests/unit/transport/test_consumer.py +++ b/tests/unit/transport/test_consumer.py @@ -378,53 +378,39 @@ class MockedConsumerAbstractMethods: def assignment(self): return self.current_assignment - def position(self, *args, **kwargs): - ... + def position(self, *args, **kwargs): ... - async def create_topic(self, *args, **kwargs): - ... + async def create_topic(self, *args, **kwargs): ... - def earliest_offsets(self, *args, **kwargs): - ... + def earliest_offsets(self, *args, **kwargs): ... - def highwater(self, *args, **kwargs): - ... + def highwater(self, *args, **kwargs): ... - def highwaters(self, *args, **kwargs): - ... + def highwaters(self, *args, **kwargs): ... - async def _getmany(self, *args, **kwargs): - ... + async def _getmany(self, *args, **kwargs): ... - async def _seek(self, *args, **kwargs): - ... + async def _seek(self, *args, **kwargs): ... - def _to_message(self, *args, **kwargs): - ... + def _to_message(self, *args, **kwargs): ... async def seek_to_committed(self, *args, **kwargs): return {} - async def seek_wait(self, *args, **kwargs): - ... + async def seek_wait(self, *args, **kwargs): ... - async def subscribe(self, *args, **kwargs): - ... + async def subscribe(self, *args, **kwargs): ... - async def seek_to_beginning(self, *args, **kwargs): - ... + async def seek_to_beginning(self, *args, **kwargs): ... - async def _commit(self, offsets) -> bool: - ... + async def _commit(self, offsets) -> bool: ... - def topic_partitions(self, topic): - ... + def topic_partitions(self, topic): ... def _new_topicpartition(self, topic, partition) -> TP: return TP(topic, partition) - def key_partition(self, *args, **kwargs): - ... + def key_partition(self, *args, **kwargs): ... class MyConsumer(MockedConsumerAbstractMethods, Consumer): @@ -1168,32 +1154,24 @@ def test_close(self, *, consumer): class Test_ConsumerThread: class MyConsumerThread(MockedConsumerAbstractMethods, ConsumerThread): - def close(self): - ... + def close(self): ... async def getmany(self, *args, **kwargs): yield None, None - def pause_partitions(self, *args, **kwargs): - ... + def pause_partitions(self, *args, **kwargs): ... - def resume_partitions(self, *args, **kwargs): - ... + def resume_partitions(self, *args, **kwargs): ... - def stop_flow(self, *args, **kwargs): - ... + def stop_flow(self, *args, **kwargs): ... - def resume_flow(self, *args, **kwargs): - ... + def resume_flow(self, *args, **kwargs): ... - async def commit(self, *args, **kwargs): - ... + async def commit(self, *args, **kwargs): ... - async def perform_seek(self, *args, **kwargs): - ... + async def perform_seek(self, *args, **kwargs): ... - async def seek(self, *args, **kwargs): - ... + async def seek(self, *args, **kwargs): ... @pytest.fixture def consumer(self): diff --git a/tests/unit/web/test_base.py b/tests/unit/web/test_base.py index b38588440..fda2c595c 100644 --- a/tests/unit/web/test_base.py +++ b/tests/unit/web/test_base.py @@ -54,35 +54,25 @@ def test_apply(self, *, manager): class MyWeb(Web): - def text(self, *args, **kwargs): - ... + def text(self, *args, **kwargs): ... - def html(self, *args, **kwargs): - ... + def html(self, *args, **kwargs): ... - def json(self, *args, **kwargs): - ... + def json(self, *args, **kwargs): ... - def bytes(self, *args, **kwargs): - ... + def bytes(self, *args, **kwargs): ... - def bytes_to_response(self, *args, **kwargs): - ... + def bytes_to_response(self, *args, **kwargs): ... - def response_to_bytes(self, *args, **kwargs): - ... + def response_to_bytes(self, *args, **kwargs): ... - def route(self, *args, **kwargs): - ... + def route(self, *args, **kwargs): ... - def add_static(self, *args, **kwargs): - ... + def add_static(self, *args, **kwargs): ... - async def read_request_content(self, *args, **kwargs): - ... + async def read_request_content(self, *args, **kwargs): ... - async def wsgi(self, *args, **kwargs): - ... + async def wsgi(self, *args, **kwargs): ... class Test_Web: