@@ -241,7 +241,7 @@ async def get_github_repo_info(session: aiohttp.ClientSession, pypi_info: PypiIn
241241 github_tags_info_url = f"https://api.github.com/repos/{ url_path } /tags"
242242 async with session .get (github_tags_info_url , headers = get_github_api_headers ()) as response :
243243 if response .status == 200 :
244- tags = await response .json ()
244+ tags : list [ dict [ str , Any ]] = await response .json ()
245245 assert isinstance (tags , list )
246246 return GithubInfo (repo_path = url_path , tags = tags )
247247 return None
@@ -266,7 +266,7 @@ async def get_diff_info(
266266 if github_info is None :
267267 return None
268268
269- versions_to_tags = {}
269+ versions_to_tags : dict [ packaging . version . Version , str ] = {}
270270 for tag in github_info .tags :
271271 tag_name = tag ["name" ]
272272 # Some packages in typeshed (e.g. emoji) have tag names
@@ -378,7 +378,7 @@ def describe_typeshed_files_modified(self) -> str:
378378 return analysis
379379
380380 def __str__ (self ) -> str :
381- data_points = []
381+ data_points : list [ str ] = []
382382 if self .runtime_definitely_has_consistent_directory_structure_with_typeshed :
383383 data_points += [
384384 self .describe_public_files_added (),
@@ -398,7 +398,7 @@ async def analyze_diff(
398398 url = f"https://api.github.com/repos/{ github_repo_path } /compare/{ old_tag } ...{ new_tag } "
399399 async with session .get (url , headers = get_github_api_headers ()) as response :
400400 response .raise_for_status ()
401- json_resp = await response .json ()
401+ json_resp : dict [ str , list [ FileInfo ]] = await response .json ()
402402 assert isinstance (json_resp , dict )
403403 # https://docs.github.com/en/rest/commits/commits#compare-two-commits
404404 py_files : list [FileInfo ] = [file for file in json_resp ["files" ] if Path (file ["filename" ]).suffix == ".py" ]
@@ -581,7 +581,11 @@ def get_update_pr_body(update: Update, metadata: dict[str, Any]) -> str:
581581 if update .diff_analysis is not None :
582582 body += f"\n \n { update .diff_analysis } "
583583
584- stubtest_will_run = not metadata .get ("tool" , {}).get ("stubtest" , {}).get ("skip" , False )
584+ # Loss of type due to infered [dict[Unknown, Unknown]]
585+ # scripts/stubsabot.py can't import tests/parse_metadata
586+ stubtest_will_run = (
587+ not metadata .get ("tool" , {}).get ("stubtest" , {}).get ("skip" , False ) # pyright: ignore[reportUnknownMemberType]
588+ )
585589 if stubtest_will_run :
586590 body += textwrap .dedent (
587591 """
@@ -611,10 +615,13 @@ async def suggest_typeshed_update(update: Update, session: aiohttp.ClientSession
611615 branch_name = f"{ BRANCH_PREFIX } /{ normalize (update .distribution )} "
612616 subprocess .check_call (["git" , "checkout" , "-B" , branch_name , "origin/main" ])
613617 with open (update .stub_path / "METADATA.toml" , "rb" ) as f :
614- meta = tomlkit .load (f )
618+ # tomlkit.load has partially unknown IO type
619+ # https://github.com/sdispater/tomlkit/pull/272
620+ meta = tomlkit .load (f ) # pyright: ignore[reportUnknownMemberType]
615621 meta ["version" ] = update .new_version_spec
616622 with open (update .stub_path / "METADATA.toml" , "w" , encoding = "UTF-8" ) as f :
617- tomlkit .dump (meta , f )
623+ # tomlkit.dump has partially unknown IO type
624+ tomlkit .dump (meta , f ) # pyright: ignore[reportUnknownMemberType]
618625 body = get_update_pr_body (update , meta )
619626 subprocess .check_call (["git" , "commit" , "--all" , "-m" , f"{ title } \n \n { body } " ])
620627 if action_level <= ActionLevel .local :
@@ -637,12 +644,15 @@ async def suggest_typeshed_obsolete(obsolete: Obsolete, session: aiohttp.ClientS
637644 branch_name = f"{ BRANCH_PREFIX } /{ normalize (obsolete .distribution )} "
638645 subprocess .check_call (["git" , "checkout" , "-B" , branch_name , "origin/main" ])
639646 with open (obsolete .stub_path / "METADATA.toml" , "rb" ) as f :
640- meta = tomlkit .load (f )
647+ # tomlkit.load has partially unknown IO type
648+ # https://github.com/sdispater/tomlkit/pull/272
649+ meta = tomlkit .load (f ) # pyright: ignore[reportUnknownMemberType]
641650 obs_string = tomlkit .string (obsolete .obsolete_since_version )
642651 obs_string .comment (f"Released on { obsolete .obsolete_since_date .date ().isoformat ()} " )
643652 meta ["obsolete_since" ] = obs_string
644653 with open (obsolete .stub_path / "METADATA.toml" , "w" , encoding = "UTF-8" ) as f :
645- tomlkit .dump (meta , f )
654+ # tomlkit.dump has partially unknown Mapping type
655+ tomlkit .dump (meta , f ) # pyright: ignore[reportUnknownMemberType]
646656 body = "\n " .join (f"{ k } : { v } " for k , v in obsolete .links .items ())
647657 subprocess .check_call (["git" , "commit" , "--all" , "-m" , f"{ title } \n \n { body } " ])
648658 if action_level <= ActionLevel .local :
@@ -727,7 +737,8 @@ async def main() -> None:
727737 if isinstance (update , Update ):
728738 await suggest_typeshed_update (update , session , action_level = args .action_level )
729739 continue
730- if isinstance (update , Obsolete ):
740+ # Redundant, but keeping for extra runtime validation
741+ if isinstance (update , Obsolete ): # pyright: ignore[reportUnnecessaryIsInstance]
731742 await suggest_typeshed_obsolete (update , session , action_level = args .action_level )
732743 continue
733744 except RemoteConflict as e :
0 commit comments