Beartype 0.9.1 released.
This patch release delivers obstreperous support for Sphinx (curse ye and yer little side effects too, autodoc
extension!), generator callables, readable exception messages, and Python 3.10 CI.
This release resolves 4 issues and merges 0 pull requests. Fearsome changes include:
Compatibility Improved
- Sphinx.
@beartype
now explicitly provides first-class support for Sphinx'sautodoc
extension (i.e.,sphinx.ext.autodoc
), resolving issue #61 kindly submitted by SeldonIO/alibi ML dev maestro supremum Janis Klaise (@jklaise).@beartype
now transparently ignoresautodoc
-mocked module attributes (e.g., produced by theautodoc_mock_imports
list global in Sphinx-specificdoc{s,}/conf.py
configuration files of downstream documentation trees) used as type hints annotating@beartype
-decorated callables, rendering@beartype
compatible withautodoc
-documented codebases. Since Sphinx lacks a public API for detecting whenautodoc
is currently generating documentation (see: sphinx-doc/sphinx#9805),@beartype
now performs its own ad-hoc detection at decoration time with micro-optimized runtime complexity:O(1)
in the common case (i.e., Sphinx'sautodoc
extension has not been previously imported under the active Python interpreter).O(n)
in the worst case (i.e., Sphinx'sautodoc
extension has been previously imported under the active Python interpreter), wheren
is the height of the call stack leading to@beartype
. Thanks, Sphinx. Thanks alot.
- Generator callables.
@beartype
now relaxes the requirement that [a]synchronous generator callables be annotated by PEP 484 -complianttyping.{Async,}Generator[...]
or PEP 585-compliantcollections.abc.{Async,}Generator[...]
type hints to additionally accept PEP 484-complianttyping.{Async,}Iterable[...]
andtyping.{Async,}Iterator[...]
as well as PEP 585-compliantcollections.abc.{Async,}Iterable[...]
andcollections.abc.{Async,}Iterator[...]
type hints, resolving issue #65 kindly submitted by the @posita the positronic brain emitter.
Features Improved
- Exception message readability.
@beartype
now emits more human-readable, disambiguous, and useful exception messages or my middle name isn't "Brain Trust." Notably:@beartype
-decorated callables annotated by one or more numeric types (e.g.,int
,float
,complex
) now raise exceptions on type-checking failures whose exception messages disambiguate those numbers from strings, resolving issue #63 kindly submitted by @jefcolbi. Previously, these messages double-quoted all numbers for disambiguity with the possibly preceding sequence index of those numbers in their parent containers – introducing yet another ambiguity between numbers and strings. Numbers are now preserve in their vanilla unquoted form; meanwhile, sequence items are additionally disambiguated from sequence values with additional explanatory substrings.- Edge-case exception messages emitted by our memoized code generator no longer contain the mostly inappropriate substring `"wrapper parameter" except where absolutely appropriate.
- Annotation-centric exception messages now guaranteeably contain the critical substring
"type hint"
.
Issues Resolved
- #61, kindly submitted by SeldonIO/alibi ML dev maestro supremum Janis Klaise (@jklaise). See "Compatibility Improved" above.
- #62, kindly submitted by Cal Leeming (@foxx), may his serious eyebrow-raising monochrome GitHub avatar be a guiding light to us all. See "Documentation Revised" below. (Thanks again to the foxy @foxx for appraising us all of hitherto unknown typing horrors. And just in time for Halloween too.)
- #63, kindly submitted by @jefcolbi. See "Features Improved" above.
- #65, kindly submitted by @posita the positronic brain emitter. See "Compatibility Improved" above.
Tests Improved
- Python 3.10 CI. This release resurrects Python 3.10 support in our GitHub Actions-based continuous integration (CI) configuration, circumventing upstream issue actions/setup-python#160 by coercively double-quoting all Python version strings specified as the values of "python-version:" keys. Ya!
Documentation Revised
- Reverse dependency showcase. The introduction to our front-facing
README.rst
documentation now gratefully advertises popular reverse dependencies (i.e., downstream open-source Python projects directly leveragingbeartype
) with a new on-brand icon bar. Gaze upon iconic icons and know the stylish face of unabashed beauty. - Type hint elision. The new "Type Hint Connectives" subsection of our front-facing
README.rst
documentation documents various means of circumventing counter-intuitive historicity in Python's core type hierarchy with (wait for it) beartype validators, resolving issue #62 kindly submitted by Cal Leeming (@foxx). Specifically, this subsection documents how to effectively declare:- A new PEP-compliant
int - bool
type hint as a beartype validator matching the set of all integers that are not booleans. - A new PEP-compliant
Sequence - str
type hint as a beartype validator matching the set of all sequences that are not strings.
- A new PEP-compliant
(Unleaded laden jelly-like underbellies!)