Skip to content

Commit

Permalink
chore: add pyupgrader to lint script
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancetnik committed Aug 4, 2023
1 parent 2591cdc commit 533495a
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 60 deletions.
13 changes: 5 additions & 8 deletions propan/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,21 @@ def import_error(error_msg: str) -> Mock:


INSTALL_RABBIT = import_error(
(
"\nYou should install RabbitMQ dependencies"
'\npip install "propan[async-rabbit]"'
)
"\nYou should install RabbitMQ dependencies" '\npip install "propan[async-rabbit]"'
)

INSTALL_KAFKA = import_error(
("\nYou should install Kafka dependencies" '\npip install "propan[async-kafka]"')
"\nYou should install Kafka dependencies" '\npip install "propan[async-kafka]"'
)

INSTALL_NATS = import_error(
("\nYou should install NATS dependencies" '\npip install "propan[async-nats]"')
"\nYou should install NATS dependencies" '\npip install "propan[async-nats]"'
)

INSTALL_SQS = import_error(
("\nYou should install SQS dependencies" '\npip install "propan[async-sqs]"')
"\nYou should install SQS dependencies" '\npip install "propan[async-sqs]"'
)

INSTALL_REDIS = import_error(
("\nYou should install RabbitMQ dependencies" '\npip install "propan[async-redis]"')
"\nYou should install RabbitMQ dependencies" '\npip install "propan[async-redis]"'
)
5 changes: 3 additions & 2 deletions propan/brokers/push_back_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
from collections import Counter
from logging import Logger
from types import TracebackType
from typing import Awaitable, Callable, Optional, Type, Union
from typing import Awaitable, Callable
from typing import Counter as CounterType
from typing import Optional, Type, Union

from typing_extensions import Counter as CounterType
from typing_extensions import TypeVar

from propan.brokers._model.schemas import PropanMessage
Expand Down
3 changes: 2 additions & 1 deletion propan/fastapi/core/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from enum import Enum
from typing import (
Any,
AsyncIterator,
Awaitable,
Callable,
Dict,
Expand All @@ -24,7 +25,7 @@
from starlette.responses import HTMLResponse, JSONResponse, Response
from starlette.routing import _DefaultLifespan
from starlette.types import AppType, ASGIApp, Lifespan
from typing_extensions import AsyncIterator, TypeVar
from typing_extensions import TypeVar

from propan.brokers._model.broker_usecase import (
BrokerAsyncUsecase,
Expand Down
7 changes: 1 addition & 6 deletions propan/test/kafka.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import sys
from datetime import datetime
from types import MethodType
from typing import Any, Dict, Optional
from unittest.mock import AsyncMock

from aiokafka.structs import ConsumerRecord

if sys.version_info < (3, 8):
from asyncmock import AsyncMock
else:
from unittest.mock import AsyncMock

from propan import KafkaBroker
from propan.test.utils import call_handler
from propan.types import SendableMessage
Expand Down
7 changes: 1 addition & 6 deletions propan/test/nats.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import sys
from types import MethodType
from typing import Any, Dict, Optional, Union
from unittest.mock import AsyncMock
from uuid import uuid4

from nats.aio.msg import Msg

if sys.version_info < (3, 8):
from asyncmock import AsyncMock
else:
from unittest.mock import AsyncMock

from propan import NatsBroker
from propan.test.utils import call_handler
from propan.types import SendableMessage
Expand Down
11 changes: 2 additions & 9 deletions propan/test/rabbit.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import re
import sys
from contextlib import asynccontextmanager
from types import MethodType
from typing import Any, Optional, Union

from propan.types import AnyDict

if sys.version_info < (3, 8):
from asyncmock import AsyncMock
else:
from unittest.mock import AsyncMock

from unittest.mock import AsyncMock
from uuid import uuid4

import aiormq
Expand All @@ -27,6 +19,7 @@
from propan.brokers.rabbit.rabbit_broker import PikaSendableMessage, TimeoutType
from propan.brokers.rabbit.utils import validate_exchange, validate_queue
from propan.test.utils import call_handler
from propan.types import AnyDict

__all__ = (
"build_message",
Expand Down
7 changes: 1 addition & 6 deletions propan/test/redis.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import re
import sys
from types import MethodType
from typing import Any, Dict, Optional, Union
from unittest.mock import AsyncMock

from typing_extensions import TypeAlias

if sys.version_info < (3, 8):
from asyncmock import AsyncMock
else:
from unittest.mock import AsyncMock

from propan._compat import model_to_json
from propan.brokers.redis.redis_broker import RedisBroker
from propan.brokers.redis.schemas import RedisMessage
Expand Down
7 changes: 1 addition & 6 deletions propan/test/sqs.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import json
import sys
from hashlib import md5
from types import MethodType
from typing import Any, Dict, Optional
from unittest.mock import AsyncMock
from uuid import uuid4

if sys.version_info < (3, 8):
from asyncmock import AsyncMock
else:
from unittest.mock import AsyncMock

from propan import SQSBroker
from propan.brokers.sqs.schema import SQSMessage
from propan.test.utils import call_handler
Expand Down
34 changes: 18 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = [
{ name = "Pastukhov Nikita", email = "diementros@yandex.ru" },
]

keywords = ["rabbitmq", "framework", "message brokers"]
keywords = ["rabbitmq", "nats", "kafka", "sqs", "redis", "framework", "message brokers"]

requires-python = ">=3.7"

Expand Down Expand Up @@ -40,26 +40,18 @@ classifiers = [
"Framework :: AsyncIO",
"Framework :: Pydantic",
"Framework :: Pydantic :: 1",
"Framework :: Pydantic :: 2",
]

dynamic = ["version"]

dependencies = [
"fast-depends>=2.1.1",
"watchfiles",
"typer",
"uvloop>=0.14.0,!=0.15.0,!=0.15.1; sys_platform != 'win32' and (sys_platform != 'cygwin' and platform_python_implementation != 'PyPy')",
]

dynamic = ["version"]

[project.urls]
Homepage = "https://lancetnik.github.io/Propan/"
Documentation = "https://lancetnik.github.io/Propan/"
Tracker = "https://github.com/Lancetnik/Propan/issues"
Source = "https://github.com/Lancetnik/Propan"

[project.scripts]
propan = "propan.__main__:cli"

[project.optional-dependencies]
async-rabbit = [
"aio-pika>=9",
Expand All @@ -77,6 +69,10 @@ async-kafka = [
"aiokafka>=0.8",
]

async-sqs = [
"aiobotocore",
]

doc = [
"PyYAML",
"email-validator>=2.0.0",
Expand All @@ -86,10 +82,6 @@ doc = [
"uvicorn",
]

async-sqs = [
"aiobotocore",
]

testsuite = [
"coverage[toml]>=7.2",
"pytest==7.4.0",
Expand Down Expand Up @@ -136,9 +128,19 @@ dev = [
"black==23.3.0",
"isort>=5",
"ruff==0.0.275",
"pyupgrade-directories",
"typer[all]",
]

[project.urls]
Homepage = "https://lancetnik.github.io/Propan/"
Documentation = "https://lancetnik.github.io/Propan/"
Tracker = "https://github.com/Lancetnik/Propan/issues"
Source = "https://github.com/Lancetnik/Propan"

[project.scripts]
propan = "propan.__main__:cli"

[tool.hatch.metadata]
allow-direct-references = true
allow-ambiguous-features = true
Expand Down
1 change: 1 addition & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pyup_dirs --py37-plus --recursive propan tests
mypy propan
ruff propan examples tests --fix
black propan examples tests
Expand Down

0 comments on commit 533495a

Please sign in to comment.