mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[BE][Easy] enable postponed annotations in tools (#129375)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129375 Approved by: https://github.com/malfet
This commit is contained in:
committed by
PyTorch MergeBot
parent
58f346c874
commit
8a67daf283
@ -1,16 +1,18 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
|
||||
import time
|
||||
import urllib.parse
|
||||
from typing import Any, Callable, cast, Dict, List, Optional, Set
|
||||
from typing import Any, Callable, cast, Dict, List
|
||||
from urllib.error import HTTPError
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
from tools.stats.upload_stats_lib import upload_to_s3
|
||||
|
||||
|
||||
FILTER_OUT_USERS = {
|
||||
"pytorchmergebot",
|
||||
"facebook-github-bot",
|
||||
@ -23,9 +25,9 @@ FILTER_OUT_USERS = {
|
||||
|
||||
def _fetch_url(
|
||||
url: str,
|
||||
headers: Dict[str, str],
|
||||
data: Optional[Dict[str, Any]] = None,
|
||||
method: Optional[str] = None,
|
||||
headers: dict[str, str],
|
||||
data: dict[str, Any] | None = None,
|
||||
method: str | None = None,
|
||||
reader: Callable[[Any], Any] = lambda x: x.read(),
|
||||
) -> Any:
|
||||
token = os.environ.get("GITHUB_TOKEN")
|
||||
@ -49,9 +51,9 @@ def _fetch_url(
|
||||
|
||||
def fetch_json(
|
||||
url: str,
|
||||
params: Optional[Dict[str, Any]] = None,
|
||||
data: Optional[Dict[str, Any]] = None,
|
||||
) -> List[Dict[str, Any]]:
|
||||
params: dict[str, Any] | None = None,
|
||||
data: dict[str, Any] | None = None,
|
||||
) -> list[dict[str, Any]]:
|
||||
headers = {"Accept": "application/vnd.github.v3+json"}
|
||||
if params is not None and len(params) > 0:
|
||||
url += "?" + "&".join(
|
||||
@ -65,16 +67,16 @@ def fetch_json(
|
||||
|
||||
def get_external_pr_data(
|
||||
start_date: datetime.date, end_date: datetime.date, period_length: int = 1
|
||||
) -> List[Dict[str, Any]]:
|
||||
) -> list[dict[str, Any]]:
|
||||
pr_info = []
|
||||
period_begin_date = start_date
|
||||
|
||||
pr_count = 0
|
||||
users: Set[str] = set()
|
||||
users: set[str] = set()
|
||||
while period_begin_date < end_date:
|
||||
period_end_date = period_begin_date + datetime.timedelta(days=period_length - 1)
|
||||
page = 1
|
||||
responses: List[Dict[str, Any]] = []
|
||||
responses: list[dict[str, Any]] = []
|
||||
while len(responses) > 0 or page == 1:
|
||||
response = cast(
|
||||
Dict[str, Any],
|
||||
|
||||
Reference in New Issue
Block a user