@@ -604,15 +604,13 @@ def get_runtime_object_for_stub(
604604
605605def add_docstrings_to_stub (
606606 module_name : str ,
607+ path : Path ,
607608 context : typeshed_client .SearchContext ,
608609 blacklisted_objects : frozenset [str ],
609610) -> None :
610611 """Add docstrings to a stub module and all functions/classes in it."""
611612
612613 print (f"Processing { module_name } ... " , flush = True )
613- path = typeshed_client .get_stub_file (module_name , search_context = context )
614- if path is None :
615- raise ValueError (f"Could not find stub for { module_name } " )
616614 try :
617615 # Redirect stdout when importing modules to avoid noisy output from modules like `this`
618616 with contextlib .redirect_stdout (io .StringIO ()):
@@ -900,6 +898,9 @@ def _main() -> None:
900898 context = typeshed_client .get_search_context (
901899 typeshed = stdlib_path , search_path = package_paths , version = sys .version_info [:2 ]
902900 )
901+
902+ codemodded_stubs = 0
903+
903904 for module , path in typeshed_client .get_all_stub_files (context ):
904905 if stdlib_path is not None and path .is_relative_to (stdlib_path ):
905906 if any (
@@ -909,11 +910,20 @@ def _main() -> None:
909910 log (f"Skipping { module } : blacklisted module" )
910911 continue
911912 else :
912- add_docstrings_to_stub (module , context , stdlib_blacklist )
913+ add_docstrings_to_stub (module , path , context , stdlib_blacklist )
913914 elif any (path .is_relative_to (p ) for p in package_paths ):
914- add_docstrings_to_stub (module , context , combined_blacklist )
915- m = "\n --- Successfully completed the codemod ---"
916- print (colored (m , "green" ))
915+ add_docstrings_to_stub (module , path , context , combined_blacklist )
916+ else :
917+ continue
918+ codemodded_stubs += 1
919+
920+ if codemodded_stubs == 0 :
921+ m = "\n --- WARNING: Didn't find any stubs to codemod for the passed packages ---"
922+ print (colored (m , "red" ))
923+ else :
924+ m = "\n --- Successfully completed the codemod ---"
925+ print (colored (m , "green" ))
926+
917927 sys .exit (0 )
918928
919929
0 commit comments