1
- import abc
2
- from collections .abc import ItemsView , KeysView , Mapping , Sequence , ValuesView
3
- from typing import Any
1
+ from collections .abc import ItemsView , Iterator , KeysView , Mapping , Sequence , ValuesView
2
+ from typing import Any , Generic , TypeVar
4
3
5
4
from ..cresultproxy import BaseRow as BaseRow
6
5
6
+ _VT_co = TypeVar ("_VT_co" , covariant = True )
7
+
7
8
MD_INDEX : int
8
9
9
10
def rowproxy_reconstructor (cls , state ): ...
@@ -13,45 +14,48 @@ KEY_OBJECTS_ONLY: int
13
14
KEY_OBJECTS_BUT_WARN : int
14
15
KEY_OBJECTS_NO_WARN : int
15
16
16
- class Row (BaseRow , Sequence [Any ], metaclass = abc .ABCMeta ):
17
+ class Row (BaseRow , Sequence [Any ]):
18
+ # The count and index methods are inherited from Sequence.
19
+ # If the result set contains columns with the same names, these
20
+ # fields contains their respective values, instead. We don't reflect
21
+ # this in the stubs.
22
+ __hash__ = BaseRow .__hash__ # type: ignore[assignment]
23
+ def __lt__ (self , other : Row | tuple [Any , ...]) -> bool : ...
24
+ def __le__ (self , other : Row | tuple [Any , ...]) -> bool : ...
25
+ def __ge__ (self , other : Row | tuple [Any , ...]) -> bool : ...
26
+ def __gt__ (self , other : Row | tuple [Any , ...]) -> bool : ...
27
+ def __eq__ (self , other : object ) -> bool : ...
28
+ def __ne__ (self , other : object ) -> bool : ...
29
+ def keys (self ) -> list [str ]: ...
30
+ # The following methods are public, but have a leading underscore
31
+ # to prevent conflicts with column names.
17
32
@property
18
- def count (self ): ...
33
+ def _mapping (self ) -> RowMapping : ...
19
34
@property
20
- def index (self ): ...
21
- def __contains__ (self , key ): ...
22
- __hash__ = BaseRow .__hash__
23
- def __lt__ (self , other ): ...
24
- def __le__ (self , other ): ...
25
- def __ge__ (self , other ): ...
26
- def __gt__ (self , other ): ...
27
- def __eq__ (self , other ): ...
28
- def __ne__ (self , other ): ...
29
- def keys (self ): ...
30
-
31
- class LegacyRow (Row , metaclass = abc .ABCMeta ):
32
- def __contains__ (self , key ): ...
33
- def has_key (self , key ): ...
34
- def items (self ): ...
35
- def iterkeys (self ): ...
36
- def itervalues (self ): ...
37
- def values (self ): ...
35
+ def _fields (self ) -> tuple [str , ...]: ...
36
+ def _asdict (self ) -> dict [str , Any ]: ...
37
+
38
+ class LegacyRow (Row ):
39
+ def has_key (self , key : str ) -> bool : ...
40
+ def items (self ) -> list [tuple [str , Any ]]: ...
41
+ def iterkeys (self ) -> Iterator [str ]: ...
42
+ def itervalues (self ) -> Iterator [Any ]: ...
43
+ def values (self ) -> list [Any ]: ...
38
44
39
45
BaseRowProxy = BaseRow
40
46
RowProxy = Row
41
47
42
- class ROMappingView (KeysView [Any ], ValuesView [Any ], ItemsView [Any , Any ]):
43
- def __init__ (self , mapping , items ) -> None : ...
48
+ class ROMappingView (KeysView [str ], ValuesView [_VT_co ], ItemsView [str , _VT_co ], Generic [ _VT_co ]): # type: ignore[misc]
49
+ def __init__ (self , mapping : RowMapping , items : list [ _VT_co ] ) -> None : ...
44
50
def __len__ (self ) -> int : ...
45
- def __iter__ (self ): ...
46
- def __contains__ (self , item ): ...
47
- def __eq__ (self , other ): ...
48
- def __ne__ (self , other ): ...
51
+ def __iter__ (self ) -> Iterator [_VT_co ]: ... # type: ignore[override]
52
+ def __eq__ (self , other : ROMappingView [_VT_co ]) -> bool : ... # type: ignore[override]
53
+ def __ne__ (self , other : ROMappingView [_VT_co ]) -> bool : ... # type: ignore[override]
49
54
50
- class RowMapping (BaseRow , Mapping [Any , Any ]):
55
+ class RowMapping (BaseRow , Mapping [str , Row ]):
51
56
__getitem__ : Any
52
- def __iter__ (self ): ...
57
+ def __iter__ (self ) -> Iterator [ str ] : ...
53
58
def __len__ (self ) -> int : ...
54
- def __contains__ (self , key ): ...
55
- def items (self ): ...
56
- def keys (self ): ...
57
- def values (self ): ...
59
+ def items (self ) -> ROMappingView [tuple [str , Any ]]: ... # type: ignore[override]
60
+ def keys (self ) -> list [str ]: ... # type: ignore[override]
61
+ def values (self ) -> ROMappingView [Any ]: ... # type: ignore[override]
0 commit comments