Skip to content

Commit e876de4

Browse files
authored
Bump typeshed_client pin (#19)
1 parent 6fd3f7a commit e876de4

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

add_docstrings.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -604,15 +604,13 @@ def get_runtime_object_for_stub(
604604

605605
def 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

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies = [
1515
"rich-argparse>=1.7.0",
1616
"termcolor>=3.1.0",
1717
"tomli>=2.2.1",
18-
"typeshed-client @ git+https://github.com/JelleZijlstra/typeshed_client@dc933baf47b3df4bbaf4e3f2d6a1fe238e6c7c68",
18+
"typeshed-client @ git+https://github.com/JelleZijlstra/typeshed_client@b79099fe36db977abbb1f3d6466a7657ae3edcfd",
1919
# So that we can add docs for `typing_extensions` APIs:
2020
"typing_extensions",
2121
# for dynamically installing typeshed packages

uv.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)