7171import datetime
7272import re
7373from pprint import pformat
74- from typing import Dict , Iterable , List , Optional , Sequence , Type , Union
74+ from typing import Any , Dict , Iterable , List , Mapping , Optional , Sequence , Type , Union
7575
7676# 3rd party
7777import attr
78- import lxml .objectify # type: ignore
78+ import lxml .objectify # type: ignore[import-untyped]
7979from attr_utils .docstrings import add_attrs_doc
8080from attr_utils .serialise import serde
8181from chemistry_tools .formulae import Formula
@@ -141,7 +141,7 @@ def __init__(
141141 else :
142142 raise TypeError (f"'matches' must be a dictionary, not { type (matches )} " )
143143
144- def to_dict (self ):
144+ def to_dict (self ) -> Mapping [ str , Any ] :
145145 """
146146 Return a dictionary representation of the class.
147147 """
@@ -321,7 +321,7 @@ def __init__(
321321 "rt_ranges" ,
322322 ]
323323
324- def to_dict (self ):
324+ def to_dict (self ) -> Mapping [ str , Any ] :
325325 """
326326 Return a dictionary representation of the class.
327327 """
@@ -383,10 +383,10 @@ class RTRange:
383383 """
384384
385385 #: The start time in minutes
386- start : datetime .timedelta = attr .ib (converter = make_timedelta , default = 0.0 ) # type: ignore
386+ start : datetime .timedelta = attr .ib (converter = make_timedelta , default = 0.0 ) # type: ignore[assignment]
387387
388388 #: The end time in minutes
389- end : datetime .timedelta = attr .ib (converter = make_timedelta , default = 0.0 ) # type: ignore
389+ end : datetime .timedelta = attr .ib (converter = make_timedelta , default = 0.0 ) # type: ignore[assignment]
390390
391391 @classmethod
392392 def from_xml (cls , element : lxml .objectify .ObjectifiedElement ) -> "RTRange" :
@@ -417,10 +417,10 @@ class Flag(str):
417417 __slots__ = ("severity" , )
418418 severity : int
419419
420- def __copy__ (self ):
420+ def __copy__ (self ) -> "Flag" :
421421 return Flag (str (self ), self .severity )
422422
423- def __deepcopy__ (self , memodict = {}):
423+ def __deepcopy__ (self , memodict = {}) -> "Flag" : # noqa: MAN001
424424 return Flag (str (self ), int (self .severity ))
425425
426426 def __new__ (cls : Type ["Flag" ], string : str , severity : int ) -> "Flag" : # noqa: D102
@@ -429,13 +429,13 @@ def __new__(cls: Type["Flag"], string: str, severity: int) -> "Flag": # noqa: D
429429
430430 return obj
431431
432- def __eq__ (self , other ) -> bool :
432+ def __eq__ (self , other ) -> bool : # noqa: MAN001
433433 if isinstance (other , Flag ):
434434 return str (self ) == str (other ) and self .severity == other .severity
435435 else :
436436 return super ().__eq__ (other )
437437
438- def __ne__ (self , other ) -> bool :
438+ def __ne__ (self , other ) -> bool : # noqa: MAN001
439439 return NotImplemented
440440
441441 def __repr__ (self ) -> str :
@@ -465,16 +465,16 @@ class Score(float):
465465
466466 flag : Flag
467467
468- def __copy__ (self ):
468+ def __copy__ (self ) -> "Score" :
469469 return Score (float (self ), str (self .flag ), self .flag .severity )
470470
471- def __deepcopy__ (self , memodict = {}):
471+ def __deepcopy__ (self , memodict = {}) -> "Score" : # noqa: MAN001
472472 return Score (float (self ), str (self .flag ), int (self .flag .severity ))
473473
474- def __init__ (self , score , flag_string : str = '' , flag_severity : int = 0 ):
474+ def __init__ (self , score , flag_string : str = '' , flag_severity : int = 0 ): # noqa: MAN001
475475 float .__init__ (float (score ))
476476
477- def __new__ (cls , score , flag_string : str = '' , flag_severity : int = 0 ) -> "Score" : # noqa: D102
477+ def __new__ (cls , score , flag_string : str = '' , flag_severity : int = 0 ) -> "Score" : # noqa: D102,MAN001
478478 obj = super ().__new__ (cls , float (score ))
479479 obj .flag = Flag (flag_string , flag_severity )
480480
@@ -497,13 +497,13 @@ def __str__(self) -> str:
497497
498498 return str (float (self ))
499499
500- def __eq__ (self , other ) -> bool :
500+ def __eq__ (self , other ) -> bool : # noqa: MAN001
501501 if isinstance (other , Score ):
502502 return float (self ) == float (other ) and self .flag == other .flag
503503 else :
504504 return super ().__eq__ (other )
505505
506- def __ne__ (self , other ) -> bool :
506+ def __ne__ (self , other ) -> bool : # noqa: MAN001
507507 return NotImplemented
508508
509509
@@ -562,7 +562,7 @@ class LocationDict(TypedDict, total=False):
562562
563563class _CompoundStrPPrinter (FancyPrinter ):
564564
565- def _repr (self , object , context , level ): # noqa: A002 # pylint: disable=redefined-builtin
565+ def _repr (self , object , context , level ) -> str : # noqa: MAN001, A002 # pylint: disable=redefined-builtin
566566 if isinstance (object , (Molecule , Formula )):
567567 self ._readable = True
568568 self ._recursive = False
@@ -619,7 +619,7 @@ def __init__(
619619 else :
620620 self .spectra = []
621621
622- def to_dict (self ):
622+ def to_dict (self ) -> Mapping [ str , Any ] :
623623 """
624624 Return a dictionary representation of the class.
625625 """
0 commit comments