Skip to content

Commit

Permalink
Use ruff's I import sorting instead of isort
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Feb 7, 2025
1 parent c48c47d commit a8943c7
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 65 deletions.
4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: 'https://github.com/PyCQA/isort'
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.4
hooks:
Expand Down
5 changes: 1 addition & 4 deletions botocore/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from botocore.compat import (
HAS_CRT,
MD5_AVAILABLE, # noqa: F401 -- keep imported for backwards compatibility
HTTPHeaders,
encodebytes,
ensure_unicode,
Expand All @@ -47,10 +48,6 @@
percent_encode_sequence,
)

# Imports for backwards compatibility
from botocore.compat import MD5_AVAILABLE # noqa


logger = logging.getLogger(__name__)


Expand Down
25 changes: 11 additions & 14 deletions botocore/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
# language governing permissions and limitations under the License.
import logging

from botocore import waiter, xform_name
from botocore import (
UNSIGNED, # noqa: F401 -- keep imported for backwards compatibility
waiter,
xform_name,
)
from botocore.args import ClientArgsCreator
from botocore.auth import AUTH_TYPE_MAPS, resolve_auth_type
from botocore.awsrequest import prepare_request_dict
Expand All @@ -26,6 +30,7 @@
)
from botocore.docs.docstring import ClientMethodDocstring, PaginatorDocstring
from botocore.exceptions import (
ClientError, # noqa: F401 -- keep imported for backwards compatibility
DataNotFoundError,
InvalidEndpointDiscoveryConfigurationError,
OperationNotPageableError,
Expand All @@ -45,26 +50,18 @@
from botocore.utils import (
CachedProperty,
EventbridgeSignerSetter,
S3ArnParamHandler, # noqa: F401 -- keep imported for backwards compatibility
S3ControlArnParamHandler, # noqa: F401 -- keep imported for backwards compatibility
S3ControlArnParamHandlerv2,
S3ControlEndpointSetter, # noqa: F401 -- keep imported for backwards compatibility
S3EndpointSetter, # noqa: F401 -- keep imported for backwards compatibility
S3ExpressIdentityResolver,
S3RegionRedirector, # noqa: F401 -- keep imported for backwards compatibility
S3RegionRedirectorv2,
ensure_boolean,
get_service_module_name,
)

# Keep these imported. There's pre-existing code that uses:
# "from botocore.client import UNSIGNED"
# "from botocore.client import ClientError"
# etc.
from botocore.exceptions import ClientError # noqa
from botocore.utils import S3ArnParamHandler # noqa
from botocore.utils import S3ControlArnParamHandler # noqa
from botocore.utils import S3ControlEndpointSetter # noqa
from botocore.utils import S3EndpointSetter # noqa
from botocore.utils import S3RegionRedirector # noqa
from botocore import UNSIGNED # noqa


_LEGACY_SIGNATURE_VERSIONS = frozenset(
(
'v2',
Expand Down
21 changes: 10 additions & 11 deletions botocore/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@

import botocore
import botocore.auth
from botocore import utils
from botocore import (
retryhandler, # noqa: F401 -- keep imported for backwards compatibility
translate, # noqa: F401 -- keep imported for backwards compatibility
utils,
)
from botocore.compat import (
MD5_AVAILABLE, # noqa: F401 -- keep imported for backwards compatibility
ETree,
OrderedDict,
XMLParseError,
Expand All @@ -49,6 +54,7 @@
from botocore.endpoint_provider import VALID_HOST_LABEL_RE
from botocore.exceptions import (
AliasConflictParameterError,
MissingServiceIdError, # noqa: F401 -- keep imported for backwards compatibility
ParamValidationError,
UnsupportedTLSVersionWarning,
)
Expand All @@ -61,21 +67,14 @@
)
from botocore.utils import (
SAFE_CHARS,
SERVICE_NAME_ALIASES, # noqa: F401 -- keep imported for backwards compatibility
ArnParser,
hyphenize_service_id, # noqa: F401 -- keep imported for backwards compatibility
is_global_accesspoint, # noqa: F401 -- keep imported for backwards compatibility
percent_encode,
switch_host_with_param,
)

# Keep these imported. There's pre-existing code that uses them.
from botocore import retryhandler # noqa
from botocore import translate # noqa
from botocore.compat import MD5_AVAILABLE # noqa
from botocore.exceptions import MissingServiceIdError # noqa
from botocore.utils import hyphenize_service_id # noqa
from botocore.utils import is_global_accesspoint # noqa
from botocore.utils import SERVICE_NAME_ALIASES # noqa


logger = logging.getLogger(__name__)

REGISTER_FIRST = object()
Expand Down
19 changes: 11 additions & 8 deletions botocore/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@
from urllib3.exceptions import ProtocolError as URLLib3ProtocolError
from urllib3.exceptions import ReadTimeoutError as URLLib3ReadTimeoutError

from botocore import parsers
from botocore.compat import set_socket_timeout
from botocore import (
ScalarTypes, # noqa: F401 -- keep imported for backwards compatibility
parsers,
)
from botocore.compat import (
XMLParseError, # noqa: F401 -- keep imported for backwards compatibility
set_socket_timeout,
)
from botocore.exceptions import (
IncompleteReadError,
ReadTimeoutError,
ResponseStreamingError,
)

# Keep these imported. There's pre-existing code that uses them.
from botocore import ScalarTypes # noqa
from botocore.compat import XMLParseError # noqa
from botocore.hooks import first_non_none_response # noqa

from botocore.hooks import (
first_non_none_response, # noqa: F401 -- keep imported for backwards compatibility
)

logger = logging.getLogger(__name__)

Expand Down
8 changes: 4 additions & 4 deletions botocore/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
translate,
waiter,
)
from botocore.compat import HAS_CRT, MutableMapping
from botocore.compat import (
HAS_CRT, # noqa: F401 -- keep imported for backwards compatibility
MutableMapping,
)
from botocore.configprovider import (
BOTOCORE_DEFAUT_SESSION_VARIABLES,
ConfigChainFactory,
Expand Down Expand Up @@ -72,9 +75,6 @@
validate_region_name,
)

from botocore.compat import HAS_CRT # noqa


logger = logging.getLogger(__name__)


Expand Down
9 changes: 5 additions & 4 deletions botocore/signers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
UnknownSignatureVersionError,
UnsupportedSignatureVersionError,
)
from botocore.utils import ArnParser, datetime2timestamp

# Keep these imported. There's pre-existing code that uses them.
from botocore.utils import fix_s3_host # noqa
from botocore.utils import (
ArnParser,
datetime2timestamp,
fix_s3_host, # noqa: F401 -- keep imported for backwards compatibility
)


class RequestSigner:
Expand Down
16 changes: 7 additions & 9 deletions botocore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,19 @@
import botocore
import botocore.awsrequest
import botocore.httpsession

# IP Regexes retained for backwards compatibility
from botocore.compat import HEX_PAT # noqa: F401
from botocore.compat import IPV4_PAT # noqa: F401
from botocore.compat import IPV6_ADDRZ_PAT # noqa: F401
from botocore.compat import IPV6_PAT # noqa: F401
from botocore.compat import LS32_PAT # noqa: F401
from botocore.compat import UNRESERVED_PAT # noqa: F401
from botocore.compat import ZONE_ID_PAT # noqa: F401
from botocore.compat import (
HAS_CRT,
HEX_PAT, # noqa: F401 -- IP Regexes retained for backwards compatibility
IPV4_PAT, # noqa: F401 -- IP Regexes retained for backwards compatibility
IPV4_RE,
IPV6_ADDRZ_PAT, # noqa: F401 -- IP Regexes retained for backwards compatibility
IPV6_ADDRZ_RE,
IPV6_PAT, # noqa: F401 -- IP Regexes retained for backwards compatibility
LS32_PAT, # noqa: F401 -- IP Regexes retained for backwards compatibility
MD5_AVAILABLE,
UNRESERVED_PAT, # noqa: F401 -- IP Regexes retained for backwards compatibility
UNSAFE_URL_CHARS,
ZONE_ID_PAT, # noqa: F401 -- IP Regexes retained for backwards compatibility
OrderedDict,
get_md5,
get_tzinfo_options,
Expand Down
8 changes: 1 addition & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ markers = [
"validates_models: marks tests as one which validates service models",
]

[tool.isort]
profile = "black"
line_length = 79
honor_noqa = true
src_paths = ["botocore", "tests"]

[tool.ruff]
exclude = [
".bzr",
Expand Down Expand Up @@ -60,7 +54,7 @@ target-version = "py38"
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F", "UP"]
select = ["E4", "E7", "E9", "F", "UP", "I"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
Expand Down

0 comments on commit a8943c7

Please sign in to comment.