Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved attribute reference 'keys' for class 'dict'

Tags:

pycharm

Pycharm highlights ".keys()" on line 5 and gives me following warning for it for this illustrative code:

1  def testfunc():
2      mydic = {}
3      for x in range(5):
4          mydic[x] = str(x)
5      elems = set(mydic.keys())

Python Interpretor: python2.7 from anaconda. Pycharm v2017.3

Can someone help me understand why do I get this warning? Everything works as expected.

Screenshots: enter image description here

enter image description here

enter image description here

like image 964
The Wanderer Avatar asked Jan 18 '18 23:01

The Wanderer


2 Answers

As per user2235698's comment above and based on my verification, this is because of a buggy pycharm version. Please update your pycharm.

like image 162
The Wanderer Avatar answered Sep 29 '22 19:09

The Wanderer


I've had this bug in PyCharm 2019.3 too. The problem was that the virtualenv I used was not excluded.

More details: https://youtrack.jetbrains.com/issue/PY-34943

like image 27
Adam Wallner Avatar answered Sep 29 '22 20:09

Adam Wallner