Skip to content

Commit

Permalink
**Beartype 0.17.1** released.
Browse files Browse the repository at this point in the history
**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:

```bash
pip install --upgrade beartype
```

This patch release comes courtesy these proud [GitHub
Sponsors](https://github.com/sponsors/leycec), without whom @leycec's
cats would currently be eating grasshoppers:

* @sesco-llc (SESCO Enterprises), "The Power of Innovation in Trading":
  <sup>*this inspires me to get out of the house and do something*</sup>
  https://sescollc.com
* @DylanModesitt (Dylan Modesitt), quantitative strategies energy
  trading associate: <sup>*...wikipedia, don't fail me now!*</sup>
  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
  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:

```python
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. Both I and our cats
applaud this abandonment of your local community.

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](https://avatars.githubusercontent.com/u/8339189?v=4) is the
  boss. Feast your eyes, everybody!

  ![big boss dylan
  modesitt](https://avatars.githubusercontent.com/u/8339189?v=4)
  <sup>the eyes follow my fingers as i type my password</sup>

* @zhiyuanshi. Thanks to you, I have money. More importantly, I now know
  about [spacemacs](https://github.com/syl20bnr/spacemacs): **Emacs** +
  **Vim** key bindings. *Urge... to... switch... IDEs...* **rising.**
  This is dangerous.

Lastly, @beartype thanks [Bully
Maguire](https://media1.tenor.com/m/o6qhUX1GwgYAAAAd/je.gif) for saving
New York City with sassy hair, emo eye shadow, and impromptu cafe street
dancing.

![](https://media1.tenor.com/m/o6qhUX1GwgYAAAAd/je.gif)
<sup>@beartype make a man feel like this, sometimes</sup>

(*Unutterable mutterings!*)
  • Loading branch information
leycec committed Feb 10, 2024
1 parent 193f005 commit 1c51f3d
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 1c51f3d

Please sign in to comment.