Skip to content

Commit 7006264

Browse files
committed
Fixes some TODOs
1 parent a355314 commit 7006264

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

classes/contrib/mypy/features/typeclass.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,18 @@ def _add_new_instance_type(
201201
len(ctx.context.decorators) > 1
202202
)
203203
if has_multiple_decorators:
204-
# TODO: what happens here?
204+
# If we have multiple decorators on a function,
205+
# it is not safe to assume
206+
# that all the regular instance type is fine. Here's an example:
207+
#
208+
# @some.instance(str)
209+
# @other.instance(int)
210+
# (instance: Union[str, int]) -> ...
211+
#
212+
# So, if we just copy copy `instance`,
213+
# both typeclasses will have both `int` and `str`
214+
# as their instance types. This is not what we want.
215+
# We want: `some` to have `str` and `other` to have `int`
205216
new_type = inference.infer_runtime_type_from_context(
206217
fallback=new_type,
207218
fullname=fullname,

classes/contrib/mypy/typeops/type_loader.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ def load_typeclass(
3131
fullname: str,
3232
ctx: MethodContext,
3333
) -> Instance:
34-
"""
35-
Loads given typeclass from a symboltable by a fullname.
36-
37-
There are two ways to load a typeclass by name:
38-
# TODO
39-
"""
34+
"""Loads given typeclass from a symboltable by a fullname."""
4035
typeclass_info = ctx.api.lookup_qualified(fullname) # type: ignore
4136
assert isinstance(typeclass_info.type, Instance)
4237
return typeclass_info.type

0 commit comments

Comments
 (0)