@@ -41,17 +41,17 @@ class Field(FieldType):
4141 storeTermVectors = property (FieldType .storeTermVectors , FieldType .setStoreTermVectors )
4242 tokenized = property (FieldType .tokenized , FieldType .setTokenized )
4343
44- properties = {name for name in locals () if not name .startswith ('__' )}
45- types = {int : ' long' , float : ' double' , str : ' string' }
44+ properties = {name for name in locals () if not name .startswith ("__" )}
45+ types = {int : " long" , float : " double" , str : " string" }
4646 types .update (
47- NUMERIC = ' long' , BINARY = ' string' , SORTED = ' string' , SORTED_NUMERIC = ' long' , SORTED_SET = ' string'
47+ NUMERIC = " long" , BINARY = " string" , SORTED = " string" , SORTED_NUMERIC = " long" , SORTED_SET = " string"
4848 )
4949 dimensions = property (
5050 FieldType .pointDimensionCount ,
5151 lambda self , count : self .setDimensions (count , Long .BYTES ),
5252 )
5353
54- def __init__ (self , name : str , docValuesType = '' , indexOptions = '' , dimensions = 0 , ** settings ):
54+ def __init__ (self , name : str , docValuesType = "" , indexOptions = "" , dimensions = 0 , ** settings ):
5555 super ().__init__ ()
5656 self .name = name
5757 for name in self .properties .intersection (settings ):
@@ -64,24 +64,24 @@ def __init__(self, name: str, docValuesType='', indexOptions='', dimensions=0, *
6464 self .indexOptions = getattr (index .IndexOptions , indexOptions .upper ())
6565 if docValuesType :
6666 self .docValuesType = getattr (index .DocValuesType , docValuesType .upper ())
67- name = docValuesType .title ().replace ('_' , '' )
68- self .docValueClass = getattr (document , name + ' DocValuesField' )
67+ name = docValuesType .title ().replace ("_" , "" )
68+ self .docValueClass = getattr (document , name + " DocValuesField" )
6969 if self .stored or self .indexed or self .dimensions :
7070 settings = self .settings
71- del settings [' docValuesType' ]
71+ del settings [" docValuesType" ]
7272 self .docValueLess = Field (self .name , ** settings )
7373 assert self .stored or self .indexed or self .docvalues or self .dimensions
7474
7575 @classmethod
7676 def String (
77- cls , name : str , tokenized = False , omitNorms = True , indexOptions = ' DOCS' , ** settings
77+ cls , name : str , tokenized = False , omitNorms = True , indexOptions = " DOCS" , ** settings
7878 ) -> Self :
7979 """Return Field with default settings for strings."""
8080 settings .update (tokenized = tokenized , omitNorms = omitNorms , indexOptions = indexOptions )
8181 return cls (name , ** settings )
8282
8383 @classmethod
84- def Text (cls , name : str , indexOptions = ' DOCS_AND_FREQS_AND_POSITIONS' , ** settings ) -> Self :
84+ def Text (cls , name : str , indexOptions = " DOCS_AND_FREQS_AND_POSITIONS" , ** settings ) -> Self :
8585 """Return Field with default settings for text."""
8686 return cls (name , indexOptions = indexOptions , ** settings )
8787
@@ -97,7 +97,7 @@ def docvalues(self):
9797 def settings (self ) -> dict :
9898 """dict representation of settings"""
9999 defaults = FieldType ()
100- result = {' dimensions' : self .dimensions } if self .dimensions else {}
100+ result = {" dimensions" : self .dimensions } if self .dimensions else {}
101101 for name in Field .properties :
102102 value = getattr (self , name )
103103 if value != getattr (defaults , name )():
@@ -110,7 +110,7 @@ def items(self, *values) -> Iterator[document.Field]:
110110 types = {int : int , float : util .NumericUtils .doubleToSortableLong }
111111 for value in values :
112112 yield self .docValueClass (self .name , types .get (type (value ), util .BytesRef )(value ))
113- self = getattr (self , ' docValueLess' , self )
113+ self = getattr (self , " docValueLess" , self )
114114 if self .dimensions :
115115 for value in values :
116116 cls = document .LongPoint if isinstance (value , int ) else document .DoublePoint
@@ -132,7 +132,7 @@ class NestedField(Field):
132132 sep: field separator used on name and values
133133 """
134134
135- def __init__ (self , name : str , sep : str = '.' , ** settings ):
135+ def __init__ (self , name : str , sep : str = "." , ** settings ):
136136 super ().__init__ (name , ** Field .String (name , ** settings ).settings )
137137 self .sep = sep
138138 self .names = tuple (self .values (name ))
@@ -145,7 +145,7 @@ def values(self, value: str) -> Iterator[str]:
145145
146146 def items (self , * values : str ) -> Iterator [document .Field ]:
147147 """Generate indexed component fields."""
148- field = getattr (self , ' docValueLess' , self )
148+ field = getattr (self , " docValueLess" , self )
149149 for value in values :
150150 for name , text in zip (self .names , self .values (value )):
151151 yield document .Field (name , text , field )
@@ -176,7 +176,7 @@ def __init__(self, name: str, dimensions: int = 1, **settings):
176176 def timestamp (cls , date ) -> float :
177177 """Return utc timestamp from date or time tuple."""
178178 if isinstance (date , datetime .date ):
179- return calendar .timegm (date .timetuple ()) + getattr (date , ' microsecond' , 0 ) * 1e-6
179+ return calendar .timegm (date .timetuple ()) + getattr (date , " microsecond" , 0 ) * 1e-6
180180 return float (calendar .timegm (tuple (date ) + (None , 1 , 1 , 0 , 0 , 0 )[len (date ) :]))
181181
182182 def items (self , * dates ) -> Iterator [document .Field ]:
@@ -327,7 +327,7 @@ def dict(self, *names: str, **defaults) -> dict:
327327 result = super ().dict (* names , ** defaults )
328328 result .update (__id__ = self .id , __score__ = self .score )
329329 if self .sortkeys :
330- result [' __sortkeys__' ] = self .sortkeys
330+ result [" __sortkeys__" ] = self .sortkeys
331331 return result
332332
333333
@@ -348,7 +348,7 @@ class Hits:
348348
349349 def __init__ (self , searcher , scoredocs : Sequence , count = 0 , fields = None ):
350350 self .searcher , self .scoredocs = searcher , scoredocs
351- if hasattr (count , ' relation' ):
351+ if hasattr (count , " relation" ):
352352 cls = int if count .relation == search .TotalHits .Relation .EQUAL_TO else float
353353 count = cls (count .value ())
354354 self .count , self .fields = count , fields
@@ -372,20 +372,20 @@ def __getitem__(self, index):
372372
373373 @property
374374 def ids (self ) -> Iterator [int ]:
375- return map (operator .attrgetter (' doc' ), self .scoredocs )
375+ return map (operator .attrgetter (" doc" ), self .scoredocs )
376376
377377 @property
378378 def scores (self ) -> Iterator [float ]:
379- return map (operator .attrgetter (' score' ), self .scoredocs )
379+ return map (operator .attrgetter (" score" ), self .scoredocs )
380380
381381 @property
382382 def maxscore (self ) -> float :
383383 """max score of present hits; not necessarily of all matches"""
384- return max (self .scores , default = float (' nan' ))
384+ return max (self .scores , default = float (" nan" ))
385385
386386 def items (self ) -> Iterator [tuple ]:
387387 """Generate zipped ids and scores."""
388- return map (operator .attrgetter (' doc' , ' score' ), self .scoredocs )
388+ return map (operator .attrgetter (" doc" , " score" ), self .scoredocs )
389389
390390 def highlights (self , query : search .Query , ** fields : int ) -> Iterator [dict ]:
391391 """Generate highlighted fields for each hit.
@@ -406,7 +406,7 @@ def docvalues(self, field: str, type=None) -> dict:
406406
407407 def groupby (
408408 self , func : Callable , count : int | None = None , docs : int | None = None
409- ) -> ' Groups' :
409+ ) -> " Groups" :
410410 """Return ordered list of [Hits][lupyne.engine.documents.Hits] grouped by value of function applied to doc ids.
411411
412412 Optionally limit the number of groups and docs per group.
@@ -480,7 +480,7 @@ def __init__(self, field: str, sort=None, cache=True, **attrs):
480480 self .groupSort = self .sortWithinGroup = sort
481481 self .fillSortFields = True
482482 if cache :
483- self .setCachingInMB (float (' inf' ), True )
483+ self .setCachingInMB (float (" inf" ), True )
484484 for name in attrs :
485485 getattr (type (self ), name ).__set__ (self , attrs [name ])
486486
0 commit comments