Skip to content

Commit

Permalink
Python 3.9 CI configuration.
Browse files Browse the repository at this point in the history
This commit corrects our GitHub Actions-based continuous integration
(CI) configuration to correctly exercise itself against Python 3.9 by
explicitly passing the `--skip-missing-interpreters=false` CLI option to
force CI failures when one or more Python environments are unavailable,
resolving the upstream tox-dev/tox#903 issue for us. Unrelatedly, this
commit also substantially improves the introductory leda in our
front-facing `README.rst` to better highlight beartype's merits versus
conventional static type checkers.

## Tests Improved

* **Python 3.9 exercised under CI.** Our GitHub Actions-based continuous
  integration (CI) configuration now correctly exercises itself against
  Python 3.9 by explicitly passing the
  `--skip-missing-interpreters=false` CLI option to force CI failures
  when one or more Python environments are unavailable, resolving the
  upstream tox-dev/tox#903 issue for `@beartype`.

(*Thistles and whistlepigs alike abjure Spring sprigs!*)
  • Loading branch information
leycec committed Dec 3, 2020
1 parent cbb6bb7 commit 23ee35f
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 19 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ jobs:
python -m site
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade numpy virtualenv tox tox-gh-actions
# Note that:
#
# * "--skip-missing-interpreters=false" disables the corresponding
# "skip_missing_interpreters = true" setting globally enabled by our
# top-level "tox.ini" configuration, forcing CI failures for
# unavailable Python environments. See also:
# https://github.com/tox-dev/tox/issues/903
- name: 'Testing package with "tox"...'
run: |
python -m tox
python -m tox --skip-missing-interpreters=false
84 changes: 69 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,59 @@ beartype —[ …the bare-metal type checker ]—
— `The Jungle Book`_.
**Beartype** is an open-source pure-Python `PEP-compliant <Compliance_>`__
runtime type checker emphasizing efficiency, portability, and thrilling puns.
``O(1)`` `constant-time <Timings_>`__ runtime type checker emphasizing
efficiency, portability, and thrilling puns.

Unlike comparable static type checkers operating at the coarse-grained
application level (e.g., Pyre_, mypy_, pyright_, pytype_), beartype operates
exclusively at the fine-grained callable level of pure-Python functions and
methods via the standard decorator design pattern. This renders beartype
natively compatible with *all* interpreters and compilers targeting the Python
language – including CPython_, PyPy_, Numba_, and Nuitka_.
Like comparable static type checkers operating at the coarse-grained
application level through ad-hoc heuristic type inference (e.g., Pyre_, mypy_,
pyright_, pytype_), beartype `effectively imposes no runtime overhead
<Timings_>`__. Unlike static type checkers:

* Beartype operates exclusively at the fine-grained callable level of
pure-Python functions and methods via the standard decorator design pattern.
This renders beartype natively compatible with *all* interpreters and
compilers targeting the Python language – including PyPy_, Numba_, Nuitka_,
and (of course) CPython_ itself.
* Beartype enjoys deterministic Turing-complete access to the actual objects
and types being type-checked. This enables beartype to solve type-checking
problems decidable only at runtime, including type-checking of arbitrary
objects whose:

* Metaclasses `dynamically customize instance and subclass checks
<_isinstancecheck>`__ by implementing the ``__instancecheck__()`` and/or
``__subclasscheck__()`` dunder methods, including:

* `PEP 3119`_-compliant metaclasses (e.g., `abc.ABCMeta_`).

* Pseudo-superclasses `dynamically customize the method resolution order
(MRO) of subclasses <_mro_entries>`__ by implementing the
``__mro_entries__()`` dunder method, including:

* `PEP 560`_-compliant pseudo-superclasses.

* Superclasses dynamically register themselves with abstract base classes
(ABCs), including:

* `PEP 3119`_-compliant third-party virtual base classes.
* `PEP 3141`_-compliant third-party virtual number classes (e.g., SymPy_).

* Classes are dynamically constructed or modified at runtime, including by:

* Class decorators.
* Class factory functions and methods.
* Metaclasses.

Unlike comparable runtime type checkers (e.g., enforce_, pytypes_, typeguard_),
beartype wraps decorated callables with dynamically generated wrappers
efficiently type-checking those specific callables. Since "performance by
default" is our first-class concern, these wrappers are guaranteed to:
beartype decorates callables with dynamically generated wrappers efficiently
type-checking each parameter passed to and value returned from those callables
in constant time. Since "performance by default" is beartype's first-class
concern, generated wrappers are guaranteed to:

* Exhibit `O(1) time complexity with negligible constant factors <Nobody
Believes You_>`__.
* Be either more efficient (in the common case) or exactly as efficient minus
the cost of an additional stack frame (in the worst case) as equivalent
type-checking implemented by hand, *which no one should ever do.*
the cost of an additional stack frame (in the worst case) as semantically
equivalent type-checking implemented by hand, *which no one should ever do.*

Beartype thus brings Rust_- and `C++`_-inspired `zero-cost abstractions
<zero-cost abstraction_>`__ into the lawless world of pure Python.
Expand Down Expand Up @@ -1387,7 +1421,11 @@ application stack at tool rather than Python runtime) include:
.. _pip:
https://pip.pypa.io

.. # ------------------( LINKS ~ py : implementation )------------------
.. # ------------------( LINKS ~ py : data model )------------------
.. _isinstancecheck:
https://docs.python.org/3/reference/datamodel.html#customizing-instance-and-subclass-checks

.. # ------------------( LINKS ~ py : interpreter )------------------
.. _CPython:
https://github.com/python/cpython
.. _Nuitka:
Expand All @@ -1414,8 +1452,6 @@ application stack at tool rather than Python runtime) include:
https://www.python.org/dev/peps/pep-0526
.. _PEP 544:
https://www.python.org/dev/peps/pep-0544
.. _PEP 560:
https://www.python.org/dev/peps/pep-0560
.. _PEP 563:
https://www.python.org/dev/peps/pep-0563
.. _PEP 570:
Expand All @@ -1435,18 +1471,36 @@ application stack at tool rather than Python runtime) include:
.. _PEP 3141:
https://www.python.org/dev/peps/pep-3141

.. # ------------------( LINKS ~ py : pep : 3119 )------------------
.. _PEP 3119:
https://www.python.org/dev/peps/pep-3119
.. _virtual base classes:
https://www.python.org/dev/peps/pep-3119/#id33

.. # ------------------( LINKS ~ py : pep : 484 )------------------
.. _PEP 484:
https://www.python.org/dev/peps/pep-0484
.. _relative forward references:
https://www.python.org/dev/peps/pep-0484/#id28

.. # ------------------( LINKS ~ py : pep : 560 )------------------
.. _PEP 560:
https://www.python.org/dev/peps/pep-0560
.. _mro_entries:
https://www.python.org/dev/peps/pep-0560/#id20

.. # ------------------( LINKS ~ py : service )------------------
.. _Anaconda:
https://docs.conda.io/en/latest/miniconda.html
.. _PyPI:
https://pypi.org

.. # ------------------( LINKS ~ py : stdlib : builtins )------------------
.. _abc:
https://docs.python.org/3/library/abc.html
.. _abc.ABCMeta:
https://docs.python.org/3/library/abc.html#abc.ABCMeta

.. # ------------------( LINKS ~ py : stdlib : builtins )------------------
.. _builtins:
https://docs.python.org/3/library/stdtypes.html
Expand Down
13 changes: 10 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,15 @@ envlist = py3{6,7,8,9},pypy3
#"--skip-missing-interpreters=false" when running the "tox" command,
#preventing CI runs from erroneously returning success on missing interpreters.

# Ignore Python interpreters *NOT* externally installed on the current system.
# By default,
# Ignore Python environments unavailable on the current system. By default,
# "tox" fails on the first unavailable Python environment. While sensible for
# continuous integration (CI), this default fails to generalize for local
# developers lacking one or more Python environments.
#
# Note that our CI configuration explicitly falsifies this setting back to its
# CI-friendly default via the "--skip-missing-interpreters=false" CLI option,
# forcing CI failures for unavailable Python environments. See also:
# https://github.com/tox-dev/tox/issues/903
skip_missing_interpreters = true

# ....................{ LIB ~ tox-gh-actions }....................
Expand All @@ -81,7 +88,7 @@ python =
3.6: py36
3.7: py37
3.8: py38
3.9: py38
3.9: py39
pypy3: pypy3

# ....................{ LIB ~ pytest }....................
Expand Down

0 comments on commit 23ee35f

Please sign in to comment.