Incorrect "unresolved attribute reference" in dict

Answered

If I define the following block:

d = {
'prop1': defaultdict(int),
'prop2': defaultdict(list)
}

d['prop2']['entry1'].append(1)

I am getting "Unresolved attribute reference 'append' for class 'int'" which is obviously untrue because d['prop2'] is a defaultdict(list) not int.

0
3 comments

Hi,

I do not have such warning. What is your PyCharm version?

Are there any custom plugins in use?

0

Tried with 2018.1.6, still no warning.

Try File | Invalidate Caches / Restart... or update to a newer version of PyCharm.

 

0

Please sign in to leave a comment.