Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 2.7 warning: __init__ not compatible to __new__

I have a class defined in Python 2.7 like this:

from future.builtins import object


class Point(object):

    def __init__(self, x, y):
        self.x = x
        self.y = y

In PyCharm, this gives a warning in the __init__ line:

Signature is not compatible to __new__.

I don't understand what this warning is telling me. Can someone give an example where this warning would rightfully catch an error or can this warning be turned off?

There's a PyCharm thread for this, but it doesn't help me: https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000254530-PyCharm-init-Signature-is-not-compatible-to-new-

like image 265
knub Avatar asked Aug 31 '18 08:08

knub


1 Answers

I suffered from the same problem and found the solution in here.

As discussed in the above link, a direct solution is to remove your Pycharm config directory ("/home/username/.PyCharm2018.3" for me). However, it would remove all your other configs too. Finally, I just fix the problem by removing the rule from inspections. You can find the rule in the Pycharm Setting window (see the figure as follow). enter image description here

like image 63
Xiong-Hui Chen Avatar answered Nov 10 '22 05:11

Xiong-Hui Chen