1
1
import sys
2
- from typing import Optional , List , Dict , Tuple , Generic , TypeVar
2
+ from typing import Optional , Generic , TypeVar
3
3
4
4
from _pytest .python import Function
5
5
@@ -46,20 +46,20 @@ class ItemList:
46
46
47
47
def __init__ (
48
48
self ,
49
- items : List [Item ],
49
+ items : list [Item ],
50
50
settings : Settings ,
51
51
scope : Scope ,
52
- rel_marks : List ["RelativeMark[Item]" ],
53
- dep_marks : List ["RelativeMark[Item]" ],
52
+ rel_marks : list ["RelativeMark[Item]" ],
53
+ dep_marks : list ["RelativeMark[Item]" ],
54
54
) -> None :
55
55
self .items = items
56
56
self .settings = settings
57
57
self .scope = scope
58
- self .start_items : List [ Tuple [int , List [Item ]]] = []
59
- self .end_items : List [ Tuple [int , List [Item ]]] = []
60
- self .unordered_items : List [Item ] = []
61
- self ._start_items : Dict [int , List [Item ]] = {}
62
- self ._end_items : Dict [int , List [Item ]] = {}
58
+ self .start_items : list [ tuple [int , list [Item ]]] = []
59
+ self .end_items : list [ tuple [int , list [Item ]]] = []
60
+ self .unordered_items : list [Item ] = []
61
+ self ._start_items : dict [int , list [Item ]] = {}
62
+ self ._end_items : dict [int , list [Item ]] = {}
63
63
self .all_rel_marks = rel_marks
64
64
self .all_dep_marks = dep_marks
65
65
self .rel_marks = filter_marks (rel_marks , items )
@@ -77,7 +77,7 @@ def handle_order_mark(self, item: Item) -> None:
77
77
else :
78
78
self ._start_items .setdefault (item .order , []).append (item )
79
79
80
- def sort_numbered_items (self ) -> List [Item ]:
80
+ def sort_numbered_items (self ) -> list [Item ]:
81
81
self .start_items = sorted (self ._start_items .items ())
82
82
self .end_items = sorted (self ._end_items .items ())
83
83
sorted_list = []
@@ -120,17 +120,17 @@ def print_unhandled_items(self) -> None:
120
120
def number_of_rel_groups (self ) -> int :
121
121
return len (self .rel_marks ) + len (self .dep_marks )
122
122
123
- def handle_rel_marks (self , sorted_list : List [Item ]) -> None :
123
+ def handle_rel_marks (self , sorted_list : list [Item ]) -> None :
124
124
self .handle_relative_marks (self .rel_marks , sorted_list , self .all_rel_marks )
125
125
126
- def handle_dep_marks (self , sorted_list : List [Item ]) -> None :
126
+ def handle_dep_marks (self , sorted_list : list [Item ]) -> None :
127
127
self .handle_relative_marks (self .dep_marks , sorted_list , self .all_dep_marks )
128
128
129
129
@staticmethod
130
130
def handle_relative_marks (
131
- marks : List ["RelativeMark[Item]" ],
132
- sorted_list : List [Item ],
133
- all_marks : List ["RelativeMark[Item]" ],
131
+ marks : list ["RelativeMark[Item]" ],
132
+ sorted_list : list [Item ],
133
+ all_marks : list ["RelativeMark[Item]" ],
134
134
) -> None :
135
135
for mark in reversed (marks ):
136
136
if move_item (mark , sorted_list ):
@@ -152,9 +152,9 @@ class ItemGroup:
152
152
"""
153
153
154
154
def __init__ (
155
- self , items : Optional [List [Item ]] = None , order : Optional [int ] = None
155
+ self , items : Optional [list [Item ]] = None , order : Optional [int ] = None
156
156
) -> None :
157
- self .items : List [Item ] = items or []
157
+ self .items : list [Item ] = items or []
158
158
self .order = order
159
159
self .nr_rel_items = 0
160
160
@@ -166,7 +166,7 @@ def dec_rel_marks(self) -> None:
166
166
if self .order is None :
167
167
self .nr_rel_items -= 1
168
168
169
- def extend (self , groups : List ["ItemGroup" ], order : Optional [int ]) -> None :
169
+ def extend (self , groups : list ["ItemGroup" ], order : Optional [int ]) -> None :
170
170
for group in groups :
171
171
self .items .extend (group .items )
172
172
self .order = order
@@ -190,8 +190,8 @@ def __init__(
190
190
191
191
192
192
def filter_marks (
193
- marks : List [RelativeMark [_ItemType ]], all_items : List [Item ]
194
- ) -> List [RelativeMark [_ItemType ]]:
193
+ marks : list [RelativeMark [_ItemType ]], all_items : list [Item ]
194
+ ) -> list [RelativeMark [_ItemType ]]:
195
195
result = []
196
196
for mark in marks :
197
197
if mark .item in all_items and mark .item_to_move in all_items :
@@ -201,7 +201,7 @@ def filter_marks(
201
201
return result
202
202
203
203
204
- def move_item (mark : RelativeMark [_ItemType ], sorted_items : List [_ItemType ]) -> bool :
204
+ def move_item (mark : RelativeMark [_ItemType ], sorted_items : list [_ItemType ]) -> bool :
205
205
if (
206
206
mark .item not in sorted_items
207
207
or mark .item_to_move not in sorted_items
0 commit comments