1+ from __future__ import annotations
2+ from typing import List , Optional
13import logging
24from itertools import * # noqa
35from jsonpath_ng .lexer import JsonPathLexer
@@ -20,7 +22,7 @@ class JSONPath:
2022 JSONPath semantics.
2123 """
2224
23- def find (self , data ):
25+ def find (self , data ) -> List [ DatumInContext ] :
2426 """
2527 All `JSONPath` types support `find()`, which returns an iterable of `DatumInContext`s.
2628 They keep track of the path followed to the current location, so if the calling code
@@ -99,7 +101,7 @@ def wrap(cls, data):
99101 else :
100102 return cls (data )
101103
102- def __init__ (self , value , path = None , context = None ):
104+ def __init__ (self , value , path : Optional [ JSONPath ] = None , context : Optional [ DatumInContext ] = None ):
103105 self .value = value
104106 self .path = path or This ()
105107 self .context = None if context is None else DatumInContext .wrap (context )
@@ -113,7 +115,7 @@ def in_context(self, context, path):
113115 return DatumInContext (value = self .value , path = path , context = context )
114116
115117 @property
116- def full_path (self ):
118+ def full_path (self ) -> JSONPath :
117119 return self .path if self .context is None else self .context .full_path .child (self .path )
118120
119121 @property
@@ -193,7 +195,7 @@ class Root(JSONPath):
193195 The root is the topmost datum without any context attached.
194196 """
195197
196- def find (self , data ):
198+ def find (self , data ) -> List [ DatumInContext ] :
197199 if not isinstance (data , DatumInContext ):
198200 return [DatumInContext (data , path = Root (), context = None )]
199201 else :
0 commit comments