Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/suggestions.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def get_suggestion(self, mod: str, node: FuncDef) -> PyAnnotateSignature:
if self.no_errors and orig_errors:
raise SuggestionFailure("Function does not typecheck.")

is_method = bool(node.info) and not node.is_static
is_method = bool(node.info) and (not node.is_static or node.name == "__new__")

with state.strict_optional_set(graph[mod].options.strict_optional):
guesses = self.get_guesses(
Expand Down
20 changes: 20 additions & 0 deletions test-data/unit/fine-grained-suggest.test
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,26 @@ def bar(iany) -> None:
(int) -> None
==

[case testSuggestNewInit]
# suggest: foo.F.__init__
# suggest: foo.F.__new__
[file foo.py]
class F:
def __new__(cls, t):
return super().__new__(cls)

def __init__(self, t):
self.t = t

[file bar.py]
from foo import F
def bar(iany) -> None:
F(0)
[out]
(int) -> None
(int) -> Any
==

[case testSuggestColonBasic]
# suggest: tmp/foo.py:1
# suggest: tmp/bar/baz.py:2
Expand Down