From 95207d08f096584d17b9643348e857e10d8c993c Mon Sep 17 00:00:00 2001 From: "Michael J. Sullivan" Date: Mon, 18 Nov 2019 11:54:18 -0800 Subject: [PATCH] Fix plugin invocation on classmethod calls through `Type` We weren't computing the proper fullname through TypeType (only through type obj callables. Maybe we should get rid of those...) This fixes these getting missed by suggestions. --- mypy/checkexpr.py | 2 ++ test-data/unit/fine-grained-suggest.test | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/mypy/checkexpr.py b/mypy/checkexpr.py index 72da7663ce4a..0f83d335221a 100644 --- a/mypy/checkexpr.py +++ b/mypy/checkexpr.py @@ -382,6 +382,8 @@ def method_fullname(self, object_type: Type, method_name: str) -> Optional[str]: # We "unwrap" it to a regular type, as the class/instance method difference doesn't # affect the fully qualified name. object_type = get_proper_type(object_type.ret_type) + elif isinstance(object_type, TypeType): + object_type = object_type.item type_name = None if isinstance(object_type, Instance): diff --git a/test-data/unit/fine-grained-suggest.test b/test-data/unit/fine-grained-suggest.test index c2b5a4cba562..fbcc1a57cb25 100644 --- a/test-data/unit/fine-grained-suggest.test +++ b/test-data/unit/fine-grained-suggest.test @@ -684,10 +684,11 @@ No guesses that match criteria! () -> None == -[case testSuggestInferClassMethod] +[case testSuggestClassMethod] # flags: --strict-optional # suggest: foo.F.bar # suggest: foo.F.baz +# suggest: foo.F.eggs [file foo.py] class F: @classmethod @@ -698,6 +699,15 @@ class F: def baz(x, y): return x + @classmethod + def spam(cls): + # type: () -> None + cls.eggs(4) + + @classmethod + def eggs(cls, x): + pass + [file bar.py] from foo import F def bar(iany) -> None: @@ -709,6 +719,7 @@ def bar(iany) -> None: [out] (int, int) -> int (str, int) -> str +(int) -> None == [case testSuggestColonBasic] pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy