From 8f64c99649afdc85e45e3a11012cc6f2ddfed9f3 Mon Sep 17 00:00:00 2001 From: Patrick Kidger <33688385+patrick-kidger@users.noreply.github.com> Date: Mon, 1 Aug 2022 01:06:45 +0100 Subject: [PATCH] Pre-commit fixes --- jaxtyping/array_types.py | 2 +- jaxtyping/import_hook.py | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/jaxtyping/array_types.py b/jaxtyping/array_types.py index e74c5de..8b62f22 100644 --- a/jaxtyping/array_types.py +++ b/jaxtyping/array_types.py @@ -249,7 +249,7 @@ class _MetaAbstractDtype(type): ) if elem.endswith("#"): raise ValueError( - "As of jaxtyping v0.0.3, broadcastable dimensions are now denoted " + "As of jaxtyping v0.1.0, broadcastable dimensions are now denoted " "with a # at the start, rather than at the end" ) diff --git a/jaxtyping/import_hook.py b/jaxtyping/import_hook.py index 31f74e8..a8dce1a 100644 --- a/jaxtyping/import_hook.py +++ b/jaxtyping/import_hook.py @@ -31,19 +31,20 @@ # # Permission is hereby granted, free of charge, to any person obtaining a copy of this # software and associated documentation files (the "Software"), to deal in the Software -# without restriction, including without limitation the rights to use, copy, modify, merge, -# publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons -# to whom the Software is furnished to do so, subject to the following conditions: +# without restriction, including without limitation the rights to use, copy, modify, +# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to the following +# conditions: # -# The above copyright notice and this permission notice shall be included in all copies or -# substantial portions of the Software. +# The above copyright notice and this permission notice shall be included in all copies +# or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. +# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # --------- @@ -148,7 +149,8 @@ class _JaxtypingLoader(SourceFileLoader): ) def exec_module(self, module): - # Use a custom optimization marker – the import lock should make this monkey patch safe + # Use a custom optimization marker - the import lock should make this monkey + # patch safe with patch( "importlib._bootstrap_external.cache_from_source", _optimized_cache_from_source, @@ -216,7 +218,8 @@ class ImportHookManager: def install_import_hook( modules: Iterable[str], typechecker: Optional[Tuple[str, str]] ) -> ImportHookManager: - """Automatically apply `@jaxtyped`, and optionally a type checker, to all classes and functions. + """Automatically apply `@jaxtyped`, and optionally a type checker, to all classes + and functions. It will only be applied to modules loaded **after** this hook has been installed.