summaryrefslogtreecommitdiff
path: root/jsonschema/_types.py
diff options
context:
space:
mode:
authorStephen Rosen <sirosen@globus.org>2022-01-05 23:00:09 +0000
committerStephen Rosen <sirosen@globus.org>2022-01-05 23:00:09 +0000
commit631fba10862dca89f032231e1aba70225379f314 (patch)
tree60640868cf78c0b70ca7ca24c97310f9e91e4942 /jsonschema/_types.py
parent2474242192af8108086410d32b4d1307675d471a (diff)
downloadjsonschema-631fba10862dca89f032231e1aba70225379f314.tar.gz
Fix nitpick error on type annotation
Nitpick was failing on TYPE_CHECKER: ClassVar[TypeChecker] It's not clear what to do about this. `TypeChecker` was imported correctly from `jsonschema._types` and is noted in the doc as `jsonschema.TypeChecker`. We can't import the `jsonschema` name at runtime because that would be circular. To resolve, use `typing.TYPE_CHECKING` to conditionally import `jsonschema` at type-checking time. This avoids the circular import but allows us to write TYPE_CHECKER: ClassVar[jsonschema.TypeChecker] As a result, Sphinx correctly builds a cross-reference from the annotation, the annotation is still accurate, and runtime behavior is left untouched.
Diffstat (limited to 'jsonschema/_types.py')
-rw-r--r--jsonschema/_types.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/jsonschema/_types.py b/jsonschema/_types.py
index b024f7e..d0525bd 100644
--- a/jsonschema/_types.py
+++ b/jsonschema/_types.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import numbers
import typing