Unnecessary warning: int doesn't have expected attribute __getitem__

I get a warning for one of my functions, saying the type int doesn't have the expected attribute __getitem__. I know that this comes from this part:

type(rule[0]) == list

However, I don't know why PyCharm would assume that __getitem__ is required in this case for a value of type int. It would never reach this part of the code for an int. So my question is: Is this a bug? Can I somehow prevent this warning in this case?




Could you please provide me with a simplified code example so I will be able to reproduce this and report it as a bug if confirmed. 


Thank you in advance! 



while simplifying the example I noticed that's an error on my end. Instead of using

Rule = type(Union[int, str, List[int], List[List[int]]])

I should've used it without type() instead:

Rule = Union[int, str, List[int], List[List[int]]]

In this case PyCharm doesn't issue the warning.

Thank you. Should have tried that before, so I'd probably noticed it. :-)


Please sign in to leave a comment.