pypi beartype 0.17.1
Beartype 0.17.1: Bully Maguire Bullies Bugs

latest releases: 0.21.0, 0.21.0rc0, 0.20.2...
19 months ago

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:

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 inside typing.ForwardRef(...) objects. Why? No reason.
  • __module__ dunder attribute claims that method was defined in a fake module named named_{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!

    big boss dylan modesitt
    the eyes follow my fingers as i type my password

  • @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

Don't miss a new beartype release

NewReleases is sending notifications on new releases.