I have a dictionary with different types, and in my code, while reading the dictionary through a loop, based on the type of it, I have different operations. The code is working as expected, but MYPY is complaining that it is incorrect. Here is the sample code:
COL = {"ABC": ["col1","col2","col3", ],"BBC": ["col1","col2","col3", ],"XYZ": {"col1": "c1","col2": "c2","col3": "c3", },}list(COL[table_name].keys()) if isinstance(COL[table_name], dict) else COL[table_name]
Mypy reports the error: error: "Collection[str]" has no attribute "values"
It looks like the if condition was not taken into consideration.
Tried type annotations for COL but did not work.