# Allow self binding for generic ParamSpec

**URL:** <https://discuss.python.org/t/allow-self-binding-for-generic-paramspec/50948>\
**Category:** Typing\
**Created:** [April 14, 2024, 1:29pm UTC](https://discuss.python.org/t/allow-self-binding-for-generic-paramspec/50948 "2024-04-14T13:29:47Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![cdce8p](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cdce8p/32/3575_2.png) [@cdce8p](https://discuss.python.org/u/cdce8p)\
**Post date:** [April 14, 2024, 10:16pm UTC](https://discuss.python.org/t/allow-self-binding-for-generic-paramspec/50948/4 "2024-04-14T22:16:23Z")

</div>

> [@erictraut](#):
>
> When you call `self.method2(2)`, the first parameter (which I renamed `__self`) is bound to an instance of `Wrapper`. There is no opportunity to bind the second parameter (`self`) to an instance of `A`.
> 
> I’m not sure what you’re proposing when you say “allow self binding for generic ParamSpec”.

I think of it as implicitly passing `Self@A` as argument if `method2` is called with `self`, `type[Self]@A` in case the method is a `@classmethod` and not passing it for `@staticmethod` (same as for `A.method2`).

> [@erictraut](#):
>
> I’ll note that this gets even more complicated when a return type is captured along with a signature and that return type depends on the type of the `self` parameter. For example:

Return `Self` is indeed an interesting case. Notably, it doesn’t work currently with neither pyright nor mypy. For `reveal_type(self.method2()` pyright returns `Unknown`, whereas mypy even complains about a missing positional argument “self” and infers it as `Never`. This At least for mypy this suggests to me that the `Self@A` instance isn’t passed along which this proposal aims to resolve.

With the mypy change above, it would be inferred as `R'5` i.e. `Any`.

---

_[View the full topic](https://discuss.python.org/t/allow-self-binding-for-generic-paramspec/50948)._
