11from collections import defaultdict
2- from typing import Any , Dict , Optional , Sequence , Tuple , Type
2+ from typing import Any , Dict , Optional , Sequence , Tuple , Type , Union
33
44from django .apps import apps
55from django .db import models as django_models
@@ -19,7 +19,7 @@ class DABContentTypeManager(django_models.Manager["DABContentType"]):
1919
2020 def __init__ (self , * args : Any , ** kwargs : Any ) -> None :
2121 super ().__init__ (* args , ** kwargs )
22- self ._cache : Dict [str , Dict [Tuple [str , str , str ] | int , "DABContentType" ]] = {}
22+ self ._cache : Dict [str , Dict [Union [ Tuple [str , str , str ], int ] , "DABContentType" ]] = {}
2323
2424 def clear_cache (self ) -> None :
2525 self ._cache .clear ()
@@ -40,13 +40,13 @@ def _get_from_cache(self, opts: Options, service: str) -> "DABContentType":
4040 key = (service , opts .app_label , opts .model_name )
4141 return self ._cache [self .db ][key ]
4242
43- def _get_opts (self , model : Type [django_models .Model ] | django_models .Model , for_concrete_model : bool ) -> Options :
43+ def _get_opts (self , model : Union [ Type [django_models .Model ], django_models .Model ] , for_concrete_model : bool ) -> Options :
4444 """Return the ``Options`` object for ``model``."""
4545 return model ._meta .concrete_model ._meta if for_concrete_model else model ._meta
4646
4747 def get_for_model (
4848 self ,
49- model : Type [django_models .Model ] | django_models .Model ,
49+ model : Union [ Type [django_models .Model ], django_models .Model ] ,
5050 for_concrete_model : bool = True ,
5151 service : Optional [str ] = None ,
5252 ) -> "DABContentType" :
@@ -71,7 +71,7 @@ def get_for_model(
7171
7272 def get_for_models (
7373 self ,
74- * model_list : Type [django_models .Model ] | django_models .Model ,
74+ * model_list : Union [ Type [django_models .Model ], django_models .Model ] ,
7575 for_concrete_models : bool = True ,
7676 service : Optional [str ] = None ,
7777 ) -> Dict [Type [django_models .Model ], "DABContentType" ]:
@@ -191,7 +191,7 @@ def model_class(self) -> Optional[Type[django_models.Model]]:
191191 except LookupError :
192192 return None
193193
194- def get_object_for_this_type (self , ** kwargs : Any ) -> django_models .Model | RemoteObject :
194+ def get_object_for_this_type (self , ** kwargs : Any ) -> Union [ django_models .Model , RemoteObject ] :
195195 """Return the object referenced by this content type."""
196196 model = self .model_class ()
197197 if model is None :
@@ -201,7 +201,7 @@ def get_object_for_this_type(self, **kwargs: Any) -> django_models.Model | Remot
201201 return get_remote_object_class ()(self , object_id )
202202 return model ._base_manager .get (** kwargs )
203203
204- def get_all_objects_for_this_type (self , ** kwargs : Any ) -> django_models .QuerySet | Sequence [django_models .Model | RemoteObject ]:
204+ def get_all_objects_for_this_type (self , ** kwargs : Any ) -> Union [ django_models .QuerySet , Sequence [Union [ django_models .Model , RemoteObject ]] ]:
205205 """Return all objects referenced by this content type."""
206206 model = self .model_class ()
207207 if model is None :
0 commit comments