|
| 1 | +from __future__ import annotations |
| 2 | + |
1 | 3 | import inspect
|
2 | 4 | from collections.abc import Callable, Iterator, Sequence
|
3 | 5 | from typing import Any, Generic, Protocol, Self, TypeVar, overload
|
|
15 | 17 | from sentry.interfaces.exception import SingleException
|
16 | 18 | from sentry.interfaces.stacktrace import Frame, Stacktrace
|
17 | 19 |
|
18 |
| -STRATEGIES: dict[str, "Strategy[Any]"] = {} |
| 20 | +STRATEGIES: dict[str, Strategy[Any]] = {} |
19 | 21 |
|
20 | 22 | RISK_LEVEL_LOW = 0
|
21 | 23 | RISK_LEVEL_MEDIUM = 1
|
@@ -43,22 +45,22 @@ def __call__(
|
43 | 45 | self,
|
44 | 46 | interface: ConcreteInterface,
|
45 | 47 | event: Event,
|
46 |
| - context: "GroupingContext", |
| 48 | + context: GroupingContext, |
47 | 49 | **meta: Any,
|
48 | 50 | ) -> ReturnedVariants: ...
|
49 | 51 |
|
50 | 52 |
|
51 | 53 | class VariantProcessor(Protocol):
|
52 | 54 | def __call__(
|
53 |
| - self, variants: ReturnedVariants, context: "GroupingContext", **meta: Any |
| 55 | + self, variants: ReturnedVariants, context: GroupingContext, **meta: Any |
54 | 56 | ) -> ReturnedVariants: ...
|
55 | 57 |
|
56 | 58 |
|
57 | 59 | def strategy(
|
58 | 60 | ids: Sequence[str],
|
59 | 61 | interface: type[Interface],
|
60 | 62 | score: int | None = None,
|
61 |
| -) -> Callable[[StrategyFunc[ConcreteInterface]], "Strategy[ConcreteInterface]"]: |
| 63 | +) -> Callable[[StrategyFunc[ConcreteInterface]], Strategy[ConcreteInterface]]: |
62 | 64 | """
|
63 | 65 | Registers a strategy
|
64 | 66 |
|
@@ -89,7 +91,7 @@ def decorator(f: StrategyFunc[ConcreteInterface]) -> Strategy[ConcreteInterface]
|
89 | 91 |
|
90 | 92 |
|
91 | 93 | class GroupingContext:
|
92 |
| - def __init__(self, strategy_config: "StrategyConfiguration"): |
| 94 | + def __init__(self, strategy_config: StrategyConfiguration): |
93 | 95 | # The initial context is essentially the grouping config options
|
94 | 96 | self._stack = [strategy_config.initial_context]
|
95 | 97 | self.config = strategy_config
|
@@ -169,7 +171,7 @@ def _get_strategy_dict(
|
169 | 171 | return rv
|
170 | 172 |
|
171 | 173 |
|
172 |
| -def lookup_strategy(strategy_id: str) -> "Strategy[Any]": |
| 174 | +def lookup_strategy(strategy_id: str) -> Strategy[Any]: |
173 | 175 | """Looks up a strategy by id."""
|
174 | 176 | try:
|
175 | 177 | return STRATEGIES[strategy_id]
|
@@ -286,7 +288,7 @@ def get_grouping_components(self, event: Event, context: GroupingContext) -> Ret
|
286 | 288 |
|
287 | 289 | class StrategyConfiguration:
|
288 | 290 | id: str | None
|
289 |
| - base: type["StrategyConfiguration"] | None = None |
| 291 | + base: type[StrategyConfiguration] | None = None |
290 | 292 | config_class = None
|
291 | 293 | strategies: dict[str, Strategy[Any]] = {}
|
292 | 294 | delegates: dict[str, Strategy[Any]] = {}
|
|
0 commit comments