Skip to content

Commit

Permalink
Mypy regression workaround.
Browse files Browse the repository at this point in the history
This commit by Ribeira Grande`typing` guru @helderco (Helder Correia)
resolves a critical regression introduced in new releases of mypy,
resolving issue #332 kindly submitted by said guru. Specifically, this
commit dissolves a simple type alias internal to the @beartype codebase
that both mypy and `pyright` once seamlessly supported. Now, only
`pyright` appears to reliably support simple type aliases. This is why
@leycec cries himself to sleep in an uninsulated cabin in the Canadian
wilderness. That, and the bitter chill that seeps through his beard.
(*Impossible imposter is lately importunate, unfortunately!*)
  • Loading branch information
helderco committed Feb 22, 2024
1 parent 16a835c commit adf1a44
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
9 changes: 0 additions & 9 deletions beartype/_data/hint/datahinttyping.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,6 @@
# ....................{ CALLABLE }....................
# Callable-specific type hints *NOT* required by subsequent type hints below.

BeartypeDecorator = Callable[[BeartypeableT], BeartypeableT]
'''
PEP-compliant type hint matching a **beartype-like decorator** (i.e., callable
presumably decorating a passed object by the :func:`beartype.beartype` decorator
under a possibly non-default beartype configuration and returning the resulting
decorated object).
'''


CallableRaiser = Callable[[object], None]
'''
PEP-compliant type hint matching a **raiser callable** (i.e., arbitrary callable
Expand Down
5 changes: 2 additions & 3 deletions beartype/_decor/decormain.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
# submodule to improve maintainability and readability here.

# ....................{ IMPORTS }....................
from beartype.typing import TYPE_CHECKING
from beartype.typing import TYPE_CHECKING, Callable
from beartype._conf.confcls import (
BEARTYPE_CONF_DEFAULT,
BeartypeConf,
)
from beartype._data.hint.datahinttyping import (
BeartypeConfedDecorator,
BeartypeReturn,
BeartypeableT,
)
Expand All @@ -45,7 +44,7 @@
@overload # type: ignore[misc,no-overload-impl]
def beartype(obj: BeartypeableT) -> BeartypeableT: ...
@overload
def beartype(*, conf: BeartypeConf) -> BeartypeConfedDecorator: ...
def beartype(*, conf: BeartypeConf) -> Callable[[BeartypeableT], BeartypeableT]: ...

# ....................{ DECORATORS }....................
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down

0 comments on commit adf1a44

Please sign in to comment.