15

This inspection reports discrepancies between declared parameters and actual arguments, as well as incorrect arguments (e.g. duplicate named arguments) and incorrect argument order. Decorators are analyzed, too.

^That's what PyCharm is telling me. It's a weak warning, so my code runs fine.

import collections
var_dict = {}
var_dict = collections.OrderedDict(sorted(var_dict.items()))

^This is the line of code in question. I believe the warning has to do with the OrderedDict call.

I checked the OrderedDict documentation for Python 3.5, but I'm still nonplussed.

Why am I getting this warning? I'm using PyCharm Community Edition 5.0.1

michen00
  • 764
  • 1
  • 8
  • 32

2 Answers2

21

I posted an issue - having similar warnings in Python 2. I believe it's a bug in their inspection (in PyCharm 5), but let's see how they respond.

To moderators: this is a valid answer as recognized by the OP. It is not a "comment". Please read carefully before deleting.

Community
  • 1
  • 1
Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
  • 1
    OP here. Yes, a bug would explain why I have a weak warning still. If no new news appears before tomorrow, when the bounty expires, I will accept this answer. – michen00 Nov 23 '15 at 19:53
  • 3
    Your issue appears to have been fixed, but only in isolated cases. In particular [a new issue](https://youtrack.jetbrains.com/issue/PY-21415#u=1478850741679) identifies false warnings with e.g. `collections.defaultdict(None, dict(a=1))` or `collections.OrderedDict(dict(a=1))` – Bob Stein Sep 24 '17 at 16:38
0

So in my case I have a class with a __new__ method which contains the allowed input arguments but I lacked the __init__ method because my class is immutable. My code that has this warning looks like instance = MyClass(a=1, b=2) Copying over the __new__ method signature into __init__ made this warning go away.

spacether
  • 2,136
  • 1
  • 21
  • 28