I have the following piece of code:
for table in list(my_dict.keys()):
if table in my_other_dict:
for file in my_dict[table]:
if file in my_other_dict[table]:
my_dict[table].remove(file)
if not my_dict[table]:
del my_dict[table]
But the second, third and fourth my_dict
reference is underlined with the following error:
Subscript for class "dict" will generate runtime exception; enclose type annotation in quotes
The only more or less relevant internet source I can find about it is this post, but I do not understand how I can apply it to my case.
Indeed, when this little piece of code is executed, there is no runtime exception.
Moreover, the last my_dict
reference is underlined with the following error message:
Generic class type cannot be deleted
This dictionary is built and returned by the following function (signature only, content is too big):
def meta_from_iso_to_utf(self, correct_meta_files):
How do I fix my code so that pylance stops complaining about these problems which do not seem to be problems as the code runs as expected ?
Edit 1 (to answer Frank's comment):
my_dict
is defined like this:
some_dict, my_dict = object.meta_from_iso_to_utf(
argument
)
In the method, the my_dict
is defined like so in a loop:
my_dict[key].append[value[0]]
table
is the variable containing the keys of my_dict
during the loop, which is a string. This variable is used only in this loop.
Concerning my editor, it is visual studio code 1.60.1
, with the Python extension from microsoft version v2021.9.1246542782