@@ -53,10 +53,7 @@ def test_imports(self) -> frozenset[str]:
5353 @property
5454 def lib_imports (self ) -> frozenset [str ]:
5555 return frozenset (
56- # module.split(".", 1)[0]
57- module
58- for module in self .__imports
59- if not module .startswith ("test." )
56+ module for module in self .__imports if not module .startswith ("test." )
6057 )
6158
6259 def visit_Import (self , node ):
@@ -119,7 +116,7 @@ def visit_Call(self, node) -> None:
119116 self .__imports .add (f"test.{ target } " )
120117
121118
122- def parse_test_imports (content : str ) -> set [str ]:
119+ def parse_test_imports (content : str ) -> frozenset [str ]:
123120 """Parse test file content and extract test package dependencies."""
124121 if not (tree := safe_parse_ast (content )):
125122 return set ()
@@ -129,7 +126,7 @@ def parse_test_imports(content: str) -> set[str]:
129126 return visitor .test_imports
130127
131128
132- def parse_lib_imports (content : str ) -> set [str ]:
129+ def parse_lib_imports (content : str ) -> frozenset [str ]:
133130 """Parse library file and extract all imported module names."""
134131 if not (tree := safe_parse_ast (content )):
135132 return set ()
@@ -147,8 +144,7 @@ def parse_lib_imports(content: str) -> set[str]:
147144def filter_rustpython_todo (content : str ) -> str :
148145 """Remove lines containing RustPython TODO markers."""
149146 lines = content .splitlines (keepends = True )
150- filtered = [line for line in lines if TODO_MARKER not in line ]
151- return "" .join (filtered )
147+ return "" .join (line for line in lines if TODO_MARKER not in line )
152148
153149
154150def count_rustpython_todo (content : str ) -> int :
@@ -342,7 +338,7 @@ def clear_import_graph_caches() -> None:
342338 },
343339 "codecs" : {
344340 "test" : [
345- "test_codecs .py" ,
341+ "test_charmapcodec .py" ,
346342 "test_codeccallbacks.py" ,
347343 "test_codecencodings_cn.py" ,
348344 "test_codecencodings_hk.py" ,
@@ -355,8 +351,9 @@ def clear_import_graph_caches() -> None:
355351 "test_codecmaps_jp.py" ,
356352 "test_codecmaps_kr.py" ,
357353 "test_codecmaps_tw.py" ,
358- "test_charmapcodec .py" ,
354+ "test_codecs .py" ,
359355 "test_multibytecodec.py" ,
356+ "testcodec.py" ,
360357 ],
361358 },
362359 # Non-pattern hard_deps (can't be auto-detected)
@@ -423,6 +420,7 @@ def clear_import_graph_caches() -> None:
423420 "test_multiprocessing_forkserver" ,
424421 "test_multiprocessing_spawn" ,
425422 "test_multiprocessing_main_handling.py" ,
423+ "_test_multiprocessing.py" ,
426424 ],
427425 },
428426 "urllib" : {
@@ -745,12 +743,9 @@ def resolve_hard_dep_parent(name: str, cpython_prefix: str) -> str | None:
745743 # Auto-detect _py{module} or _py_{module} patterns
746744 # Only if the parent module actually exists
747745 if name .startswith ("_py" ):
748- if name .startswith ("_py_" ):
749- # _py_abc -> abc
750- parent = name [4 :]
751- else :
752- # _pydatetime -> datetime
753- parent = name [3 :]
746+ # _py_abc -> abc
747+ # _pydatetime -> datetime
748+ parent = name .removeprefix ("_py_" ).removeprefix ("_py" )
754749
755750 # Verify the parent module exists
756751 lib_dir = pathlib .Path (cpython_prefix ) / "Lib"
@@ -781,7 +776,7 @@ def resolve_test_to_lib(test_name: str) -> str | None:
781776 tests = dep_info .get ("test" , [])
782777 for test_path in tests :
783778 # test_path is like "test_urllib2.py" or "test_multiprocessing_fork"
784- path_stem = test_path [: - 3 ] if test_path . endswith (".py" ) else test_path
779+ path_stem = test_path . removesuffix (".py" )
785780 if path_stem == test_name :
786781 return lib_name
787782
0 commit comments