-
Notifications
You must be signed in to change notification settings - Fork 312
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
Update @particle_input to handle typing that utilzes Union[], List[], etc. #912
Comments
Hm...I wonder if it would be helpful to define There's also a new feature in Python 3.9 (which was just released!) for type hinting generics which might be cleaner eventually (e.g., |
Oh...and >>> Particle(True)
Particle("H") Huh. |
What's |
|
I'm currently working on this and hoping to open a PR soon on it. Here are my thoughts on the functionality.
|
This looks great, and very thorough! This covers a lot of use cases that I hadn't thought about. I was thinking that the docstring for this would be a good place to discuss what valid representations of particles are. If you don't mind, I'd like to help out with at least the docstring for this since this is something I've been meaning to put in the documentation anyway. |
Sure, I've made a bunch of progress in getting the above implement and should be able to open a PR sometime next week. We can go through the docstrings, and more, at that point. |
Sounds good! I also commented on this in #796. In particular, I tentatively created a one-liner for |
I'll point out, one of the benefits of having a |
EXACTLY! |
@particle_input
ques off of arguments annotated withParticle
to properly condition that argument into aParticle()
object. However, that argument is allowed to be a string (e.g."He+"
) or aParticle()
object and, thus, should really be annotated withUnion[str, Particle]
. Without this annotation, IDEs will generally throw warnings if you trying to use"He+"
as an argument.I think
@particle_input
can accomplish this by doing something like...Then the following would result in...
The text was updated successfully, but these errors were encountered: