Confusing Inspection Warning

Answered

I drafted this message when trying to understand why a warning is being thrown by a PyCharm inspection. I have the following simplified code:

array = [[1,2,3],[4,5,6],[7,8,9]]
print(array[1][1])
array[1][1] = 'data'
print(array[1][1])

It works as expected when I run it.  However, the inspection scanner complains about the second index...

Screen shot:

I assumed there was a problem with the type of the index.  It took me some time to realize that it was concerned about the change in data type. 

 

In the case I'm working with the code is changing None to a float.  Is there a preferred way to handle this?

0
2 comments

Hi Berg,

It's an unfortunate but already known problem with type checking in assignments to nested collections: PY-31855 (I've updated it with your example). It's on our radars, please subscribe to the issue to get notified of the progress.

0

Perfect.  Thanks for the response.  I'm subscribed and will look forward to the release that fixes it.

0

Please sign in to leave a comment.