Extend @particle_input to ParticleListLike annotations#2790
Extend @particle_input to ParticleListLike annotations#2790namurphy merged 12 commits intoPlasmaPy:mainfrom
@particle_input to ParticleListLike annotations#2790Conversation
|
Thank you for submitting this pull request (PR)! ✨ PlasmaPy depends on contributors like you, so we deeply appreciate it! The bottom of this page shows several checks that are run for every PR. ✅ Don't worry if something broke! We break stuff all the time. 😅 Click on "Details" to learn why a check didn't pass. Please also feel free to ask for help. We do that all the time as well! 🌸 We invite you to our weekly community meeting (2 pm ET on most Tuesdays) and office hours (3 pm ET on most Thursdays). After this PR is marked as ready for review, someone should stop by to provide a code review and offer suggestions soon. 👥 If we don't provide a review within a few days, please feel free to send us a reminder. 🎗 PlasmaPy's contributor guide has information on:
Tip 📚 For a documentation preview, click on Details next to docs/readthedocs.org:plasmapy. For cryptic documentation errors, see the documentation troubleshooting guide.
We thank you once again! 🌌 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2790 +/- ##
=======================================
Coverage 94.61% 94.62%
=======================================
Files 107 107
Lines 9664 9667 +3
Branches 1464 1466 +2
=======================================
+ Hits 9144 9147 +3
Misses 327 327
Partials 193 193 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
PlasmaPy/src/plasmapy/particles/decorators.py Lines 590 to 597 in 9fa3846 I'm trying to figure out if there's some type in Python that includes the usual |
Hm...I don't know of any type or typing construct like that, unfortunately. This reminds me that we used to have a problem where |
Yeah that should be fixed now with the above logic. I'll double check just to be 100% :) |
namurphy
left a comment
There was a problem hiding this comment.
Thank you for adding this, and my apologies for taking so long to merge it! I expect that this will be useful. I added a changelog entry, and will merge it shortly.
| @pytest.mark.parametrize("particle", ["p+", ("p+", "D+"), ["He-4", "Al", "Si"]]) | ||
| @particle_input | ||
| def test_particle_list_input(particle: ParticleListLike) -> None: | ||
| assert isinstance(particle, ParticleList) |
There was a problem hiding this comment.
🪩 That's a cool idea to decorate the test itself in order to test the decorator. I like this pattern!
Currently, the
@particle_inputdecorator supportsParticleListannotations but does not provide robust support for casting forParticleListLikeobjects. This PR will implement support for casting of iterables and strings toParticleListobjects for parameters annotated withParticleListLike.