astroid icon indicating copy to clipboard operation
astroid copied to clipboard

Fix overzealous filtering of FunctionDef nodes in ClassDef.igetattr

Open nelfin opened this issue 3 years ago • 1 comments

Steps

  • [ ] For new features or bug fixes, add a ChangeLog entry describing what your PR does.
  • [x] Write a good description on what the PR does.

Description

Ref #1015. When there are multiple statements defining some attribute ClassDef.igetattr filters out later definitions if they are not in the same scope as the first (to support cases like "self.a = 1; self.a = 2" or "self.items = []; self.items += 1"). However, it checks the scope of the first attribute against the parent scope of the later attributes. For mundane statements this makes no difference, but for scope-introducing statements such as FunctionDef these are not the same.

Type of Changes

Type
:bug: Bug fix

Related Issue

Closes #1015

nelfin avatar Sep 15 '21 08:09 nelfin

@nelfin Just going through some stale PRs. Have you given the questions raised here some thoughts? Perhaps somewhat related is my comment here which also relates to "picking the correct definition".

DanielNoord avatar Dec 30 '21 17:12 DanielNoord

We're closing tons of duplicates for this in pylint. I think special-casing functions (sans properties) is good enough.

jacobtylerwalls avatar Feb 25 '24 00:02 jacobtylerwalls

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 92.75%. Comparing base (12ed435) to head (06a5f2b).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1173   +/-   ##
=======================================
  Coverage   92.75%   92.75%           
=======================================
  Files          94       94           
  Lines       11080    11084    +4     
=======================================
+ Hits        10277    10281    +4     
  Misses        803      803           
Flag Coverage Δ
linux 92.56% <100.00%> (+<0.01%) :arrow_up:
pypy 90.76% <100.00%> (+<0.01%) :arrow_up:
windows 92.34% <100.00%> (+<0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
astroid/nodes/scoped_nodes/scoped_nodes.py 92.52% <100.00%> (+0.02%) :arrow_up:

codecov[bot] avatar Feb 25 '24 00:02 codecov[bot]