Skip to content
Merged
Changes from all commits
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
26 changes: 26 additions & 0 deletions crates/ty_python_semantic/resources/mdtest/call/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,32 @@ reveal_type(Derived.f(1)) # revealed: str
reveal_type(Derived().f(1)) # revealed: str
```

### Staticmethod assigned in class body

Assigning a `staticmethod(...)` object directly in the class body should preserve the callable
behavior of the wrapped function when accessed on both classes and instances.

```py
def foo(*args, **kwargs) -> None:
print("foo", args, kwargs)

class A:
__call__ = staticmethod(foo)
bar = staticmethod(foo)

a = A()
a()
a.bar()
a(5)
a.bar(5)
a(x=10)
a.bar(x=10)

A.bar()
A.bar(5)
A.bar(x=10)
```

### Accessing the staticmethod as a static member

```py
Expand Down
Loading