Skip to content

Commit c5860cc

Browse files
committed
Add ruff lint rule - RUF
1 parent 1e9aa59 commit c5860cc

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

packages/aws-event-stream/src/aws_event_stream/events.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from dataclasses import dataclass
1616
from io import BytesIO
1717
from struct import pack, unpack
18+
from types import MappingProxyType
1819
from typing import Literal, Self
1920

2021
from smithy_core.aio.interfaces import AsyncByteStream
@@ -610,11 +611,11 @@ class _DecodeUtils:
610611
INT64_BYTE_FORMAT = "!q"
611612

612613
# uint byte size to unpack format
613-
UINT_BYTE_FORMAT: dict[_ArraySize, str] = {
614+
UINT_BYTE_FORMAT: Mapping[_ArraySize, str] = MappingProxyType({
614615
1: UINT8_BYTE_FORMAT,
615616
2: UINT16_BYTE_FORMAT,
616617
4: UINT32_BYTE_FORMAT,
617-
}
618+
})
618619

619620
@staticmethod
620621
def unpack_uint8(data: BytesLike) -> tuple[int, int]:
@@ -749,7 +750,7 @@ class EventHeaderDecoder(Iterator[tuple[str, HEADER_VALUE]]):
749750

750751
# Maps header type to appropriate unpacking function
751752
# These unpacking functions return the value and the amount unpacked
752-
_HEADER_TYPE_MAP: dict[int, Callable[[BytesLike], tuple[HEADER_VALUE, int]]] = {
753+
_HEADER_TYPE_MAP: Mapping[int, Callable[[BytesLike], tuple[HEADER_VALUE, int]]] = MappingProxyType({
753754
# Boolean headers have no data bytes following the type signifier, so they
754755
# can just return static values.
755756
0: lambda b: (True, 0), # boolean_true
@@ -762,7 +763,7 @@ class EventHeaderDecoder(Iterator[tuple[str, HEADER_VALUE]]):
762763
7: _DecodeUtils.unpack_utf8_string, # string
763764
8: _DecodeUtils.unpack_timestamp, # timestamp
764765
9: _DecodeUtils.unpack_uuid, # uuid
765-
}
766+
})
766767

767768
def __init__(self, header_bytes: BytesLike) -> None:
768769
"""Initialize an event header decoder.

packages/smithy-core/src/smithy_core/schemas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ def __init__(
5050
if any(_member_props) and not all(_member_props):
5151
raise SmithyException(
5252
"If any member property is set, all member properties must be set. "
53-
f"member_name: {repr(id.member)}, member_target: "
54-
f"{repr(member_target)}, member_index: {repr(member_index)}"
53+
f"member_name: {id.member!r}, member_target: "
54+
f"{member_target!r}, member_index: {member_index!r}"
5555
)
5656

5757
# setattr is required because the class is frozen

packages/smithy-http/src/smithy_http/aio/aiohttp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import aiohttp
1313

1414
try:
15-
import aiohttp # noqa: F811
15+
import aiohttp
1616

1717
HAS_AIOHTTP = True
1818
except ImportError:

packages/smithy-http/src/smithy_http/aio/auth/apikey.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ async def sign(
108108
)
109109
case ApiKeyLocation.HEADER:
110110
value = identity.api_key
111-
if "scheme" in signing_properties and signing_properties["scheme"]:
111+
if signing_properties.get("scheme"):
112112
value = f"{signing_properties['scheme']} {value}"
113113
http_request.fields.set_field(
114114
Field(name=signing_properties["name"], values=[value])

packages/smithy-http/src/smithy_http/aio/crt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
from awscrt import io as crt_io
1919

2020
try:
21-
from awscrt import http as crt_http # noqa: F811
22-
from awscrt import io as crt_io # noqa: F811
21+
from awscrt import http as crt_http
22+
from awscrt import io as crt_io
2323

2424
HAS_CRT = True
2525
except ImportError:

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ black = true
4646
target-version = "py312"
4747

4848
[tool.ruff.lint]
49-
# candidates: DTZ, EM, INP, ISC, PERF, RUF, SIM118, SIM401, SLOT
49+
# candidates: DTZ, EM, INP, ISC, PERF, SIM118, SIM401, SLOT
5050
# perhaps in the future: N, PYI, TC, TID
5151
# probably not, a lot of work: DOC, D, PL, TRY
5252

53-
select = [ "ASYNC", "C4", "E1", "E4", "E7", "E9", "F", "FURB", "G", "I", "LOG", "PIE", "S", "T", "UP" ]
53+
select = [ "ASYNC", "C4", "E1", "E4", "E7", "E9", "F", "FURB", "G", "I", "LOG", "PIE", "RUF", "S", "T", "UP" ]
5454
exclude = [ "packages/smithy-core/src/smithy_core/rfc3986.py" ]
5555

5656
[tool.ruff.lint.per-file-ignores]

0 commit comments

Comments
 (0)