Skip to content

Commit b0f7a24

Browse files
committed
python#1727: fine-grained.test for classmethod
1 parent 05b8dff commit b0f7a24

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

‎test-data/unit/fine-grained.test‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,6 +2143,51 @@ main:3: note: Possible overload variants:
21432143
main:3: note: def foo(cls: Wrapper, x: int) -> int
21442144
main:3: note: def foo(cls: Wrapper, x: str) -> str
21452145

2146+
[case testInitMovesAroundClassmethod]
2147+
[file m.py]
2148+
class C:
2149+
def __init__(self, x: int) -> None:
2150+
self._x = x
2151+
@classmethod
2152+
def create(cls, x: int) -> 'C':
2153+
return cls(x)
2154+
[file m.py.2]
2155+
class C:
2156+
@classmethod
2157+
def create(cls, x: int) -> 'C':
2158+
return cls(x)
2159+
def __init__(self, x: int) -> None:
2160+
self._x = x
2161+
[file m.py.3]
2162+
class C:
2163+
def __init__(self, x: int) -> None:
2164+
self._x = x
2165+
@classmethod
2166+
def create(cls, x: int) -> 'C':
2167+
return cls(x)
2168+
[builtins fixtures/classmethod.pyi]
2169+
[out]
2170+
==
2171+
==
2172+
2173+
[case testInitDisappearsClassmethodStays]
2174+
[file m.py]
2175+
class C:
2176+
def __init__(self, x: int) -> None:
2177+
self._x = x
2178+
@classmethod
2179+
def create(cls, x: int) -> 'C':
2180+
return cls(x)
2181+
[file m.py.2]
2182+
class C:
2183+
@classmethod
2184+
def create(cls, x: int) -> 'C':
2185+
return cls(x)
2186+
[builtins fixtures/classmethod.pyi]
2187+
[out]
2188+
==
2189+
m.py:4: error: Too many arguments for "C"
2190+
21462191
[case testRefreshGenericClass]
21472192
from typing import TypeVar, Generic
21482193
from a import A

0 commit comments

Comments
 (0)