Skip to content

Conversation

@MicahGale
Copy link
Collaborator

@MicahGale MicahGale commented Oct 28, 2025

Pull Request Checklist for MontePy

Description

MontePy does a lot of type and value checking, which consists of a lot of conditional raising of TypeError and ValueError as noted in #674. Thanks @kordusas for bugging us to actually do this. This fixes this by using decorator magic to automatically run these tests at call time every time with minimal code per new function.

This has been a large effort to:

  1. Vendor check_value.py from OpenMC
  2. Update check_value.py to:
    1. add @args_checked decorator
    2. Add support for typing.Annotated for value checking
    3. Add support for recursive type annotations
  3. Introduce montepy.types for common types
  4. Switch almost all type and value checking via @args_checked and montepy.types

Fixes #674, fixes #91, fixes #393?


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).

LLM Disclosure

Were any large language models (LLM or "AI") used in to generate any of this code?

  • Yes
    • Model(s) used: ChatGPT-mini via GH copilot
  • No

Documentation Checklist

  • I have documented all added classes and methods.
  • For infrastructure updates, I have updated the developer's guide.
  • For significant new features, I have added a section to the getting started guide.

First-Time Contributor Checklist

  • If this is your first contribution, add yourself to pyproject.toml if you wish to do so.

Additional Notes for Reviewers

Ensure that:

  • This PR fully addresses and resolves the referenced issue(s).
  • 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.

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

tjlaboss and others added 30 commits March 11, 2025 16:10
* Vendor "checkvalue.py" from OpenMC and add license

* The OpenMC codebase is released under the MIT license.
This commit includes a module from OpenMC to add value checking
capabilities to MontePy. The LICENSE is updated accordingly.

* Update CHANGELOG

* Don't require sphinx docs checkvalue for now

* Rename checkvalue -> _check_value

* Update LICENSE

* Copy license VERBATIM

and add serial commas to MontePy's license

* Update LICENSE to reflect checkvalue's 2014 date
@MicahGale MicahGale marked this pull request as ready for review October 31, 2025 03:55
@MicahGale MicahGale requested a review from tjlaboss October 31, 2025 03:55
@MicahGale
Copy link
Collaborator Author

Docs changes:

  1. dev docs
  2. check_value
  3. types

@MicahGale MicahGale mentioned this pull request Nov 3, 2025
@MicahGale MicahGale changed the base branch from develop to minor-rel-dev November 19, 2025 05:09
@MicahGale
Copy link
Collaborator Author

This does almost double the benchmark time. So I'm thinking of pushing this to next next minor release where we will have jit parsing overcoming this overhead.

@MicahGale
Copy link
Collaborator Author

Ok @tjlaboss, could you review this one finally, lower priority since this won't ship until MontePy 1.3

@tjlaboss
Copy link
Collaborator

tjlaboss commented Dec 1, 2025

Heavy PR, but mostly boilerplate. Everything seems to be working as expected.

@tjlaboss tjlaboss closed this Dec 1, 2025
@tjlaboss tjlaboss reopened this Dec 1, 2025
@tjlaboss
Copy link
Collaborator

tjlaboss commented Dec 1, 2025

Also I haven't mastered the art of clicking a button yet.

@MicahGale
Copy link
Collaborator Author

Heavy PR, but mostly boilerplate. Everything seems to be working as expected.

Yeah.... sorry.

@MicahGale
Copy link
Collaborator Author

Thanks for the review.

@MicahGale MicahGale merged commit 2e880c8 into minor-rel-dev Dec 3, 2025
52 checks passed
@MicahGale MicahGale deleted the alpha-test-checkvalue branch December 3, 2025 14:03
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. feature request An issue that improves the user interface.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Automated dynamic type enforcement Implement the use of function annotations

3 participants