I have a 3rd-party web-framework which has type hints in some of its code. I can not control the code of the said framework
Suppose I have following piece
from framework import web
...
class UserPosts(web.WebView):
async def get(self):
user_id = await self.request.user_dict['id']
...
web.WebView
class has type hints in its code and request
attribute is marked as an instance of a specific class which doesn't have user_dict
attr in definition because it is a dict that my custom made middleware dynamically attaches to the request instance.
I want to provide type hint for user_dict
but I don't understand how this can be approached.
Can someone help me with a tip about the right direction?
Thanks.
Define a new class, and override the ctor within that class:
So far nothing has changed.
Now adjust the constructor so it uses proper type hints, add logging and parameter validation to taste, the world is your oyster!