Skip to content

Refactor montepy.errors -> montepy.exceptions #778

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

Merged
merged 13 commits into from
Jul 7, 2025
Merged

Conversation

tjlaboss
Copy link
Collaborator

@tjlaboss tjlaboss commented Jul 7, 2025

Pull Request Checklist for MontePy

Description

  • Rename montepy/errors.py to montepy/exceptions.py.
  • Refactor all uses accordingly throughout the codebase and test suite.
  • Create a new montepy/errors.py that issues a DeprecationWarning every time montepy.errors.something is used.

Closes #764


General Checklist

  • I have performed a self-review of my own code.
  • The code follows the standards outlined in the development documentation.
  • I have formatted my code with black version 25.
  • I have added tests that prove my fix is effective or that my feature works (if applicable).

Additional Notes for Reviewers

Ensure that:

  • The submitted code is consistent with the merge checklist outlined here.
  • The PR covers all relevant aspects according to the development guidelines.
  • 100% coverage of the patch is achieved, or justification for a variance is given.

Discussion

I think that the warning should be raised for any montepy.errors.SomeException and not at the module level.

The alternative way to deprecate was to make the warning module-level. I did it this way because either:

  • we import montepy.errors in __init__.py and get the warning there, or
  • we don't and montepy.errors.SomeException will be broken

The warning in __init__.py cannot be silenced with with warnings.catch_warnings(...), or else it will be caught everywhere because of how Python imports work. Doing it only at the module level would not raise a warning if a user specifically does import montepy.errors or from montepy.errors import.


📚 Documentation preview 📚: https://montepy--778.org.readthedocs.build/en/778/

@tjlaboss tjlaboss requested a review from MicahGale July 7, 2025 20:01
@tjlaboss tjlaboss added code improvement A feature request that will improve the software and its maintainability, but be invisible to users. low priority labels Jul 7, 2025
Copy link
Collaborator

@MicahGale MicahGale left a comment

Choose a reason for hiding this comment

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

You make a good argument for using an IDE.

@MicahGale
Copy link
Collaborator

Also you have missing coverage in montepy.exceptions, but coveralls is having issue and I can't find the lines that are missing.

@tjlaboss tjlaboss requested a review from MicahGale July 7, 2025 20:54
Copy link
Collaborator

@MicahGale MicahGale left a comment

Choose a reason for hiding this comment

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

The changelog needs adjusting. I think the missed patch coverage is my fault, and it's just showing up for you due to the rename.

@MicahGale
Copy link
Collaborator

I like how this page is present, but not easy to get to: https://montepy--778.org.readthedocs.build/en/778/api/montepy.errors.html

Should we exclude it via robots.txt? I think probably not. New crawlers won't find it, and it would be better if a search engine can see that it is deprecated rather than showing users a very old cached version in the search engine

@tjlaboss
Copy link
Collaborator Author

tjlaboss commented Jul 7, 2025

Today I learned about the :orphan: tag, which prevents the orphan warning.

Copy link
Collaborator

@MicahGale MicahGale left a comment

Choose a reason for hiding this comment

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

Lgtm.

@MicahGale MicahGale merged commit ee0275b into develop Jul 7, 2025
24 checks passed
@MicahGale MicahGale deleted the errs_are_exceptions branch July 7, 2025 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code improvement A feature request that will improve the software and its maintainability, but be invisible to users. low priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor 'errors.py' -> 'exceptions.py'
2 participants