Skip to content

Commit

Permalink
Revert "Implicitly assign class type to the first parameter of its me…
Browse files Browse the repository at this point in the history
…thods (#1514) (#1586)"

This broke one of our repos ("client").

This reverts commit e45ac10.
  • Loading branch information
Guido van Rossum committed May 30, 2016
1 parent 6bbcc8d commit a9aeacc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
8 changes: 1 addition & 7 deletions mypy/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2140,14 +2140,8 @@ def function_type(func: FuncBase, fallback: 'mypy.types.Instance') -> 'mypy.type
for arg in fdef.arguments:
names.append(arg.variable.name())

if fdef.is_method() and not fdef.is_static and not fdef.is_class:
self_arg = [mypy.types.Instance(func.info, [])] # type: List[mypy.types.Type]
arg_types = self_arg + ([mypy.types.AnyType()] * (len(fdef.arguments) - 1))
else:
arg_types = [mypy.types.AnyType()] * len(fdef.arguments)

return mypy.types.CallableType(
arg_types,
[mypy.types.AnyType()] * len(fdef.arguments),
[arg.kind for arg in fdef.arguments],
names,
mypy.types.AnyType(),
Expand Down
6 changes: 3 additions & 3 deletions mypy/test/data/typexport-basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ class A:
def f(self): pass
A.f
[out]
MemberExpr(5) : def (self: A) -> Any
MemberExpr(5) : def (self: Any) -> Any

[case testOverloadedUnboundMethod]
## MemberExpr
Expand All @@ -914,7 +914,7 @@ class A:
def f(self, x): pass
A.f
[out]
MemberExpr(8) : Overload(def (self: A) -> Any, def (self: A, x: Any) -> Any)
MemberExpr(8) : Overload(def (self: Any) -> Any, def (self: Any, x: Any) -> Any)

[case testUnboundMethodWithInheritance]
## MemberExpr
Expand Down Expand Up @@ -977,7 +977,7 @@ class A(Generic[t]):
def f(self, x): pass
A.f(None, None)
[out]
MemberExpr(7) : def (self: A, x: Any) -> Any
MemberExpr(7) : def (self: Any, x: Any) -> Any

[case testGenericMethodOfGenericClass]
## MemberExpr
Expand Down

0 comments on commit a9aeacc

Please sign in to comment.