I am aware that circular dependencies is generally discouraged – yet, in C# and TypeScript I've sometimes found them useful. It might be my lack of experience with python, or maybe I'm thinking the wrong way or missing the right words to google for. How would I solve the following?
I'm trying to create a class that handles requests, and each of these handling events is accompanied by a context. So, I want to create the handler class, and the context class - but they are dependent, and the linter gives me problems on line 2, saying that HandlerService is not defined.
Example (dummy):
class HandlerContext:
def __init__(self, service : HandlerService, uuid : str):
self.service = service
self.uuid = uuid
class HandlerService:
def handle_request(self, context : HandlerContext, data : object):
# do things ...
pass