Skip to content

Commit da084eb

Browse files
committed
3.10 is a lost cause
1 parent f8ccd4c commit da084eb

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

steam/ext/commands/commands.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,10 @@ def callback(
246246
function.__annotations__ = annotations = typing_extensions.get_type_hints(function)
247247
for name, annotation in annotations.items():
248248
if get_origin(annotation) is converters.Greedy and isinstance(annotation.converter, ForwardRef):
249-
function.__annotations__[name] = converters.Greedy[
250-
eval(annotation.converter.__forward_code__, function.__globals__)
251-
]
249+
annotations[name] = converters.Greedy[eval(annotation.converter.__forward_code__, function.__globals__)]
252250
self.params = dict(inspect.signature(function, eval_str=True).parameters)
253251
if not self.params:
254252
raise TypeError(f'Callback for {self.name} command is missing a "ctx" parameter.') from None
255-
for param in self.params.values():
256-
annotation = param.annotation
257-
if get_origin(annotation) is converters.Greedy and isinstance(annotation.converter, ForwardRef):
258-
param._annotation = converters.Greedy[eval(annotation.converter.__forward_code__, function.__globals__)] # type: ignore
259253

260254
self.module = function.__module__
261255
self._callback = function

tests/unit/test_commands.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# ruff: noqa: F811
22
import contextlib
3+
import sys
34
import traceback
45
from collections.abc import AsyncGenerator
56
from copy import copy
@@ -71,10 +72,20 @@ async def convert(self, ctx: commands.Context, argument: str) -> tuple[Any, ...]
7172
(str, pytest.raises(TypeError)),
7273
(int, contextlib.nullcontext(int)),
7374
(CustomConverter, contextlib.nullcontext(CustomConverter)),
74-
("None", pytest.raises(TypeError)),
75-
("str", pytest.raises(TypeError)),
76-
("int", contextlib.nullcontext(int)),
77-
],
75+
]
76+
+ (
77+
[
78+
("None", pytest.raises(TypeError)),
79+
("str", pytest.raises(TypeError)),
80+
("int", contextlib.nullcontext(int)),
81+
]
82+
if sys.version_info
83+
< (
84+
3,
85+
11,
86+
) # honestly considering how broken the 3.10 behaviour is I CBA fixing it, don't put your args in strings people
87+
else []
88+
),
7889
)
7990
def test_greedy(param_type: type | str, result: contextlib.AbstractContextManager[Any]) -> None:
8091
global param_type_ # hack to make typing.get_type_hints work with locals

0 commit comments

Comments
 (0)