Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to suppress warning "Access to protected member" in pycharm method?

I have some class

class A(object):
    def __init__(self, data):
        self._data = data
    def _equals(self, other):
        return self._data == other._data

Pycharm doesn't like that I access other._data because it is private.

"Access to protected member"

This doesn't make sense to me, because the access is made from within the class.

How do I either suppress this warning, or write correct code?

like image 999
Gulzar Avatar asked Jun 04 '19 09:06

Gulzar


Video Answer


1 Answers

If you really need it, like namedlist's ._asdict(), the answer is Can I get PyCharm to suppress a particular warning on a single line?:

class A(object):
    def __init__(self, data):
        self._data = data
    def _equals(self, other):
        # noinspection PyProtectedMember
        return self._data == other._data
like image 146
Polv Avatar answered Sep 19 '22 09:09

Polv