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

ENH: Change AttributeError to ValueError #599

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

bifbof
Copy link
Collaborator

@bifbof bifbof commented Jan 14, 2024

A bit of a pet peeve of mine.
All over trackintel we used AttributeError where ValueError would make more sense.
I changed it where it made sense for me.

for reference: https://docs.python.org/3/library/exceptions.html

AttributeError
Raised when an attribute reference (see Attribute references) or assignment fails. (When an object does not support attribute references or attribute assignments at all, TypeError is raised.)

e.g.

>> a = object()
>> a.not_existing_field
AttributeError: 'object' object has no attribute 'not_existing_field'

ValueError
Raised when an operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception such as IndexError.

e.g.

>> chr(0x1100001)
ValueError: chr() arg not in range(0x110000)

Copy link

codecov bot commented Jan 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a74f437) 93.31% compared to head (c0f8ab9) 93.41%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #599      +/-   ##
==========================================
+ Coverage   93.31%   93.41%   +0.09%     
==========================================
  Files          33       33              
  Lines        2064     2064              
  Branches      364      364              
==========================================
+ Hits         1926     1928       +2     
+ Misses        127      126       -1     
+ Partials       11       10       -1     

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

@hongyeehh
Copy link
Member

Thanks for the formalization - these error treatments should be enforced in later enhancements and PRs

@hongyeehh hongyeehh merged commit 4babae9 into mie-lab:master Jan 15, 2024
8 checks passed
@bifbof bifbof deleted the ValueError branch January 15, 2024 14:30
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