The Wanderer
The Wanderer

Reputation: 3271

Unresolved attribute reference 'keys' for class 'dict'

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

Upvotes: 13

Views: 15265

Answers (2)

The Wanderer
The Wanderer

Reputation: 3271

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

Upvotes: 8

Adam Wallner
Adam Wallner

Reputation: 2412

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

Upvotes: 5

Related Questions