Skip to content

Commit

Permalink
Run fmt after upgrading targets
Browse files Browse the repository at this point in the history
  • Loading branch information
JordonPhillips committed Dec 2, 2022
1 parent 73d0826 commit ee0a559
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# language governing permissions and limitations under the License.


from typing import Generic, Optional, TypeVar
from typing import Generic, TypeVar

EntryType = TypeVar("EntryType")

Expand All @@ -37,20 +37,18 @@ def entries(self) -> list[SmithyEntry[EntryType]]:
# merging collections
return list(self._entries)

def _resolve_entry_position(self, name: Optional[str], default_pos: int) -> int:
def _resolve_entry_position(self, name: str | None, default_pos: int) -> int:
for n, entry in enumerate(self._entries):
if entry.name == name:
return n
return default_pos

def add_before(
self, entry: SmithyEntry[EntryType], name: Optional[str] = None
self, entry: SmithyEntry[EntryType], name: str | None = None
) -> None:
position = self._resolve_entry_position(name, 0)
self._entries.insert(position, entry)

def add_after(
self, entry: SmithyEntry[EntryType], name: Optional[str] = None
) -> None:
def add_after(self, entry: SmithyEntry[EntryType], name: str | None = None) -> None:
position = self._resolve_entry_position(name, len(self._entries))
self._entries.insert(position + 1, entry)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


from dataclasses import dataclass, field
from typing import Any, Optional
from typing import Any
from urllib.parse import parse_qsl, urlparse

from smithy_python.interfaces import http as http_interface
Expand All @@ -28,13 +28,13 @@ class URL:
def __init__(
self,
hostname: str,
path: Optional[str] = None,
scheme: Optional[str] = None,
query_params: Optional[QueryParamsList] = None,
port: Optional[int] = None,
path: str | None = None,
scheme: str | None = None,
query_params: QueryParamsList | None = None,
port: int | None = None,
):
self.hostname: str = hostname
self.port: Optional[int] = port
self.port: int | None = port

self.path: str = ""
if path is not None:
Expand All @@ -54,7 +54,7 @@ def __init__(
self,
url: http_interface.URL,
method: str = "GET",
headers: Optional[HeadersList] = None,
headers: HeadersList | None = None,
body: Any = None,
):
self.url: http_interface.URL = url
Expand Down
12 changes: 6 additions & 6 deletions python-packages/smithy-python/smithy_python/_private/http/crt.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from concurrent.futures import Future
from io import BytesIO
from threading import Lock
from typing import Any, AsyncGenerator, Awaitable, Generator, Optional
from typing import Any, AsyncGenerator, Awaitable, Generator

from awscrt import http, io

Expand Down Expand Up @@ -46,7 +46,7 @@ def _initialize_default_loop(self) -> io.ClientBootstrap:

class _BaseAwsCrtHttpResponse:
def __init__(self) -> None:
self._stream: Optional[http.HttpClientStream] = None
self._stream: http.HttpClientStream | None = None
self._status_code_future: Future[int] = Future()
self._headers_future: Future[HeadersList] = Future()
self._chunk_futures: list[Future[bytes]] = []
Expand Down Expand Up @@ -172,14 +172,14 @@ def chunks(self) -> Generator[bytes, None, None]:
break


ConnectionPoolKey = tuple[str, str, Optional[int]]
ConnectionPoolKey = tuple[str, str, int | None]
ConnectionPoolDict = dict[ConnectionPoolKey, http.HttpClientConnection]


class AwsCrtHttpSessionConfig:
def __init__(
self,
force_http_2: Optional[bool] = None,
force_http_2: bool | None = None,
) -> None:
if force_http_2 is None:
force_http_2 = False
Expand All @@ -192,8 +192,8 @@ class _BaseAwsCrtHttpSession:

def __init__(
self,
eventloop: Optional[AWSCRTEventLoop] = None,
config: Optional[AwsCrtHttpSessionConfig] = None,
eventloop: AWSCRTEventLoop | None = None,
config: AwsCrtHttpSessionConfig | None = None,
) -> None:
if eventloop is None:
eventloop = AWSCRTEventLoop()
Expand Down
22 changes: 11 additions & 11 deletions python-packages/smithy-python/smithy_python/_private/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# language governing permissions and limitations under the License.


from typing import Any, Awaitable, Callable, Generic, Optional, TypeVar
from typing import Any, Awaitable, Callable, Generic, TypeVar

from smithy_python._private.collection import SmithyCollection
from smithy_python.interfaces.http import Request, Response
Expand Down Expand Up @@ -46,7 +46,7 @@ def chain_middleware(

# Step Inputs
class InitializeInput(Generic[Input]):
def __init__(self, *, param: Input, context: Optional[Context] = None) -> None:
def __init__(self, *, param: Input, context: Context | None = None) -> None:
self.input: Input = param
if context is None:
context = {}
Expand All @@ -58,19 +58,19 @@ def __init__(
self,
*,
param: Input,
request: Optional[Request] = None,
context: Optional[Context] = None,
request: Request | None = None,
context: Context | None = None,
) -> None:
self.input: Input = param
self.request: Optional[Request] = request
self.request: Request | None = request
if context is None:
context = {}
self.context: Context = context


class BuildInput(Generic[Input]):
def __init__(
self, *, param: Input, request: Request, context: Optional[Context] = None
self, *, param: Input, request: Request, context: Context | None = None
) -> None:
self.input: Input = param
self.request: Request = request
Expand All @@ -85,12 +85,12 @@ def __init__(
*,
param: Input,
request: Request,
response: Optional[Response] = None,
context: Optional[Context] = None,
response: Response | None = None,
context: Context | None = None,
) -> None:
self.input: Input = param
self.request: Request = request
self.response: Optional[Response] = response
self.response: Response | None = response
if context is None:
context = {}
self.context: Context = context
Expand All @@ -103,7 +103,7 @@ def __init__(
param: Input,
request: Request,
response: Response,
context: Optional[Context] = None,
context: Context | None = None,
) -> None:
self.input: Input = param
self.request: Request = request
Expand Down Expand Up @@ -197,7 +197,7 @@ def __init__(self) -> None:
def resolve(
self,
terminal: DeserializeHandler[Input, Output],
context: Optional[Context] = None,
context: Context | None = None,
) -> Handler[Input, Output]:
stack_chain = self._build_deserialize_chain(terminal)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import Any, Optional, Protocol, TypeVar
from typing import Any, Protocol, TypeVar

# Defining headers as a list instead of a mapping to avoid ambiguity and
# the nuances of multiple fields in a mapping style interface
Expand All @@ -9,7 +9,7 @@
class URL(Protocol):
scheme: str # http or https
hostname: str # hostname e.g. amazonaws.com
port: Optional[int] # explicit port number
port: int | None # explicit port number
path: str # request path
query_params: list[tuple[str, str]]

Expand Down

0 comments on commit ee0a559

Please sign in to comment.