-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
[BUG?] Generic types at module scope #256
Comments
Gah! Thanks so much for this wonderfully detailed issue, @skeggse. You are entirely correct about everything, which must be why you still devbro in Silicon Valley whereas I feebly fled to the Canadian wilderness. I regret nothing. Sadly, this is technically a duplicate of feature request #226: [Feature Request] Postponed evaluation of non-self-referential type hints. Let's shift you over there and copy-and-paste your excellent minimal-reproducible example (MRE), which I promise to resolve "shortly." 😓 I've been delaying addressing this due to the |
Aha! I evidently struggle to use Github's search tool to find what I'm looking for. Happily, your index is much better tuned on the relevant keywords than the amalgam that is me + Github 🥳
I cannot attest to whether you "feebly fled" but I somehow doubt that a bit 😄 I still "devbro" in SV because I must be some sort of masochist.
This link is maybe the wrong link? I don't see any references to Thank you for pointing out the error in my ways, at least. I'll have to ponder how to move forward here; being unable to upgrade another dependency is non-ideal. |
...heh. It's such an intense place on the one hand; it's the epicentre of world-straddling AI on the other hand. I suspect these two hands have something to do with one another. 😆
Gah! That link was totally the wrong link. This is the right link. Caution: things got pretty intense there. The tl;dr here is that @beartype 0.15.0 to be released this Friday I swear this on my cats. is introducing a new One-liner or it didn't happen, so: # In the "{your_package}.__init__" submodule:
from beartype.claw import beartype_this_package
# After this Friday, this is what *EVERYONE* should now do.
# Nobody needs to manually decorate anything by @beartype anymore.
# This isn't just syntactic sugar, though. Doing this also instructs
# @beartype to type-check annotated assignment statements previously
# only type-checked by static type-checkers like mypy and pyright: e.g.,
# # @beartype will now type-check this and raise a violation at runtime.
# not_an_int: int = 'You lie, not_an_int! Why do you lie so much?'
beartype_this_package() Flex those bear muscles. 💪 🐻 |
Oh, and...
No, no! The error is entirely ours; thanks so much for reminding me of our unresolved breakage. I fully agree that @beartype's behaviour is total suckage here. I hadn't realized that third-party packages were beginning to annotate everything with non-standard forward references like Sadly, the only sane path forward for you is probably to temporarily disable @beartype on |
lidatong/dataclasses-json#371 seems to have made
beartype
unhappy in my codebase that uses bothdataclasses_json
andbeartype
:$ pip show beartype | rg Version Version: 0.14.1
This is interesting to me, because it sure seems like it's valid code, and it feels like a simple implementation gap, but I am lacking a bunch of context and knowledge to properly evaluate this.
Minimal repro:
Now, I'm sure you'd prefer a minimal repro that doesn't involve third-party library, but I think it's worth seeing in context. However, here's a repro that doesn't depend on
dataclasses_json
, though it does so at the expense of being less terse :)This produces an error that looks very similar to the earlier one:
The text was updated successfully, but these errors were encountered: