Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to offer more helpful error message if str fallback is used wi… #752

Merged
merged 4 commits into from
Jan 28, 2025

Conversation

jwlodek
Copy link
Member

@jwlodek jwlodek commented Jan 27, 2025

…th enum

Addresses #750

@jwlodek jwlodek requested a review from DominicOram January 27, 2025 17:09
Copy link
Contributor

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

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

Awesome, thank you for addressing this quickly! I've added a couple of nit-picks but they're just over style, take them or leave them

src/ophyd_async/epics/core/_aioca.py Outdated Show resolved Hide resolved
Comment on lines 308 to 318
if valid_choices is not None and len(valid_choices) > 0:
if value not in valid_choices:
msg = (
f"{value} is not a valid choice for {self.write_pv}, "
f"valid choices: {self.converter.metadata.get('choices')}"
)
raise ValueError(msg) from exc
else:
raise
else:
raise
Copy link
Contributor

Choose a reason for hiding this comment

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

Could: I don't think the else statements are needed:

Suggested change
if valid_choices is not None and len(valid_choices) > 0:
if value not in valid_choices:
msg = (
f"{value} is not a valid choice for {self.write_pv}, "
f"valid choices: {self.converter.metadata.get('choices')}"
)
raise ValueError(msg) from exc
else:
raise
else:
raise
if valid_choices is not None and len(valid_choices) > 0:
if value not in valid_choices:
msg = (
f"{value} is not a valid choice for {self.write_pv}, "
f"valid choices: {self.converter.metadata.get('choices')}"
)
raise ValueError(msg) from exc
raise

@jwlodek jwlodek merged commit c867932 into bluesky:main Jan 28, 2025
14 of 15 checks passed
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