@@ -155,10 +155,10 @@ def from_json(d: JsonDict):
155155
156156 base_cls = globals ().get ("LitType" )
157157 cls = globals ().get (type_name ) # class by name from this module
158- if cls is None or not issubclass (cls , base_cls ):
158+ if cls is None or not issubclass (cls , base_cls ): # pyrefly: ignore[bad-argument-type]
159159 raise NameError (f"{ type_name } is not a valid LitType." )
160160
161- return cls (** {k : d [k ] for k in d if k != "__name__" })
161+ return cls (** {k : d [k ] for k in d if k != "__name__" }) # pyrefly: ignore[not-callable]
162162
163163Spec = dict [str , LitType ]
164164
@@ -174,7 +174,7 @@ def _remap_leaf(leaf: LitType, keymap: dict[str, str]) -> LitType:
174174 k : (keymap .get (v , v ) if k in FIELD_REF_ATTRIBUTES else v )
175175 for k , v in d .items ()
176176 }
177- return leaf .__class__ (** d )
177+ return leaf .__class__ (** d ) # pyrefly: ignore[bad-argument-type]
178178
179179
180180def remap_spec (spec : Spec , keymap : dict [str , str ]) -> Spec :
@@ -201,7 +201,7 @@ class StringLitType(LitType):
201201 Mainly used for string inputs that have special formatting, and should only
202202 be edited manually.
203203 """
204- default : str = ""
204+ default : str = "" # pyrefly: ignore[bad-override]
205205
206206 def validate_input (self , value , spec : Spec , example : Input ):
207207 if not isinstance (value , str ):
@@ -260,13 +260,13 @@ def validate_output(self, value, output_spec: Spec, output_dict: JsonDict,
260260@attr .s (auto_attribs = True , frozen = True , kw_only = True )
261261class ListLitType (LitType ):
262262 """List type."""
263- default : Sequence [Any ] = None
263+ default : Sequence [Any ] = None # pyrefly: ignore[bad-assignment, bad-override]
264264
265265
266266@attr .s (auto_attribs = True , frozen = True , kw_only = True )
267267class _StringCandidateList (ListLitType ):
268268 """A list of (text, score) tuples."""
269- default : ScoredTextCandidates = None
269+ default : ScoredTextCandidates = None # pyrefly: ignore[bad-assignment]
270270
271271 def validate_output (self , value , output_spec : Spec , output_dict : JsonDict ,
272272 input_spec : Spec , dataset_spec : Spec ,
@@ -373,9 +373,9 @@ class TokenTopKPreds(ListLitType):
373373
374374 The inner list should contain (word, probability) in descending order.
375375 """
376- default : Sequence [ScoredTextCandidates ] = None
376+ default : Sequence [ScoredTextCandidates ] = None # pyrefly: ignore[bad-assignment]
377377
378- align : str = None # name of a Tokens field in the model output
378+ align : str = None # name of a Tokens field in the model output # pyrefly: ignore[bad-assignment]
379379 parent : Optional [str ] = None
380380
381381 def _validate_scored_candidates (self , scored_candidates ):
@@ -389,7 +389,7 @@ def _validate_scored_candidates(self, scored_candidates):
389389 if scored_candidate [1 ] is not None :
390390 if not isinstance (scored_candidate [1 ], NumericTypes ):
391391 raise ValueError (f"{ scored_candidate } second element is not a num" )
392- if prev_val < scored_candidate [1 ]:
392+ if prev_val < scored_candidate [1 ]: # pyrefly: ignore[unsupported-operation]
393393 raise ValueError (
394394 "TokenTopKPreds candidates are not in descending order" )
395395 else :
@@ -414,7 +414,7 @@ class Scalar(LitType):
414414 """Scalar value, a single float or int."""
415415 min_val : float = 0
416416 max_val : float = 1
417- default : float = 0
417+ default : float = 0 # pyrefly: ignore[bad-override]
418418 step : float = .01
419419
420420 def validate_input (self , value , spec : Spec , example : Input ):
@@ -464,7 +464,7 @@ class TokenScores(_FloatList):
464464@attr .s (auto_attribs = True , frozen = True , kw_only = True )
465465class ReferenceScores (ListLitType ):
466466 """Score of one or more target sequences."""
467- default : Sequence [float ] = None
467+ default : Sequence [float ] = None # pyrefly: ignore[bad-assignment]
468468
469469 # name of a TextSegment or ReferenceTexts field in the input
470470 parent : Optional [str ] = None
@@ -504,7 +504,7 @@ def validate_input(self, value, spec: Spec, example: Input):
504504@attr .s (auto_attribs = True , frozen = True , kw_only = True )
505505class _Tensor (LitType ):
506506 """A tensor type."""
507- default : Sequence [float ] = None
507+ default : Sequence [float ] = None # pyrefly: ignore[bad-assignment, bad-override]
508508
509509 def validate_input (self , value , spec : Spec , example : Input ):
510510 if isinstance (value , list ):
@@ -585,7 +585,7 @@ class SpanLabels(ListLitType):
585585 Span labels can cover more than one token, may not cover all tokens in the
586586 sentence, and may overlap with each other.
587587 """
588- default : Sequence [dtypes .SpanLabel ] = None
588+ default : Sequence [dtypes .SpanLabel ] = None # pyrefly: ignore[bad-assignment]
589589 align : str # name of Tokens field
590590 parent : Optional [str ] = None
591591
@@ -609,7 +609,7 @@ class EdgeLabels(ListLitType):
609609 https://github.com/nyu-mll/jiant/tree/master/probing#data-format for more
610610 details.
611611 """
612- default : Sequence [dtypes .EdgeLabel ] = None
612+ default : Sequence [dtypes .EdgeLabel ] = None # pyrefly: ignore[bad-assignment]
613613 align : str # name of Tokens field
614614
615615 def validate_output (self , value , output_spec : Spec , output_dict : JsonDict ,
@@ -636,7 +636,7 @@ class MultiSegmentAnnotations(ListLitType):
636636 TODO(lit-dev): by default, spans are treated as bytes in this context.
637637 Make this configurable, if some spans need to refer to tokens instead.
638638 """
639- default : Sequence [dtypes .AnnotationCluster ] = None
639+ default : Sequence [dtypes .AnnotationCluster ] = None # pyrefly: ignore[bad-assignment]
640640 exclusive : bool = False # if true, treat as candidate list
641641 background : bool = False # if true, don't emphasize in visualization
642642
@@ -775,7 +775,7 @@ class SubwordOffsets(ListLitType):
775775
776776 offsets[i] should be the index of the first wordpiece for input token i.
777777 """
778- default : Sequence [int ] = None
778+ default : Sequence [int ] = None # pyrefly: ignore[bad-assignment]
779779 align_in : str # name of field in data spec
780780 align_out : str # name of field in model output spec
781781
@@ -793,7 +793,7 @@ class SparseMultilabelPreds(_StringCandidateList):
793793
794794 The tuples are of the label and the score.
795795 """
796- default : ScoredTextCandidates = None
796+ default : ScoredTextCandidates = None # pyrefly: ignore[bad-assignment]
797797 vocab : Optional [Sequence [str ]] = None # label names
798798 parent : Optional [str ] = None
799799
@@ -816,7 +816,7 @@ class SingleFieldMatcher(FieldMatcher):
816816
817817 UI will materialize this to a dropdown-list.
818818 """
819- default : str = None
819+ default : str = None # pyrefly: ignore[bad-assignment, bad-override]
820820
821821
822822@attr .s (auto_attribs = True , frozen = True , kw_only = True )
@@ -826,7 +826,7 @@ class MultiFieldMatcher(FieldMatcher):
826826 UI will materialize this to multiple checkboxes. Use this when the user needs
827827 to pick more than one field in UI.
828828 """
829- default : Sequence [str ] = [] # default names of selected items.
829+ default : Sequence [str ] = [] # default names of selected items. # pyrefly: ignore[bad-override]
830830 select_all : bool = False # Select all by default (overriddes default).
831831
832832
@@ -840,20 +840,20 @@ class Salience(LitType):
840840@attr .s (auto_attribs = True , frozen = True , kw_only = True )
841841class TokenSalience (Salience ):
842842 """Metadata about a returned token salience map."""
843- default : dtypes .TokenSalience = None
843+ default : dtypes .TokenSalience = None # pyrefly: ignore[bad-assignment, bad-override]
844844
845845
846846@attr .s (auto_attribs = True , frozen = True , kw_only = True )
847847class FeatureSalience (Salience ):
848848 """Metadata about a returned feature salience map."""
849- default : dtypes .FeatureSalience = None
849+ default : dtypes .FeatureSalience = None # pyrefly: ignore[bad-assignment, bad-override]
850850
851851
852852@attr .s (auto_attribs = True , frozen = True , kw_only = True )
853853class FrameSalience (Salience ):
854854 """Metadata about a returned frame salience map."""
855855
856- default : dtypes .FrameSalience = None
856+ default : dtypes .FrameSalience = None # pyrefly: ignore[bad-assignment, bad-override]
857857
858858
859859@attr .s (auto_attribs = True , frozen = True , kw_only = True )
@@ -869,13 +869,13 @@ class ImageSalience(Salience):
869869@attr .s (auto_attribs = True , frozen = True , kw_only = True )
870870class SequenceSalience (Salience ):
871871 """Metadata about a returned sequence salience map."""
872- default : dtypes .SequenceSalienceMap = None
872+ default : dtypes .SequenceSalienceMap = None # pyrefly: ignore[bad-assignment, bad-override]
873873
874874
875875@attr .s (auto_attribs = True , frozen = True , kw_only = True )
876876class BooleanLitType (LitType ):
877877 """Boolean value."""
878- default : bool = False
878+ default : bool = False # pyrefly: ignore[bad-override]
879879
880880 def validate_input (self , value , spec , example : Input ):
881881 if not isinstance (value , bool ):
@@ -916,7 +916,7 @@ class MetricBestValue(dtypes.EnumSerializableAsValues, enum.Enum):
916916@attr .s (auto_attribs = True , frozen = True , kw_only = True )
917917class MetricResult (LitType ):
918918 """Score returned from the computation of a Metric."""
919- default : float = 0
919+ default : float = 0 # pyrefly: ignore[bad-override]
920920 description : str = ""
921921 best_value : MetricBestValue = MetricBestValue .NONE
922922
@@ -934,7 +934,7 @@ class SalienceTargetInfo(LitType):
934934
935935 Value is a dict with keys 'field' (str) and 'index' (Optional[int]).
936936 """
937- default : Optional [Mapping [str , Any ]] = None
937+ default : Optional [Mapping [str , Any ]] = None # pyrefly: ignore[bad-override]
938938
939939
940940# LINT.ThenChange(../client/lib/lit_types.ts)
0 commit comments