@@ -138,7 +138,12 @@ def test_eip_spec_version(module: ModuleType, github_token: Optional[str] = None
138138class EIPSpecTestItem (Item ):
139139 """Custom pytest test item to test EIP spec versions."""
140140
141- def __init__ (self , name , parent , module , github_token = None ):
141+ module : ModuleType
142+ github_token : Optional [str ]
143+
144+ def __init__ (
145+ self , name : str , parent : Module , module : ModuleType , github_token : Optional [str ] = None
146+ ):
142147 """
143148 Initialize the test item.
144149
@@ -154,21 +159,40 @@ def __init__(self, name, parent, module, github_token=None):
154159 self .github_token = github_token
155160
156161 @classmethod
157- def from_parent (cls , parent , module , github_token = None ) :
162+ def from_parent (cls , parent , ** kw ) -> "EIPSpecTestItem" :
158163 """
159164 Public constructor to define new tests.
160165 https://docs.pytest.org/en/latest/reference/reference.html#pytest.nodes.Node.from_parent.
166+
167+ Args:
168+ parent: The parent Node
169+ kw: Additional keyword arguments (module, github_token)
170+
161171 """
162- return super ().from_parent (
163- parent = parent , name = "test_eip_spec_version" , module = module , github_token = github_token
164- )
172+ module = kw .pop ("module" , None )
173+ github_token = kw .pop ("github_token" , None )
174+
175+ # Call the parent class's from_parent with just the required args
176+ item = super ().from_parent (parent = parent , name = "test_eip_spec_version" )
165177
166- def runtest (self ):
178+ # Set the additional attributes after creation
179+ item .module = module
180+ item .github_token = github_token
181+
182+ return item
183+
184+ def runtest (self ) -> None :
167185 """Define the test to execute for this item."""
168186 test_eip_spec_version (self .module , github_token = self .github_token )
169187
170- def reportinfo (self ):
171- """Get location information for this test item to use test reports."""
188+ def reportinfo (self ) -> tuple [str , int , str ]:
189+ """
190+ Get location information for this test item to use test reports.
191+
192+ Returns:
193+ A tuple of (path, line_number, description)
194+
195+ """
172196 return "spec_version_checker" , 0 , f"{ self .name } "
173197
174198
@@ -180,7 +204,7 @@ def pytest_collection_modifyitems(
180204
181205 modules : Set [Module ] = {item .parent for item in items if isinstance (item .parent , Module )}
182206 new_test_eip_spec_version_items = [
183- EIPSpecTestItem .from_parent (module , module .obj , github_token = github_token )
207+ EIPSpecTestItem .from_parent (parent = module , module = module .obj , github_token = github_token )
184208 for module in sorted (modules , key = lambda module : module .path )
185209 if is_test_for_an_eip (str (module .path ))
186210 ]
0 commit comments