mirror of
https://github.com/django-components/django-components.git
synced 2025-09-26 15:39:08 +00:00
Remove typing-extensions
This commit is contained in:
parent
25fe39c6d6
commit
b58100eb9d
1 changed files with 14 additions and 2 deletions
|
@ -1,9 +1,21 @@
|
|||
try:
|
||||
from typing import Annotated
|
||||
except ImportError:
|
||||
from typing_extensions import Annotated
|
||||
|
||||
html = Annotated[str, "html"]
|
||||
class Annotated:
|
||||
def __init__(self, type_, *args, **kwargs):
|
||||
self.type_ = type_
|
||||
self.metadata = args, kwargs
|
||||
|
||||
def __repr__(self):
|
||||
return f"Annotated[{self.type_}, {self.metadata[0]!r}, {self.metadata[1]!r}]"
|
||||
|
||||
def __getitem__(self, params):
|
||||
if not isinstance(params, tuple):
|
||||
params = (params,)
|
||||
return Annotated(self.type_, *params, **self.metadata[1])
|
||||
|
||||
|
||||
css = Annotated[str, "css"]
|
||||
django_html = Annotated[str, "django_html"]
|
||||
js = Annotated[str, "js"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue