Skip to content

Commit 7516daf

Browse files
Kludexauvipy
authored andcommitted
Bump pyupgrade version and add __future__.annotations import
1 parent a93099b commit 7516daf

File tree

160 files changed

+416
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+416
-98
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ repos:
33
rev: v2.32.0
44
hooks:
55
- id: pyupgrade
6-
args: ["--py36-plus"]
6+
args: ["--py37-plus"]
77

88
- repo: https://github.com/PyCQA/flake8
99
rev: 4.0.1

conftest.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import pytest
24

35

docs/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from sphinx_celery import conf
24

35
globals().update(conf.build_config(

examples/complete_receive.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
55
"""
66

7+
from __future__ import annotations
8+
79
from pprint import pformat
810

911
from kombu import Connection, Consumer, Exchange, Queue, eventloop

examples/complete_send.py

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
77
"""
88

9+
from __future__ import annotations
10+
911
from kombu import Connection, Exchange, Producer, Queue
1012

1113
#: By default messages sent to exchanges are persistent (delivery_mode=2),

examples/experimental/async_consume.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env python
22

3+
from __future__ import annotations
4+
35
from kombu import Connection, Consumer, Exchange, Producer, Queue
46
from kombu.asynchronous import Hub
57

examples/hello_consumer.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from kombu import Connection
24

35
with Connection('amqp://guest:guest@localhost:5672//') as conn:

examples/hello_publisher.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import datetime
24

35
from kombu import Connection

examples/memory_transport.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""
22
Example that use memory transport for message produce.
33
"""
4+
from __future__ import annotations
5+
46
import time
57

68
from kombu import Connection, Consumer, Exchange, Queue

examples/rpc-tut6/rpc_client.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env python
22

3+
from __future__ import annotations
4+
35
from kombu import Connection, Consumer, Producer, Queue, uuid
46

57

examples/rpc-tut6/rpc_server.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env python
22

3+
from __future__ import annotations
4+
35
from kombu import Connection, Queue
46
from kombu.mixins import ConsumerProducerMixin
57

examples/simple_eventlet_receive.py

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
88
"""
99

10+
from __future__ import annotations
11+
1012
import eventlet
1113

1214
from kombu import Connection

examples/simple_eventlet_send.py

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
88
"""
99

10+
from __future__ import annotations
11+
1012
import eventlet
1113

1214
from kombu import Connection

examples/simple_receive.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
44
"""
55

6+
from __future__ import annotations
7+
68
from kombu import Connection
79

810
#: Create connection

examples/simple_send.py

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
88
"""
99

10+
from __future__ import annotations
11+
1012
from kombu import Connection
1113

1214
#: Create connection

examples/simple_task_queue/client.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from kombu.pools import producers
24

35
from .queues import task_exchange

examples/simple_task_queue/queues.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from kombu import Exchange, Queue
24

35
task_exchange = Exchange('tasks', type='direct')

examples/simple_task_queue/tasks.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
from __future__ import annotations
2+
3+
14
def hello_task(who='world'):
25
print(f'Hello {who}')

examples/simple_task_queue/worker.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from kombu.log import get_logger
24
from kombu.mixins import ConsumerMixin
35
from kombu.utils.functional import reprcall

kombu/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"""Messaging library for Python."""
22

3+
from __future__ import annotations
4+
35
import os
46
import re
57
import sys
68
from collections import namedtuple
7-
from typing import Any, List, cast
9+
from typing import Any, cast
810

911
__version__ = '5.2.4'
1012
__author__ = 'Ask Solem'
@@ -78,7 +80,7 @@ def __getattr__(self, name: str) -> Any:
7880
return getattr(module, name)
7981
return ModuleType.__getattribute__(self, name)
8082

81-
def __dir__(self) -> List[str]:
83+
def __dir__(self) -> list[str]:
8284
result = list(new_module.__all__)
8385
result.extend(('__file__', '__path__', '__doc__', '__all__',
8486
'__docformat__', '__name__', '__path__', 'VERSION',

kombu/abstract.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Object utilities."""
22

3+
from __future__ import annotations
4+
35
from copy import copy
46

57
from .connection import maybe_channel

kombu/asynchronous/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Event loop."""
22

3+
from __future__ import annotations
4+
35
from kombu.utils.eventio import ERR, READ, WRITE
46

57
from .hub import Hub, get_event_loop, set_event_loop

kombu/asynchronous/aws/__init__.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
from typing import Any, Optional
1+
from __future__ import annotations
2+
3+
from typing import Any
24

35
from kombu.asynchronous.aws.sqs.connection import AsyncSQSConnection
46

57

68
def connect_sqs(
7-
aws_access_key_id: Optional[str] = None,
8-
aws_secret_access_key: Optional[str] = None,
9+
aws_access_key_id: str | None = None,
10+
aws_secret_access_key: str | None = None,
911
**kwargs: Any
1012
) -> AsyncSQSConnection:
1113
"""Return async connection to Amazon SQS."""

kombu/asynchronous/aws/connection.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Amazon AWS Connection."""
22

3+
from __future__ import annotations
4+
35
from email import message_from_bytes
46
from email.mime.message import MIMEMessage
57

kombu/asynchronous/aws/ext.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Amazon boto3 interface."""
22

3+
from __future__ import annotations
4+
35
try:
46
import boto3
57
from botocore import exceptions

kombu/asynchronous/aws/sqs/connection.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Amazon SQS Connection."""
22

3+
from __future__ import annotations
4+
35
from vine import transform
46

57
from kombu.asynchronous.aws.connection import AsyncAWSQueryConnection

kombu/asynchronous/aws/sqs/ext.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Amazon SQS boto3 interface."""
22

33

4+
from __future__ import annotations
5+
46
try:
57
import boto3
68
except ImportError:

kombu/asynchronous/aws/sqs/message.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Amazon SQS message implementation."""
22

3+
from __future__ import annotations
4+
35
import base64
46

57
from kombu.message import Message

kombu/asynchronous/aws/sqs/queue.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Amazon SQS queue implementation."""
22

3+
from __future__ import annotations
4+
35
from vine import transform
46

57
from .message import AsyncMessage

kombu/asynchronous/debug.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Event-loop debugging tools."""
22

3+
from __future__ import annotations
4+
35
from kombu.utils.eventio import ERR, READ, WRITE
46
from kombu.utils.functional import reprcall
57

kombu/asynchronous/http/__init__.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from typing import TYPE_CHECKING, Optional
1+
from __future__ import annotations
2+
3+
from typing import TYPE_CHECKING
24

35
from kombu.asynchronous import get_event_loop
46
from kombu.asynchronous.http.base import Headers, Request, Response
@@ -10,13 +12,13 @@
1012
__all__ = ('Client', 'Headers', 'Response', 'Request')
1113

1214

13-
def Client(hub: Optional[Hub] = None, **kwargs: int) -> "CurlClient":
15+
def Client(hub: Hub | None = None, **kwargs: int) -> CurlClient:
1416
"""Create new HTTP client."""
1517
from .curl import CurlClient
1618
return CurlClient(hub, **kwargs)
1719

1820

19-
def get_client(hub: Optional[Hub] = None, **kwargs: int) -> "CurlClient":
21+
def get_client(hub: Hub | None = None, **kwargs: int) -> CurlClient:
2022
"""Get or create HTTP client bound to the current event loop."""
2123
hub = hub or get_event_loop()
2224
try:

kombu/asynchronous/http/base.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
"""Base async HTTP client implementation."""
22

3+
from __future__ import annotations
4+
35
import sys
46
from http.client import responses
5-
from typing import TYPE_CHECKING, Optional, Type
7+
from typing import TYPE_CHECKING
68

79
from vine import Thenable, maybe_promise, promise
810

@@ -259,8 +261,8 @@ def __enter__(self):
259261

260262
def __exit__(
261263
self,
262-
exc_type: Optional[Type[BaseException]],
263-
exc_val: Optional[BaseException],
264-
exc_tb: Optional['TracebackType']
264+
exc_type: type[BaseException] | None,
265+
exc_val: BaseException | None,
266+
exc_tb: TracebackType | None
265267
) -> None:
266268
self.close()

kombu/asynchronous/http/curl.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"""HTTP Client using pyCurl."""
22

3+
from __future__ import annotations
4+
35
from collections import deque
46
from functools import partial
57
from io import BytesIO
68
from time import time
7-
from typing import Optional
89

910
from kombu.asynchronous.hub import READ, WRITE, Hub, get_event_loop
1011
from kombu.exceptions import HttpError
@@ -37,7 +38,7 @@ class CurlClient(BaseClient):
3738

3839
Curl = Curl
3940

40-
def __init__(self, hub: Optional[Hub] = None, max_clients: int = 10):
41+
def __init__(self, hub: Hub | None = None, max_clients: int = 10):
4142
if pycurl is None:
4243
raise ImportError('The curl client requires the pycurl library.')
4344
hub = hub or get_event_loop()

kombu/asynchronous/hub.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
"""Event loop implementation."""
22

3+
from __future__ import annotations
4+
35
import errno
46
import threading
57
from contextlib import contextmanager
68
from queue import Empty
79
from time import sleep
810
from types import GeneratorType as generator
9-
from typing import Optional
1011

1112
from vine import Thenable, promise
1213

@@ -20,7 +21,7 @@
2021
__all__ = ('Hub', 'get_event_loop', 'set_event_loop')
2122
logger = get_logger(__name__)
2223

23-
_current_loop: Optional["Hub"] = None
24+
_current_loop: Hub | None = None
2425

2526
W_UNKNOWN_EVENT = """\
2627
Received unknown event %r for fd %r, please contact support!\
@@ -40,12 +41,12 @@ def _dummy_context(*args, **kwargs):
4041
yield
4142

4243

43-
def get_event_loop() -> Optional["Hub"]:
44+
def get_event_loop() -> Hub | None:
4445
"""Get current event loop object."""
4546
return _current_loop
4647

4748

48-
def set_event_loop(loop: Optional["Hub"]) -> Optional["Hub"]:
49+
def set_event_loop(loop: Hub | None) -> Hub | None:
4950
"""Set the current event loop object."""
5051
global _current_loop
5152
_current_loop = loop

0 commit comments

Comments
 (0)