Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_dynamic_class_hook() not invoked on generic types #8359

Closed
mkurnikov opened this issue Feb 3, 2020 · 4 comments · Fixed by #16052
Closed

get_dynamic_class_hook() not invoked on generic types #8359

mkurnikov opened this issue Feb 3, 2020 · 4 comments · Fixed by #16052
Labels
topic-plugins The plugin API and ideas for new plugins

Comments

@mkurnikov
Copy link
Contributor

In Django, there's a method called as_manager() on QuerySet
https://docs.djangoproject.com/en/3.0/ref/models/querysets/#django.db.models.query.QuerySet.as_manager
which returns an instance of a dynamically created manager with callee QuerySet method copied inside

class AnonymousManager(models.Manager):
    ... methods of QuerySet callee copied ...

I'd like to be able to call it like with generic parameters

MyQuerySet[MyModel].as_manager()

Now, because of clause

            if isinstance(callee_expr, RefExpr) and callee_expr.fullname:
                method_name = call.callee.name
                fname = callee_expr.fullname + '.' + method_name

get_dynamic_class_hook() never called. callee_expr is TypeApplication here, not RefExpr.

@msullivan
Copy link
Collaborator

I'd be happy to review a PR if you send one!

@AlexWaygood AlexWaygood added the topic-plugins The plugin API and ideas for new plugins label Apr 4, 2022
@flaeppe
Copy link

flaeppe commented Sep 5, 2023

@sobolevn Seems that what I also discovered here typeddjango/django-stubs#1683 (comment) is already reported

@sobolevn
Copy link
Member

sobolevn commented Sep 5, 2023

@flaeppe do you want to contribute? :)
I would be happy to merge this feature, since it is affecting us for like 3 years now.

@flaeppe
Copy link

flaeppe commented Sep 5, 2023

Yeah, sure, I'll have a look as soon as I get some time

sobolevn pushed a commit that referenced this issue Sep 19, 2023
Fixes: #8359

CC @sobolevn 

`get_dynamic_class_hook()` will now additionally be called for generic
classes with parameters. e.g.

```python
y = SomeGenericClass[type, ...].method()
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-plugins The plugin API and ideas for new plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants