Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Roll back change to the botocore version from
'2.0.0' to the previous version, and drop it from
the user agent string.

Remove "requires CRT"-related checks, including
in the user agent builder and tests.

Fix functional test that was checking for "Python"
in the user agent string, which previously held
the Python version; this now would have been
present only because the user agent implementation
adds `md/pyimpl#CPython` to the string. Updated
the test to remove check for "Python" and include
checking for `md/installer` and `md/command`.
  • Loading branch information
kdaily committed May 8, 2024
1 parent 1ade664 commit bad9f1e
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 42 deletions.
2 changes: 1 addition & 1 deletion awscli/botocore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import os
import re

__version__ = '2.0.0'
__version__ = '2.0.0dev155'


class NullHandler(logging.Handler):
Expand Down
2 changes: 1 addition & 1 deletion awscli/botocore/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,4 +575,4 @@ def _compute_user_agent_appid_config(self, config_kwargs):
'The configured value for user_agent_appid exceeds the '
f'maximum length of {USERAGENT_APPID_MAXLEN} characters.'
)
config_kwargs['user_agent_appid'] = user_agent_appid
config_kwargs['user_agent_appid'] = user_agent_appid
11 changes: 0 additions & 11 deletions awscli/botocore/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,6 @@ def get_tzinfo_options():
return (tzlocal,)


# Detect if CRT is available for use
try:
import awscrt.auth

# Allow user opt-out if needed
disabled = os.environ.get('BOTO_DISABLE_CRT', "false")
HAS_CRT = not disabled.lower() == 'true'
except ImportError:
HAS_CRT = False


########################################################
# urllib3 compat backports #
########################################################
Expand Down
2 changes: 0 additions & 2 deletions awscli/botocore/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
from botocore.regions import EndpointResolver
from botocore.useragent import UserAgentString

from botocore.compat import HAS_CRT # noqa


logger = logging.getLogger(__name__)

Expand Down
8 changes: 1 addition & 7 deletions awscli/botocore/useragent.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from typing import NamedTuple, Optional

from botocore import __version__ as botocore_version
from botocore.compat import HAS_CRT

_USERAGENT_ALLOWED_CHARACTERS = ascii_letters + digits + "!$%&'*+-.^_`|~"
_USERAGENT_ALLOWED_OS_NAMES = (
Expand Down Expand Up @@ -198,9 +197,7 @@ def __init__(

@classmethod
def from_environment(cls):
crt_version = None
if HAS_CRT:
crt_version = _get_crt_version() or 'Unknown'
crt_version = _get_crt_version() or 'Unknown'
return cls(
platform_name=platform.system(),
platform_version=platform.release(),
Expand Down Expand Up @@ -298,9 +295,6 @@ def _build_sdk_metadata(self):
self._session_user_agent_name,
self._session_user_agent_version,
),
UserAgentComponent(
'md', _USERAGENT_SDK_NAME, botocore_version
),
]
)
else:
Expand Down
5 changes: 4 additions & 1 deletion tests/functional/test_clidriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ def test_user_agent_in_request(self):
'aws-cli' in
self._send.call_args[0][0].headers['User-Agent'].decode('utf-8'))
self.assertTrue(
'Python' in
'md/installer' in
self._send.call_args[0][0].headers['User-Agent'].decode('utf-8'))
self.assertTrue(
'md/command' in
self._send.call_args[0][0].headers['User-Agent'].decode('utf-8'))


Expand Down
19 changes: 0 additions & 19 deletions tests/unit/botocore/test_useragent.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,6 @@
sanitize_user_agent_string_component,
)

# TODO: fix this import and remove the `requires_crt` method.
# The imported method conflicts with the `requires_crt`
# that comes from s3transfer tests.

# from tests import requires_crt

from botocore.compat import HAS_CRT


def requires_crt(reason=None):
if reason is None:
reason = "Test requires awscrt to be installed"

def decorator(func):
return unittest.skipIf(not HAS_CRT, reason)(func)

return decorator


@pytest.mark.parametrize(
'raw_str, allow_hash, expected_str',
Expand Down Expand Up @@ -164,7 +146,6 @@ def test_from_environment(monkeypatch):
assert uas._python_implementation == 'Cpython'


@requires_crt()
def test_from_environment_can_read_crt_version(monkeypatch):
import awscrt

Expand Down

0 comments on commit bad9f1e

Please sign in to comment.