@@ -322,7 +322,7 @@ def _queries(cls) -> dict[str, type[Query]]:
322322 @cached_classproperty
323323 def _relation (cls ) -> type [Model [D ]]:
324324 """The model that this model is closely related to."""
325- return cls
325+ return cls # type: ignore[return-value]
326326
327327 @cached_classproperty
328328 def relation_join (cls ) -> str :
@@ -419,15 +419,15 @@ def _check_db(self, need_id: bool = True) -> D:
419419
420420 return self ._db
421421
422- def copy (self ) -> Model :
422+ def copy (self ) -> Model [ D ] :
423423 """Create a copy of the model object.
424424
425425 The field values and other state is duplicated, but the new copy
426426 remains associated with the same database as the old object.
427427 (A simple `copy.deepcopy` will not work because it would try to
428428 duplicate the SQLite connection.)
429429 """
430- new = self . __class__ ()
430+ new : Model [ D ] = type ( self ) ()
431431 new ._db = self ._db
432432 new ._values_fixed = self ._values_fixed .copy ()
433433 new ._values_flex = self ._values_flex .copy ()
@@ -535,7 +535,7 @@ def update(self, values):
535535 for key , value in values .items ():
536536 self [key ] = value
537537
538- def items (self ) -> Iterator [tuple [str , Any ]]:
538+ def items (self ) -> Iterator [tuple [str , AnyModel ]]:
539539 """Iterate over (key, value) pairs that this object contains.
540540 Computed fields are not included.
541541 """
@@ -1013,7 +1013,7 @@ class Database:
10131013 data is written in a transaction.
10141014 """
10151015
1016- def __init__ (self , path , timeout : float = 5.0 ):
1016+ def __init__ (self , path : bytes | str , timeout : float | int = 5.0 ) -> None :
10171017 if sqlite3 .threadsafety == 0 :
10181018 raise RuntimeError (
10191019 "sqlite3 must be compiled with multi-threading support"
@@ -1026,8 +1026,8 @@ def __init__(self, path, timeout: float = 5.0):
10261026 if hasattr (sqlite3 , "enable_callback_tracebacks" ):
10271027 sqlite3 .enable_callback_tracebacks (True )
10281028
1029- self .path = path
1030- self .timeout = timeout
1029+ self .path : bytes | str = path
1030+ self .timeout : float = float ( timeout )
10311031
10321032 self ._connections : dict [int , sqlite3 .Connection ] = {}
10331033 self ._tx_stacks : defaultdict [int , list [Transaction ]] = defaultdict (list )
0 commit comments