Skip to content

Commit 96ae7f2

Browse files
committed
cleanups from PR
1 parent 5c043c2 commit 96ae7f2

File tree

5 files changed

+28
-21
lines changed

5 files changed

+28
-21
lines changed

packages/smithy-aws-core/src/smithy_aws_core/auth/sigv4.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class SigV4AuthScheme(
2525
):
2626
"""SigV4 AuthScheme."""
2727

28-
scheme_id: str
28+
scheme_id: str = "aws.auth#sigv4"
2929
signer: HTTPSigner[AWSCredentialsIdentity, SigV4SigningProperties]
3030

3131
def __init__(
@@ -39,7 +39,6 @@ def __init__(
3939
:param identity_resolver: The identity resolver to extract the api key identity.
4040
:param signer: The signer used to sign the request.
4141
"""
42-
self.scheme_id = "aws.auth#sigv4"
4342
# TODO: There are type mismatches in the signature of the "sign" method.
4443
self.signer = signer or AsyncSigV4Signer() # type: ignore
4544

packages/smithy-aws-core/src/smithy_aws_core/credentials_resolvers/environment.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
# SPDX-License-Identifier: Apache-2.0
33
import os
44

5-
from smithy_aws_core.identity import AWSCredentialsIdentity, AWSCredentialsResolver
5+
from smithy_aws_core.identity import AWSCredentialsIdentity
6+
from smithy_core.aio.interfaces.identity import IdentityResolver
67
from smithy_core.exceptions import SmithyIdentityException
78
from smithy_core.interfaces.identity import IdentityProperties
89

910

10-
class EnvironmentCredentialsResolver(AWSCredentialsResolver):
11+
class EnvironmentCredentialsResolver(
12+
IdentityResolver[AWSCredentialsIdentity, IdentityProperties]
13+
):
1114
"""Resolves AWS Credentials from system environment variables."""
1215

1316
def __init__(self):

packages/smithy-aws-core/src/smithy_aws_core/credentials_resolvers/static.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
3-
from smithy_aws_core.identity import AWSCredentialsIdentity, AWSCredentialsResolver
3+
from smithy_aws_core.identity import AWSCredentialsIdentity
4+
from smithy_core.aio.interfaces.identity import IdentityResolver
45
from smithy_core.interfaces.identity import IdentityProperties
56

67

7-
class StaticCredentialsResolver(AWSCredentialsResolver):
8+
class StaticCredentialsResolver(
9+
IdentityResolver[AWSCredentialsIdentity, IdentityProperties]
10+
):
811
"""Resolve Static AWS Credentials."""
912

1013
def __init__(self, *, credentials: AWSCredentialsIdentity) -> None:

packages/smithy-aws-core/src/smithy_aws_core/identity.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,6 @@ def account_id(self) -> str | None:
6363
return self._account_id
6464

6565

66-
AWSCredentialsResolver = IdentityResolver[AWSCredentialsIdentity, IdentityProperties]
66+
type AWSCredentialsResolver = IdentityResolver[
67+
AWSCredentialsIdentity, IdentityProperties
68+
]

packages/smithy-aws-core/tests/unit/credentials_resolvers/test_environment_credentials_resolver.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,36 @@ async def test_no_values_set():
1515
)
1616

1717

18-
async def test_required_values_missing(monkeypatch): # type: ignore
19-
monkeypatch.setenv("AWS_ACCOUNT_ID", "123456789012") # type: ignore
18+
async def test_required_values_missing(monkeypatch: pytest.MonkeyPatch):
19+
monkeypatch.setenv("AWS_ACCOUNT_ID", "123456789012")
2020

2121
with pytest.raises(SmithyIdentityException):
2222
await EnvironmentCredentialsResolver().get_identity(
2323
identity_properties=IdentityProperties()
2424
)
2525

2626

27-
async def test_akid_missing(monkeypatch): # type: ignore
28-
monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "secret") # type: ignore
27+
async def test_akid_missing(monkeypatch: pytest.MonkeyPatch):
28+
monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "secret")
2929

3030
with pytest.raises(SmithyIdentityException):
3131
await EnvironmentCredentialsResolver().get_identity(
3232
identity_properties=IdentityProperties()
3333
)
3434

3535

36-
async def test_secret_missing(monkeypatch): # type: ignore
37-
monkeypatch.setenv("AWS_ACCESS_KEY_ID", "akid") # type: ignore
36+
async def test_secret_missing(monkeypatch: pytest.MonkeyPatch):
37+
monkeypatch.setenv("AWS_ACCESS_KEY_ID", "akid")
3838

3939
with pytest.raises(SmithyIdentityException):
4040
await EnvironmentCredentialsResolver().get_identity(
4141
identity_properties=IdentityProperties()
4242
)
4343

4444

45-
async def test_minimum_required(monkeypatch): # type: ignore
46-
monkeypatch.setenv("AWS_ACCESS_KEY_ID", "akid") # type: ignore
47-
monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "secret") # type: ignore
45+
async def test_minimum_required(monkeypatch: pytest.MonkeyPatch):
46+
monkeypatch.setenv("AWS_ACCESS_KEY_ID", "akid")
47+
monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "secret")
4848

4949
credentials = await EnvironmentCredentialsResolver().get_identity(
5050
identity_properties=IdentityProperties()
@@ -53,11 +53,11 @@ async def test_minimum_required(monkeypatch): # type: ignore
5353
assert credentials.secret_access_key == "secret"
5454

5555

56-
async def test_all_values(monkeypatch): # type: ignore
57-
monkeypatch.setenv("AWS_ACCESS_KEY_ID", "akid") # type: ignore
58-
monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "secret") # type: ignore
59-
monkeypatch.setenv("AWS_SESSION_TOKEN", "session") # type: ignore
60-
monkeypatch.setenv("AWS_ACCOUNT_ID", "123456789012") # type: ignore
56+
async def test_all_values(monkeypatch: pytest.MonkeyPatch):
57+
monkeypatch.setenv("AWS_ACCESS_KEY_ID", "akid")
58+
monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "secret")
59+
monkeypatch.setenv("AWS_SESSION_TOKEN", "session")
60+
monkeypatch.setenv("AWS_ACCOUNT_ID", "123456789012")
6161

6262
credentials = await EnvironmentCredentialsResolver().get_identity(
6363
identity_properties=IdentityProperties()

0 commit comments

Comments
 (0)