File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
packages/service-library/src/servicelib/fastapi
services/agent/src/simcore_service_agent/services Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change 1- import logging
1+ from typing import TypeVar
22
33from fastapi import FastAPI
44
5- _logger = logging . getLogger ( __name__ )
5+ T = TypeVar ( "T" , bound = "SingletonInAppStateMixin" )
66
77
88class SingletonInAppStateMixin :
@@ -14,7 +14,7 @@ class SingletonInAppStateMixin:
1414 frozen : bool = True # Will raise if set multiple times
1515
1616 @classmethod
17- def get_from_app_state (cls , app : FastAPI ):
17+ def get_from_app_state (cls : type [ T ] , app : FastAPI ) -> T :
1818 return getattr (app .state , cls .app_state_name )
1919
2020 def set_to_app_state (self , app : FastAPI ):
@@ -26,7 +26,7 @@ def set_to_app_state(self, app: FastAPI):
2626 return self .get_from_app_state (app )
2727
2828 @classmethod
29- def pop_from_app_state (cls , app : FastAPI ):
29+ def pop_from_app_state (cls : type [ T ] , app : FastAPI ) -> None :
3030 """
3131 Raises:
3232 AttributeError: if instance is not in app.state
Original file line number Diff line number Diff line change 2626
2727
2828@dataclass
29- class VolumesManager (SingletonInAppStateMixin ):
29+ class VolumesManager ( # pylint:disable=too-many-instance-attributes
30+ SingletonInAppStateMixin
31+ ):
3032 app : FastAPI
3133 book_keeping_interval : timedelta
3234 volume_cleanup_interval : timedelta
You can’t perform that action at this time.
0 commit comments