Beartype 0.17.1 gently descends from the heavens on a golden dragon made of rainbows. "How can this be!?", the crowd exclaims. Verily, it is best not to ask questions:
pip install --upgrade beartype
This patch release comes courtesy these proud GitHub Sponsors, without whom @leycec's cats would currently be eating grasshoppers:
- @sesco-llc (SESCO Enterprises), "The Power of Innovation in Trading": this inspires me to get out of the house and do something https://sescollc.com
- @DylanModesitt (Dylan Modesitt), quantitative strategies energy trading associate: ...wikipedia, don't fail me now! https://dylanmodesitt.com
Thanks so much, masters of fintech.
Who Let the Bugs Out?
This patch release adds explicit support for typing.NamedTuple
subclasses under PEP 563 (i.e., from __future__ import annotations
), resolving issue #318 kindly submitted by the cosmically rare-earth GitHub element @kasium. For unknown reasons (which probably reduce to "Guido was tired that day."), the typing.NamedTuple
superclass exhibits high strangeness.
Specifically, for each typing.NamedTuple
subclass named {MuhTuple}
, the typing.NamedTuple
superclass dynamically generates a {MuhTuple}.__new__()
dunder method whose:
__annotations__
dunder attribute wraps all stringified type hints insidetyping.ForwardRef(...)
objects. Why? No reason.__module__
dunder attribute claims that method was defined in a fake module namednamed_{MuhTuple}
. Why? Nobody knows.
For example:
from __future__ import annotations # <-- PEP 563: it makes kittens cry
import typing
# When you said this...
class MuhTuple(typing.NamedTuple): # <-- very reasonable
muh_field: int # <-- makes sense, huh?
# ...what "typing.NamedTuple" heard you say was this:
class MuhTuple(typing.NamedTuple):
def __new__(cls, muh_field: ForwardRef('int')) -> None: # <-- wut
self.muh_field = muh_field
MuhTuple.__new__.__module__ = 'named_MuhTuple' # <-- lolbro
Why does typing.NamedTuple
do these sad things? Because it is crazy. This is the official answer. Cray classes gonna cray.
@beartype now responds with a mountain of code that took us two weeks. Was that worth it? Probably not. Probably should have just implemented deep type-checking already. Instead, this is all we got.
Mo Money Means Mo Code
@beartype 0.17.0 advised everybody to donate money to charitable causes. Instead, everybody donated more money to @beartype. Reverse psychology surely is the path of righteousness.
These monocled code aristocrats graciously filled the money trough, which the cats are now sleeping on against our wishes:
-
@DylanModesitt. @beartype now proudly markets you and everything you do. We're Team @DylanModesitt over here. Also, your GitHub Avatar is the boss. Feast your eyes, everybody!
-
@zhiyuanshi. Thanks to you, I have money. More importantly, I now know about spacemacs: Emacs + Vim key bindings. Urge... to... switch... IDEs... rising. My danger sense is tingling.
Lastly, @beartype thanks Bully Maguire for saving New York City with sassy hair, emo eye shadow, and impromptu cafe street dancing.
@beartype make a man feel like this, sometimes