Skip to content

fix(utils): catch TypeError from inapplicable descriptors in DelegateAttributes#8079

Merged
jenshnielsen merged 1 commit intomicrosoft:mainfrom
jenshnielsen:jenshnielsen/fix_mock
Apr 29, 2026
Merged

fix(utils): catch TypeError from inapplicable descriptors in DelegateAttributes#8079
jenshnielsen merged 1 commit intomicrosoft:mainfrom
jenshnielsen:jenshnielsen/fix_mock

Conversation

@jenshnielsen
Copy link
Copy Markdown
Collaborator

@jenshnielsen jenshnielsen commented Apr 29, 2026

The descriptor introspection added in #8039 can find descriptors via the MRO that are not applicable to the current instance (e.g. type.__name__ invoked on a non-type object). This causes a TypeError when Python's inspect module calls getattr(obj, '__name__', None) on DelegateAttributes subclasses like GetLatest.

Catch TypeError in the descriptor __get__ call so that inapplicable descriptors fall through to the normal AttributeError path.

…Attributes

The descriptor introspection added in microsoft#8039 can find descriptors via the
MRO that are not applicable to the current instance (e.g. type.__name__
invoked on a non-type object). This causes a TypeError when Python's
inspect module calls getattr(obj, '__name__', None) on DelegateAttributes
subclasses like GetLatest.

Catch TypeError in the descriptor __get__ call so that inapplicable
descriptors fall through to the normal AttributeError path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jenshnielsen jenshnielsen requested a review from a team as a code owner April 29, 2026 07:45
@jenshnielsen jenshnielsen enabled auto-merge April 29, 2026 07:48
@jenshnielsen jenshnielsen disabled auto-merge April 29, 2026 07:53
@jenshnielsen jenshnielsen enabled auto-merge April 29, 2026 07:53
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.60%. Comparing base (5c75dd6) to head (42a99ae).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8079   +/-   ##
=======================================
  Coverage   70.59%   70.60%           
=======================================
  Files         333      333           
  Lines       32494    32497    +3     
=======================================
+ Hits        22940    22943    +3     
  Misses       9554     9554           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jenshnielsen jenshnielsen added this pull request to the merge queue Apr 29, 2026
Merged via the queue into microsoft:main with commit 2d4cee8 Apr 29, 2026
18 checks passed
@jenshnielsen jenshnielsen deleted the jenshnielsen/fix_mock branch April 29, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants