I like to create my own annotations or typing extensions in my project. Basically what I like to do is reuse type annotations across my project.
So, instead of typing List[Dict[str, pd.DataFrame]] hundred times, I want to save this to a python variable and reuse it that way. Sort of custom annotations.
How can we do that?
I tried NewType = List[Dict[str, pd.DataFrame]] but it doesnt work. In the sense that, the autocomplete features doesn’t come up suggesting the different functions/attributes for the object.
>Solution :
You can read about custom new types in here. It will help you more about this.
from typing import NewType, List, Dict
import pandas as pd
CustomType = NewType('CustomType',List[Dict[str, pd.DataFrame]])