temp2
This commit is contained in:
parent
665ef9f495
commit
1efb8b90ba
|
@ -103,9 +103,29 @@ def cached_function_method_attribute(ctx: AttributeContext) -> mypy.types.Type:
|
||||||
ctx.default_attr_type.type.fullname
|
ctx.default_attr_type.type.fullname
|
||||||
== "synapse.util.caches.descriptors.CachedFunction"
|
== "synapse.util.caches.descriptors.CachedFunction"
|
||||||
):
|
):
|
||||||
|
if getattr(ctx.context, "name") == "did_forget":
|
||||||
|
breakpoint()
|
||||||
|
|
||||||
# Unwrap the wrapped function.
|
# Unwrap the wrapped function.
|
||||||
return _unwrap_cached_decoratored_function(
|
wrapped_signature = ctx.default_attr_type.args[0]
|
||||||
ctx.default_attr_type.args[0], ctx.api
|
assert isinstance(wrapped_signature, CallableType)
|
||||||
|
|
||||||
|
# 1. Mark this as a bound function signature.
|
||||||
|
signature: CallableType = bind_self(wrapped_signature)
|
||||||
|
|
||||||
|
# 4. Ensure the return type is a Deferred.
|
||||||
|
ret_arg = _get_true_return_type(signature)
|
||||||
|
|
||||||
|
# This should be able to use api.named_generic_type, but that doesn't seem
|
||||||
|
# to find the correct symbol for anything more than 1 module deep.
|
||||||
|
#
|
||||||
|
# modules is not part of CheckerPluginInterface. The following is a combination
|
||||||
|
# of TypeChecker.named_generic_type and TypeChecker.lookup_typeinfo.
|
||||||
|
sym = ctx.api.modules["twisted.internet.defer"].names.get("Deferred") # type: ignore[attr-defined]
|
||||||
|
ret_type = Instance(sym.node, [remove_instance_last_known_values(ret_arg)])
|
||||||
|
|
||||||
|
return ctx.default_attr_type.copy_modified(
|
||||||
|
args=[signature.copy_modified(ret_type=ret_type)]
|
||||||
)
|
)
|
||||||
|
|
||||||
return ctx.default_attr_type
|
return ctx.default_attr_type
|
||||||
|
|
Loading…
Reference in New Issue