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

Remove unnecessary pass statements #670

Conversation

kevindlewis23
Copy link
Collaborator

No description provided.

Copy link

codecov bot commented Jul 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 30.11%. Comparing base (b32cf68) to head (d1d9057).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #670      +/-   ##
==========================================
- Coverage   30.16%   30.11%   -0.06%     
==========================================
  Files         139      139              
  Lines       22551    22437     -114     
==========================================
- Hits         6803     6757      -46     
+ Misses      15748    15680      -68     

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

Copy link
Collaborator

@ZackAttack614 ZackAttack614 left a comment

Choose a reason for hiding this comment

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

Please be careful when removing pass statements, as they're sometimes used in important ways to indicate that a function or class is not implemented. Without a function definition, Python will throw errors.

hexrd/distortion/distortionabc.py Show resolved Hide resolved
hexrd/distortion/distortionabc.py Show resolved Hide resolved
hexrd/findorientations.py Show resolved Hide resolved
hexrd/fitting/calibration/calibrator.py Show resolved Hide resolved
hexrd/fitting/calibration/calibrator.py Show resolved Hide resolved
hexrd/instrument/detector.py Show resolved Hide resolved
hexrd/instrument/detector.py Show resolved Hide resolved
hexrd/instrument/detector.py Show resolved Hide resolved
hexrd/instrument/detector.py Show resolved Hide resolved
scripts/calibrate_from_rotation_series.py Show resolved Hide resolved
@kevindlewis23
Copy link
Collaborator Author

kevindlewis23 commented Jul 5, 2024

Please be careful when removing pass statements, as they're sometimes used in important ways to indicate that a function or class is not implemented. Without a function definition, Python will throw errors.

Passes are not required for abstract methods, as long as there's a docstring. I already tested this and no errors are thrown. From looking online, this is seems to be the preferred way to do it. https://stackoverflow.com/questions/45826692/body-of-abstract-method-in-python-3-5

@ZackAttack614
Copy link
Collaborator

While this is true, relying on Python's evaluation of the docstring doesn't provide the user with much feedback if they're using a method that hasn't yet been overridden. Best practice is to raise a NotImplementedError in methods rather than do nothing, so that if a user calls a method that does not have a real definition, the system doesn't break in a way that is hard to understand.

@kevindlewis23
Copy link
Collaborator Author

While this is true, relying on Python's evaluation of the docstring doesn't provide the user with much feedback if they're using a method that hasn't yet been overridden. Best practice is to raise a NotImplementedError in methods rather than do nothing, so that if a user calls a method that does not have a real definition, the system doesn't break in a way that is hard to understand.

Okay, I'll raise a NotImplementedError then

Copy link
Collaborator

@ZackAttack614 ZackAttack614 left a comment

Choose a reason for hiding this comment

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

Nearly there

hexrd/material/spacegroup.py Outdated Show resolved Hide resolved
hexrd/material/spacegroup.py Outdated Show resolved Hide resolved
scripts/calibrate_from_rotation_series.py Outdated Show resolved Hide resolved
@kevindlewis23 kevindlewis23 merged commit 5ecf297 into HEXRD:master Jul 11, 2024
6 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