-
Notifications
You must be signed in to change notification settings - Fork 25
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
mypy complaining when using literals #584
Comments
Hi. Thank you for the interest in the package. Why do you not follow the examples in the README, so something like In [1]: from particle.pdgid import literals as lid In [2]: lid.gamma In [3]: lid.gamma.abspid :)? It is in general a bad idea to import as the name of something common/in the package/... |
This being said, you mention MyPy, so what exactly are you doing, and for what? In any case I hope the examples/notebooks are a good source to get started. Let us know, thank you. |
The issue is still the same if I use the I just type my code. I suspect particles are lazy-loaded and it confuses the type checker. |
I'm sorry but I'm still failing to understand in which env you get this. Isn't something you can switch off for usage, anyway? |
Let me just ping @henryiii in case he has some insight. Else I would be inclined to close this issue. |
It’s because we take a dynamic approach to filling these out. It’s not something that changes frequently, so personally I’d be fine with figuring out a more static-friendly way to do it. |
It is not super urgent! For now I just ignore a few lines where this code is used. Will investigate a bit more if there is a simple workaround and report back if I find anything. |
The dynamic approach is nice since we did the job "years ago" and got it all behind our backs ever since, as it were. I'm afraid I still do not see the way you are working to have the "issue", and you're certainly the first one to mention it in 2-3 years. Would adding a pragma ignore somewhere help? |
I've talked about this before for several years, I've been bothered by the fact that we have a static list of things and we can't use it statically in type checkers because we are dynamically generating it. There are a few options for fixing it, such as generating the file instead of dynamically generating the entries, or writing out a |
I use the following code:
mypy complains with
Is there a workaround?
The text was updated successfully, but these errors were encountered: