update jaxtyped decorator (#44)

* update jaxtyped decorator

* add newline character to pacify flake

* add precomit hooks

* add missing return statement

* replace typing_extensions>=4.2.0 with typing_extensions

* pin version range for typing_extensions

* set min version of typing-extensions but not max

* bump version number to 0.2.8
This commit is contained in:
Kevin P Murphy
2022-11-13 22:25:28 -08:00
committed by GitHub
parent 3f877c0dbb
commit e201039dfe
3 changed files with 12 additions and 3 deletions
+1 -1
View File
@@ -67,4 +67,4 @@ from .import_hook import install_import_hook
from .pytree_type import PyTree
__version__ = "0.2.7"
__version__ = "0.2.8"
+7 -1
View File
@@ -18,6 +18,7 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import functools as ft
import inspect
import threading
@@ -44,4 +45,9 @@ class _Jaxtyped:
def jaxtyped(fn):
return ft.wraps(fn)(_Jaxtyped(fn))
if inspect.isclass(fn): # allow decorators on class definitions
init = jaxtyped(fn.__init__)
fn.__init__ = init
return fn
else:
return ft.wraps(fn)(_Jaxtyped(fn))
+4 -1
View File
@@ -67,11 +67,14 @@ python_requires = "~=3.7"
# We use typeguard internally (in a fairly minimal way), but it's not required that
# end users make the same choice.
# For typing_extensions, we choose versions that match
# https://github.com/explosion/confection/blob/main/setup.cfg#L33 used in colab
install_requires = [
"jax>=0.3.4",
"numpy>=1.20.0",
"typeguard>=2.13.3",
"typing_extensions>=4.2.0",
"typing_extensions>=3.7.4.1",
]
entry_points = dict(pytest11=["jaxtyping = jaxtyping.pytest_plugin"])