Skip to content

Commit b208edb

Browse files
authored
Merge pull request #3495 from nateprewitt/ruff_update_2025
Update ruff/pre-commit
2 parents 56085c2 + c155790 commit b208edb

37 files changed

+150
-183
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@ exclude: "\
1414
)"
1515
repos:
1616
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
17-
rev: v4.5.0
17+
rev: v5.0.0
1818
hooks:
1919
- id: check-yaml
2020
- id: end-of-file-fixer
2121
- id: trailing-whitespace
22-
- repo: 'https://github.com/PyCQA/isort'
23-
rev: 5.12.0
24-
hooks:
25-
- id: isort
2622
- repo: https://github.com/astral-sh/ruff-pre-commit
27-
rev: v0.4.8
23+
rev: v0.12.0
2824
hooks:
29-
- id: ruff
25+
- id: ruff-check
3026
args: [ --fix ]
3127
- id: ruff-format

botocore/args.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@
3030
from botocore.regions import EndpointRulesetResolver
3131
from botocore.signers import RequestSigner
3232
from botocore.useragent import UserAgentString, register_feature_id
33-
from botocore.utils import PRIORITY_ORDERED_SUPPORTED_PROTOCOLS # noqa: F401
34-
from botocore.utils import ensure_boolean, is_s3_accelerate_url
33+
from botocore.utils import (
34+
PRIORITY_ORDERED_SUPPORTED_PROTOCOLS, # noqa: F401
35+
ensure_boolean,
36+
is_s3_accelerate_url,
37+
)
3538

3639
logger = logging.getLogger(__name__)
3740

botocore/auth.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
from botocore.compat import (
2828
HAS_CRT,
29+
MD5_AVAILABLE, # noqa: F401
2930
HTTPHeaders,
3031
encodebytes,
3132
ensure_unicode,
@@ -47,10 +48,6 @@
4748
percent_encode_sequence,
4849
)
4950

50-
# Imports for backwards compatibility
51-
from botocore.compat import MD5_AVAILABLE # noqa
52-
53-
5451
logger = logging.getLogger(__name__)
5552

5653

@@ -88,7 +85,7 @@ def _host_from_url(url):
8885
}
8986
if url_parts.port is not None:
9087
if url_parts.port != default_ports.get(url_parts.scheme):
91-
host = '%s:%d' % (host, url_parts.port)
88+
host = f'{host}:{url_parts.port}'
9289
return host
9390

9491

botocore/client.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
# language governing permissions and limitations under the License.
1313
import logging
1414

15-
from botocore import waiter, xform_name
15+
from botocore import (
16+
UNSIGNED, # noqa: F401
17+
waiter,
18+
xform_name,
19+
)
1620
from botocore.args import ClientArgsCreator
1721
from botocore.auth import AUTH_TYPE_MAPS, resolve_auth_type
1822
from botocore.awsrequest import prepare_request_dict
@@ -27,6 +31,7 @@
2731
)
2832
from botocore.docs.docstring import ClientMethodDocstring, PaginatorDocstring
2933
from botocore.exceptions import (
34+
ClientError, # noqa: F401
3035
DataNotFoundError,
3136
InvalidEndpointDiscoveryConfigurationError,
3237
OperationNotPageableError,
@@ -46,26 +51,18 @@
4651
from botocore.utils import (
4752
CachedProperty,
4853
EventbridgeSignerSetter,
54+
S3ArnParamHandler, # noqa: F401
55+
S3ControlArnParamHandler, # noqa: F401
4956
S3ControlArnParamHandlerv2,
57+
S3ControlEndpointSetter, # noqa: F401
58+
S3EndpointSetter, # noqa: F401
5059
S3ExpressIdentityResolver,
60+
S3RegionRedirector, # noqa: F401
5161
S3RegionRedirectorv2,
5262
ensure_boolean,
5363
get_service_module_name,
5464
)
5565

56-
# Keep these imported. There's pre-existing code that uses:
57-
# "from botocore.client import UNSIGNED"
58-
# "from botocore.client import ClientError"
59-
# etc.
60-
from botocore.exceptions import ClientError # noqa
61-
from botocore.utils import S3ArnParamHandler # noqa
62-
from botocore.utils import S3ControlArnParamHandler # noqa
63-
from botocore.utils import S3ControlEndpointSetter # noqa
64-
from botocore.utils import S3EndpointSetter # noqa
65-
from botocore.utils import S3RegionRedirector # noqa
66-
from botocore import UNSIGNED # noqa
67-
68-
6966
logger = logging.getLogger(__name__)
7067
history_recorder = get_global_history_recorder()
7168

botocore/docs/params.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ def _add_member_documentation(self, section, shape, name=None, **kwargs):
189189
[f'``{key}``' for key in shape.members.keys()]
190190
)
191191
unknown_code_example = (
192-
'\'SDK_UNKNOWN_MEMBER\': '
193-
'{\'name\': \'UnknownMemberName\'}'
192+
'\'SDK_UNKNOWN_MEMBER\': {\'name\': \'UnknownMemberName\'}'
194193
)
195194
tagged_union_docs.write(note % (tagged_union_members_str))
196195
example = section.add_new_section('param-unknown-example')

botocore/exceptions.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ class ValidationError(BotoCoreError):
351351
:ivar type_name: The name of the underlying type.
352352
"""
353353

354-
fmt = "Invalid value ('{value}') for param {param} " "of type {type_name} "
354+
fmt = "Invalid value ('{value}') for param {param} of type {type_name} "
355355

356356

357357
class ParamValidationError(BotoCoreError):
@@ -371,8 +371,7 @@ class UnknownKeyError(ValidationError):
371371
"""
372372

373373
fmt = (
374-
"Unknown key '{value}' for param '{param}'. Must be one "
375-
"of: {choices}"
374+
"Unknown key '{value}' for param '{param}'. Must be one of: {choices}"
376375
)
377376

378377

@@ -482,9 +481,7 @@ def __init__(self, name, reason, last_response):
482481
class IncompleteReadError(BotoCoreError):
483482
"""HTTP response did not return expected number of bytes."""
484483

485-
fmt = (
486-
'{actual_bytes} read, but total bytes ' 'expected is {expected_bytes}.'
487-
)
484+
fmt = '{actual_bytes} read, but total bytes expected is {expected_bytes}.'
488485

489486

490487
class InvalidExpressionError(BotoCoreError):

botocore/handlers.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@
2727

2828
import botocore
2929
import botocore.auth
30-
from botocore import utils
30+
from botocore import (
31+
retryhandler, # noqa: F401
32+
translate, # noqa: F401
33+
utils,
34+
)
3135
from botocore.compat import (
36+
MD5_AVAILABLE, # noqa: F401
3237
ETree,
3338
OrderedDict,
3439
XMLParseError,
@@ -49,6 +54,7 @@
4954
from botocore.endpoint_provider import VALID_HOST_LABEL_RE
5055
from botocore.exceptions import (
5156
AliasConflictParameterError,
57+
MissingServiceIdError, # noqa: F401
5258
ParamValidationError,
5359
UnsupportedTLSVersionWarning,
5460
)
@@ -61,21 +67,14 @@
6167
)
6268
from botocore.utils import (
6369
SAFE_CHARS,
70+
SERVICE_NAME_ALIASES, # noqa: F401
6471
ArnParser,
72+
hyphenize_service_id, # noqa: F401
73+
is_global_accesspoint, # noqa: F401
6574
percent_encode,
6675
switch_host_with_param,
6776
)
6877

69-
# Keep these imported. There's pre-existing code that uses them.
70-
from botocore import retryhandler # noqa
71-
from botocore import translate # noqa
72-
from botocore.compat import MD5_AVAILABLE # noqa
73-
from botocore.exceptions import MissingServiceIdError # noqa
74-
from botocore.utils import hyphenize_service_id # noqa
75-
from botocore.utils import is_global_accesspoint # noqa
76-
from botocore.utils import SERVICE_NAME_ALIASES # noqa
77-
78-
7978
logger = logging.getLogger(__name__)
8079

8180
REGISTER_FIRST = object()

botocore/monitoring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ def _get_auth_match(self, auth_val):
535535
def _truncate(self, text, max_length):
536536
if len(text) > max_length:
537537
logger.debug(
538-
'Truncating following value to maximum length of ' '%s: %s',
538+
'Truncating following value to maximum length of %s: %s',
539539
text,
540540
max_length,
541541
)

botocore/paginate.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@ def __iter__(self):
324324
and previous_next_token == next_token
325325
):
326326
message = (
327-
f"The same next token was received "
328-
f"twice: {next_token}"
327+
f"The same next token was received twice: {next_token}"
329328
)
330329
raise PaginationError(message=message)
331330
self._inject_token_into_kwargs(current_kwargs, next_token)

botocore/response.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,21 @@
1818
from urllib3.exceptions import ProtocolError as URLLib3ProtocolError
1919
from urllib3.exceptions import ReadTimeoutError as URLLib3ReadTimeoutError
2020

21-
from botocore import parsers
22-
from botocore.compat import set_socket_timeout
21+
from botocore import (
22+
ScalarTypes, # noqa: F401
23+
parsers,
24+
)
25+
from botocore.compat import (
26+
XMLParseError, # noqa: F401
27+
set_socket_timeout,
28+
)
2329
from botocore.exceptions import (
2430
IncompleteReadError,
2531
ReadTimeoutError,
2632
ResponseStreamingError,
2733
)
28-
29-
# Keep these imported. There's pre-existing code that uses them.
30-
from botocore import ScalarTypes # noqa
31-
from botocore.compat import XMLParseError # noqa
3234
from botocore.hooks import first_non_none_response # noqa
3335

34-
3536
logger = logging.getLogger(__name__)
3637

3738

0 commit comments

Comments
 (0)