@@ -116,7 +116,7 @@ A.implicit_self(1)
116116Passing ` self ` implicitly also verifies the type:
117117
118118``` py
119- from typing import Never
119+ from typing import Never, Callable
120120
121121class Strange :
122122 def can_not_be_called (self : Never) -> None : ...
@@ -139,6 +139,9 @@ The first parameter of instance methods always has type `Self`, if it is not exp
139139The name ` self ` is not special in any way.
140140
141141``` py
142+ def some_decorator (f : Callable) -> Callable:
143+ return f
144+
142145class B :
143146 def name_does_not_matter (this ) -> Self:
144147 reveal_type(this) # revealed: Self@name_does_not_matter
@@ -153,15 +156,37 @@ class B:
153156 reveal_type(self ) # revealed: Self@keyword_only
154157 return self
155158
159+ @some_decorator
160+ def decorated_method (self ) -> Self:
161+ reveal_type(self ) # revealed: Self@decorated_method
162+ return self
163+
156164 @ property
157165 def a_property (self ) -> Self:
158- # TODO : Should reveal Self@a_property
159- reveal_type(self ) # revealed: Unknown
166+ reveal_type(self ) # revealed: Self@a_property
160167 return self
161168
169+ @ staticmethod
170+ def static_method (self ):
171+ # The parameter can be called `self`, but it is not treated as `Self`
172+ reveal_type(self ) # revealed: Unknown
173+
174+ @ staticmethod
175+ @some_decorator
176+ def decorated_static_method (self ):
177+ # TODO : this should be Unknown
178+ reveal_type(self ) # revealed: Self@decorated_static_method
179+
180+ @some_decorator
181+ @ staticmethod
182+ def decorated_static_method (self ):
183+ # TODO : this should be Unknown
184+ reveal_type(self ) # revealed: Self@decorated_static_method
185+
162186reveal_type(B().name_does_not_matter()) # revealed: B
163187reveal_type(B().positional_only(1 )) # revealed: B
164188reveal_type(B().keyword_only(x = 1 )) # revealed: B
189+ reveal_type(B().decorated_method()) # revealed: Unknown
165190
166191# TODO : this should be B
167192reveal_type(B().a_property) # revealed: Unknown
0 commit comments