5050def flatten (vals ):
5151 """Flatten vals recursively, lazily using yield"""
5252
53- def is_coll (thing ):
53+ def is_coll (thing ) -> bool :
5454 """Return True if the thing looks like a collection.
5555
5656 This is not exhaustive, do not use in general.
@@ -77,7 +77,7 @@ def flatten_type(t):
7777 return [t ]
7878
7979
80- def overlaps (a : list , b : list ):
80+ def overlaps (a : list , b : list ) -> bool :
8181 """Return true if there are any elements in common between a and b"""
8282 return len (set (a ).intersection (set (b ))) > 0
8383
@@ -248,7 +248,7 @@ class _ValueObject(Entity, ABC):
248248 See https://en.wikipedia.org/wiki/Value_object for more on Value Objects.
249249 """
250250
251- def __hash__ (self ):
251+ def __hash__ (self ) -> int :
252252 return encode_canonical_json (self .ga4gh_serialize ()).decode ("utf-8" ).__hash__ ()
253253
254254 def ga4gh_serialize (self ) -> dict :
@@ -280,14 +280,14 @@ class Ga4ghIdentifiableObject(_ValueObject, ABC):
280280 description = "A sha512t24u digest created using the VRS Computed Identifier algorithm." ,
281281 )
282282
283- def __lt__ (self , other ):
283+ def __lt__ (self , other ) -> bool :
284284 return self .get_or_create_digest () < other .get_or_create_digest ()
285285
286286 @staticmethod
287287 def is_ga4gh_identifiable () -> bool :
288288 return True
289289
290- def has_valid_ga4gh_id (self ):
290+ def has_valid_ga4gh_id (self ) -> bool | str | None :
291291 return self .id and GA4GH_IR_REGEXP .match (self .id ) is not None
292292
293293 def compute_digest (
@@ -354,7 +354,7 @@ def get_or_create_ga4gh_identifier(
354354 else :
355355 return self .compute_ga4gh_identifier (recompute )
356356
357- def compute_ga4gh_identifier (self , recompute : bool = False , as_version = None ):
357+ def compute_ga4gh_identifier (self , recompute : bool = False , as_version = None ) -> str :
358358 """Return a GA4GH Computed Identifier.
359359
360360 If ``as_version`` is provided, other parameters are ignored and a computed
@@ -611,7 +611,7 @@ def validate_start_end(
611611 raise ValueError (err_msg )
612612 return v
613613
614- def ga4gh_serialize_as_version (self , as_version : PrevVrsVersion ):
614+ def ga4gh_serialize_as_version (self , as_version : PrevVrsVersion ) -> str :
615615 """Return a serialized string following the conventions for SequenceLocation
616616 serialization as defined in the VRS version specified by ``as_version``.
617617
@@ -643,7 +643,7 @@ def ga4gh_serialize_as_version(self, as_version: PrevVrsVersion):
643643 msg = f"Received an unexpected value for `as_version`: { as_version } . MUST be an instance of `PrevVrsVersion`."
644644 raise TypeError (msg )
645645
646- def get_refget_accession (self ):
646+ def get_refget_accession (self ) -> str | None :
647647 if isinstance (self .sequenceReference , SequenceReference ):
648648 return self .sequenceReference .refgetAccession
649649 if isinstance (self .sequenceReference , iriReference ):
@@ -685,7 +685,7 @@ class Allele(_VariationBase, BaseModelForbidExtra):
685685 Field (..., description = "An expression of the sequence state" )
686686 )
687687
688- def ga4gh_serialize_as_version (self , as_version : PrevVrsVersion ):
688+ def ga4gh_serialize_as_version (self , as_version : PrevVrsVersion ) -> str :
689689 """Return a serialized string following the conventions for
690690 Allele serialization as defined in the VRS version specified by 'as_version`.
691691
0 commit comments