Skip to content

Commit 296811b

Browse files
committed
Remove explicit Config protocol
1 parent a7475d7 commit 296811b

File tree

5 files changed

+11
-48
lines changed

5 files changed

+11
-48
lines changed

codegen/core/src/main/java/software/amazon/smithy/python/codegen/generators/ConfigGenerator.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -290,18 +290,6 @@ private void writeInterceptorsType(PythonWriter writer) {
290290

291291
private void generateConfig(GenerationContext context, PythonWriter writer) {
292292
var configSymbol = CodegenUtils.getConfigSymbol(context.settings());
293-
Symbol configProtocolSymbol = null;
294-
if (context.applicationProtocol().isHttpProtocol()) {
295-
configProtocolSymbol = Symbol.builder()
296-
.name("HttpConfig")
297-
.namespace("smithy_http.interfaces.config", ".")
298-
.build();
299-
} else {
300-
configProtocolSymbol = Symbol.builder()
301-
.name("Config")
302-
.namespace("smithy_core.interfaces.config", ".")
303-
.build();
304-
}
305293

306294
// Initialize the list of config properties with our base properties. Here a new
307295
// list is constructed because that base list is immutable.
@@ -336,7 +324,7 @@ private void generateConfig(GenerationContext context, PythonWriter writer) {
336324
writer.addStdlibImport("dataclasses", "dataclass");
337325
writer.write("""
338326
@dataclass(init=False)
339-
class $T($T):
327+
class $T:
340328
\"""Configuration for $L.\"""
341329
342330
${C|}
@@ -353,7 +341,6 @@ def __init__(
353341
${C|}
354342
""",
355343
configSymbol,
356-
configProtocolSymbol,
357344
context.settings().service().getName(),
358345
writer.consumer(w -> writePropertyDeclarations(w, finalProperties)),
359346
writer.consumer(w -> writeInitParams(w, finalProperties)),

packages/smithy-core/src/smithy_core/interfaces/config.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

packages/smithy-http/src/smithy_http/interceptors/user_agent.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
33
import platform
4-
from typing import Self
4+
from typing import Self, Any
55

66
import smithy_core
7-
import smithy_http
8-
from smithy_core.aio.interfaces import Request
97
from smithy_core.interceptors import Interceptor, InterceptorContext
108
from smithy_http import Field
119
from smithy_http.aio.interfaces import HTTPRequest
1210
from smithy_http.user_agent import UserAgent, UserAgentComponent
1311

1412

15-
class UserAgentInterceptor(Interceptor[Request, None, HTTPRequest, None]):
13+
class UserAgentInterceptor(Interceptor[Any, None, HTTPRequest, None]):
1614
"""Adds interceptors that initialize UserAgent in the context and add the user-agent header"""
1715

18-
def read_before_execution(self, context: InterceptorContext[Request, None, None, None]) -> None:
16+
def read_before_execution(self, context: InterceptorContext[Any, None, None, None]) -> None:
1917
context.properties['user_agent'] = _UserAgentBuilder.from_environment().build()
2018

2119
def modify_before_signing(
22-
self, context: InterceptorContext[Request, None, HTTPRequest, None]
20+
self, context: InterceptorContext[Any, None, HTTPRequest, None]
2321
) -> HTTPRequest:
2422
user_agent = context.properties['user_agent']
2523
request = context.transport_request

packages/smithy-http/src/smithy_http/interfaces/config.py

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
3+
from typing import Protocol, Any
34

4-
from smithy_core.interfaces.config import Config
5+
from smithy_core.interceptors import Interceptor
56
from smithy_http.interceptors.user_agent import UserAgentInterceptor
67

7-
def user_agent_plugin(config: Config) -> None:
8+
class _InterceptorConfig(Protocol):
9+
interceptors: list[Interceptor[Any, Any, Any, Any]]
10+
11+
def user_agent_plugin(config: _InterceptorConfig) -> None:
812
config.interceptors.append(UserAgentInterceptor())

0 commit comments

Comments
 (0)