|
4 | 4 | import copy |
5 | 5 | import re |
6 | 6 | from collections.abc import Callable |
7 | | -from typing import Any, Final, Generic, TypeVar |
| 7 | +from typing import Any, Final |
8 | 8 |
|
9 | 9 | from botocore.exceptions import ClientError |
10 | 10 |
|
|
79 | 79 | "AWS::NotificationARNs", |
80 | 80 | } |
81 | 81 |
|
82 | | -TBefore = TypeVar("TBefore") |
83 | | -TAfter = TypeVar("TAfter") |
84 | | -_T = TypeVar("_T") |
85 | 82 |
|
86 | 83 | REGEX_OUTPUT_APIGATEWAY = re.compile( |
87 | 84 | rf"^(https?://.+\.execute-api\.)(?:[^-]+-){{2,3}}\d\.(amazonaws\.com|{_AWS_URL_SUFFIX})/?(.*)$" |
|
91 | 88 | VALID_LOGICAL_RESOURCE_ID_RE = re.compile(r"^[A-Za-z0-9]+$") |
92 | 89 |
|
93 | 90 |
|
94 | | -class PreprocEntityDelta(Generic[TBefore, TAfter]): |
| 91 | +class PreprocEntityDelta[TBefore, TAfter]: |
95 | 92 | before: Maybe[TBefore] |
96 | 93 | after: Maybe[TAfter] |
97 | 94 |
|
@@ -432,16 +429,16 @@ def _maybe_perform_static_replacements(self, delta: PreprocEntityDelta) -> Prepr |
432 | 429 | def _maybe_perform_dynamic_replacements(self, delta: PreprocEntityDelta) -> PreprocEntityDelta: |
433 | 430 | return self._maybe_perform_on_delta(delta, self._perform_dynamic_replacements) |
434 | 431 |
|
435 | | - def _maybe_perform_on_delta( |
436 | | - self, delta: PreprocEntityDelta | None, f: Callable[[_T], _T] |
| 432 | + def _maybe_perform_on_delta[T]( |
| 433 | + self, delta: PreprocEntityDelta | None, f: Callable[[T], T] |
437 | 434 | ) -> PreprocEntityDelta | None: |
438 | 435 | if isinstance(delta.before, str): |
439 | 436 | delta.before = f(delta.before) |
440 | 437 | if isinstance(delta.after, str): |
441 | 438 | delta.after = f(delta.after) |
442 | 439 | return delta |
443 | 440 |
|
444 | | - def _perform_dynamic_replacements(self, value: _T) -> _T: |
| 441 | + def _perform_dynamic_replacements[T](self, value: T) -> T: |
445 | 442 | if not isinstance(value, str): |
446 | 443 | return value |
447 | 444 |
|
|
0 commit comments