Revert "[BE][Easy] enable postponed annotations in tools (#129375)"

This reverts commit 59eb2897f1745f513edb6c63065ffad481c4c8d0.

Reverted https://github.com/pytorch/pytorch/pull/129375 on behalf of https://github.com/huydhn due to Sorry for reverting your change but I need to revert to cleanly revert https://github.com/pytorch/pytorch/pull/129374, please do a rebase and reland this ([comment](https://github.com/pytorch/pytorch/pull/129375#issuecomment-2197800541))
This commit is contained in:
PyTorch MergeBot
2024-06-29 00:44:25 +00:00
parent 6063bb9d45
commit a32ce5ce34
123 changed files with 1052 additions and 1275 deletions

View File

@ -1,10 +1,10 @@
"""GitHub Utilities"""
from __future__ import annotations
import json
import os
from typing import Any, Callable, cast, Dict
from typing import Any, Callable, cast, Dict, Optional, Tuple
from urllib.error import HTTPError
from urllib.parse import quote
from urllib.request import Request, urlopen
@ -13,11 +13,11 @@ from urllib.request import Request, urlopen
def gh_fetch_url_and_headers(
url: str,
*,
headers: dict[str, str] | None = None,
data: dict[str, Any] | None = None,
method: str | None = None,
headers: Optional[Dict[str, str]] = None,
data: Optional[Dict[str, Any]] = None,
method: Optional[str] = None,
reader: Callable[[Any], Any] = lambda x: x.read(),
) -> tuple[Any, Any]:
) -> Tuple[Any, Any]:
if headers is None:
headers = {}
token = os.environ.get("GITHUB_TOKEN")
@ -44,9 +44,9 @@ def gh_fetch_url_and_headers(
def gh_fetch_url(
url: str,
*,
headers: dict[str, str] | None = None,
data: dict[str, Any] | None = None,
method: str | None = None,
headers: Optional[Dict[str, str]] = None,
data: Optional[Dict[str, Any]] = None,
method: Optional[str] = None,
reader: Callable[[Any], Any] = lambda x: x.read(),
) -> Any:
return gh_fetch_url_and_headers(
@ -56,8 +56,8 @@ def gh_fetch_url(
def _gh_fetch_json_any(
url: str,
params: dict[str, Any] | None = None,
data: dict[str, Any] | None = None,
params: Optional[Dict[str, Any]] = None,
data: Optional[Dict[str, Any]] = None,
) -> Any:
headers = {"Accept": "application/vnd.github.v3+json"}
if params is not None and len(params) > 0:
@ -69,13 +69,13 @@ def _gh_fetch_json_any(
def gh_fetch_json_dict(
url: str,
params: dict[str, Any] | None = None,
data: dict[str, Any] | None = None,
) -> dict[str, Any]:
params: Optional[Dict[str, Any]] = None,
data: Optional[Dict[str, Any]] = None,
) -> Dict[str, Any]:
return cast(Dict[str, Any], _gh_fetch_json_any(url, params, data))
def gh_fetch_commit(org: str, repo: str, sha: str) -> dict[str, Any]:
def gh_fetch_commit(org: str, repo: str, sha: str) -> Dict[str, Any]:
return gh_fetch_json_dict(
f"https://api.github.com/repos/{org}/{repo}/commits/{sha}"
)