Skip to content

fix: improve error handling for missing device attributes in DeviceCo…#979

Merged
cappel89 merged 1 commit into
mainfrom
fix/hidden_device_access
Jun 25, 2026
Merged

fix: improve error handling for missing device attributes in DeviceCo…#979
cappel89 merged 1 commit into
mainfrom
fix/hidden_device_access

Conversation

@wakonig

@wakonig wakonig commented Jun 24, 2026

Copy link
Copy Markdown
Member

Description

When a user would mistype and try to access something like

dev._samx

They would get a cryptic error that the super has no attribute "getattr". This PR fixes it by properly raising an AttributeError beforehand but only for dunder attributes. This was introduced in the past to inform the IPython tab completion about missing fields.

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@wakonig wakonig marked this pull request as ready for review June 24, 2026 15:09
Copilot AI review requested due to automatic review settings June 24, 2026 15:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts DeviceContainer.__getattr__ to avoid the confusing super()-related failure on missing “private”/special attribute lookups, improving the error surfaced to users and keeping introspection/IPython completion from being disrupted.

Changes:

  • Update DeviceContainer.__getattr__ to raise AttributeError for missing __* lookups while continuing to raise DeviceConfigError for missing device names.
  • Add a regression test ensuring missing single-underscore device lookups raise DeviceConfigError.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
bec_lib/bec_lib/devicemanager.py Changes DeviceContainer.__getattr__ handling for missing __* attributes to raise AttributeError for safer introspection.
bec_lib/tests/test_devices.py Adds a test for missing single-underscore attribute access on DeviceContainer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bec_lib/bec_lib/devicemanager.py
Comment thread bec_lib/tests/test_devices.py
@wakonig wakonig self-assigned this Jun 24, 2026
@wakonig wakonig requested a review from a team June 24, 2026 16:19
@cappel89 cappel89 merged commit 31378ad into main Jun 25, 2026
59 checks passed
@cappel89 cappel89 deleted the fix/hidden_device_access branch June 25, 2026 11:02
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.

3 participants