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

HTTPMethodView subclass not supports generics #2938

Open
1 task done
elenlee opened this issue Apr 10, 2024 · 0 comments
Open
1 task done

HTTPMethodView subclass not supports generics #2938

elenlee opened this issue Apr 10, 2024 · 0 comments
Labels

Comments

@elenlee
Copy link

elenlee commented Apr 10, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

For Python3.12 generic classes the following is ok:

class Foo0: ...
class Foo1[T](Foo0): ...
class Foo2(Foo1[int]): ...

But for HTTPMethodView subclass there is an error:

from sanic.views import HTTPMethodView

class Bar1[T](HTTPMethodView): ...
class Bar2(Bar1[int]): ...
    class Bar2(Bar1[int]): ...
               ~~~~^^^^^
  File "/usr/local/lib/python3.12/typing.py", line 374, in inner
    return _caches[func](*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/typing.py", line 1055, in _generic_class_getitem
    for param in cls.__parameters__:
                 ^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Bar1' has no attribute '__parameters__'

Code snippet

No response

Expected Behavior

No error expected

How do you run Sanic?

As a script (app.run or Sanic.serve)

Operating System

Linux

Sanic Version

Sanic 23.12.1; Routing 23.12.0

Additional context

No response

@elenlee elenlee added the bug label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant