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

Raise ValueError for unknown formats in the import/export OD APIs #476

Conversation

erlend-aasland
Copy link
Contributor

Fixes #475

@codecov-commenter
Copy link

codecov-commenter commented Jul 2, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.68%. Comparing base (5734f37) to head (bb1f9e9).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #476      +/-   ##
==========================================
+ Coverage   67.55%   67.68%   +0.12%     
==========================================
  Files          26       26              
  Lines        3101     3104       +3     
  Branches      521      521              
==========================================
+ Hits         2095     2101       +6     
+ Misses        864      862       -2     
+ Partials      142      141       -1     
Files Coverage Δ
canopen/objectdictionary/__init__.py 82.29% <100.00%> (+1.16%) ⬆️

Copy link
Collaborator

@acolomb acolomb left a comment

Choose a reason for hiding this comment

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

This looks fine overall. But I still favor ValueError in these cases, as it is simply an invalid string being passed for the parameter. Such things should be sanitized / limited before calling the function IMHO. If it comes from a config file, ValueError will be a correct description of th failure cause. In contrast, ObjectDictionaryError concerns invalid operations using the OD, as its docstring states: """Unsupported operation with the current Object Dictionary."""

@erlend-aasland
Copy link
Contributor Author

I'm fine with ValueError; it is a good alternative to ObjectDictionaryError.

@erlend-aasland erlend-aasland marked this pull request as ready for review July 2, 2024 09:40
test/test_eds.py Outdated Show resolved Hide resolved
@erlend-aasland erlend-aasland changed the title Consistently raise ObjectDictionaryError in the import/export OD APIs Raise ValueError and improve the exc message for unknown formats in the import/export OD APIs Jul 2, 2024
@acolomb acolomb changed the title Raise ValueError and improve the exc message for unknown formats in the import/export OD APIs Raise ValueError for unknown formats in the import/export OD APIs Jul 2, 2024
@acolomb acolomb merged commit 503918c into christiansandberg:master Jul 2, 2024
1 check passed
@erlend-aasland erlend-aasland deleted the no-NotImplementedError-for-you branch July 2, 2024 10:33
@erlend-aasland
Copy link
Contributor Author

Thanks a lot for the review and the helpful discussion; highly appreciated.

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.

Consider using ObjectDictionaryError iso. NotImplementedError in export/import OD APIs
3 participants