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

Fix S101, replace all assert in code base (except for tests) #4017

Merged
merged 24 commits into from
Aug 31, 2024

Conversation

DanielYang59
Copy link
Contributor

@DanielYang59 DanielYang59 commented Aug 26, 2024

Summary

  • Fix S101, replace all assert in code base
  • Use offending value in error message

Please review all changes carefully to make sure the assert condition is correctly reversed (there're just too many changes and I tried not to make mistakes).

@DanielYang59 DanielYang59 marked this pull request as ready for review August 26, 2024 06:09
@janosh janosh mentioned this pull request Aug 27, 2024
4 tasks
@DanielYang59 DanielYang59 changed the title Fix S101, replace all assert in code base Fix S101, replace all assert in code base (except for tests) Aug 28, 2024
Copy link
Member

@janosh janosh left a comment

Choose a reason for hiding this comment

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

thanks a lot for all this work @DanielYang59! 🙏

will improve user experience a lot to get helpful error messages rather than a generic AssertionError. to make the messages more informative, i think it would be great to include the offending value/type in all (Value|Type)Errors (see 135f69e for a few examples)

@janosh janosh added linting Linting and quality assurance ux User experience labels Aug 29, 2024
@DanielYang59
Copy link
Contributor Author

thanks a lot for all this work @DanielYang59! 🙏

No problem. Thanks for reviewing!

to make the messages more informative, i think it would be great to include the offending value/type in all (Value|Type)Errors (see 135f69e for a fe examples)

That's a very sensible suggestion, I would implement this later :)

@DanielYang59 DanielYang59 requested a review from janosh August 30, 2024 03:18
@DanielYang59
Copy link
Contributor Author

DanielYang59 commented Aug 31, 2024

Manually trace this link 135f69e to the discussion on f-string (sometimes comment doesn't show up in the PR for reasons I don't know 😄 ), in case I want to get back to this thread.

Copy link
Member

@janosh janosh left a comment

Choose a reason for hiding this comment

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

excellent work! 🙏

@janosh janosh enabled auto-merge (squash) August 31, 2024 05:51
@@ -120,7 +120,8 @@ def __init__(self, wavelength="CuKa", symprec: float = 0, debye_waller_factors=N
self.radiation = wavelength
self.wavelength = WAVELENGTHS[wavelength]
else:
raise TypeError(f"{type(wavelength)=} must be either float, int or str")
wavelength_type = type(wavelength).__name__
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, thanks a lot for fixing all those (type(var).__name__ for name directly instead of <class 'xxx'>). I totally forgot about them.

@janosh janosh merged commit c06abf1 into materialsproject:master Aug 31, 2024
43 checks passed
@DanielYang59 DanielYang59 deleted the really-remove-assert branch August 31, 2024 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linting Linting and quality assurance ux User experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants