Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions pylint/checkers/classes/class_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,13 +470,8 @@ def _is_attribute_property(name: str, klass: nodes.ClassDef) -> bool:
inferred
):
return True
if inferred.pytype() != property_name:
continue

cls = node_frame_class(inferred)
if cls == klass.declared_metaclass():
continue
return True
if inferred.pytype() == property_name:
return True
return False


Expand Down
12 changes: 0 additions & 12 deletions tests/functional/p/protected_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,6 @@ def __init__(self):
OBJ._teta # [protected-access]


# Make sure protect-access doesn't raise an exception Uninferable attributes
class MC:
@property
def nargs(self):
return 1 if self._nargs else 2
Comment on lines -24 to -26
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just remove the property and see if the tests still passes?

Copy link
Contributor Author

@temyurchenko temyurchenko Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I comment out @property, it does pass



class Application(metaclass=MC):
def __no_special__(cls):
nargs = obj._nargs # [protected-access]


class Light:
@property
def _light_internal(self) -> None:
Expand Down
5 changes: 2 additions & 3 deletions tests/functional/p/protected_access.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
protected-access:19:0:19:9::Access to a protected member _teta of a client class:UNDEFINED
protected-access:31:16:31:26:Application.__no_special__:Access to a protected member _nargs of a client class:UNDEFINED
protected-access:41:14:41:35:Light.func:Access to a protected member _light_internal of a client class:UNDEFINED
protected-access:45:10:45:31:func:Access to a protected member _light_internal of a client class:UNDEFINED
protected-access:29:14:29:35:Light.func:Access to a protected member _light_internal of a client class:UNDEFINED
protected-access:33:10:33:31:func:Access to a protected member _light_internal of a client class:UNDEFINED
Loading