mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[3/N] Apply py39 ruff fixes (#142115)
Fixes #ISSUE_NUMBER Pull Request resolved: https://github.com/pytorch/pytorch/pull/142115 Approved by: https://github.com/ezyang
This commit is contained in:
@ -7,7 +7,7 @@ import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import urllib.request
|
||||
from typing import cast, List, NoReturn, Optional
|
||||
from typing import cast, NoReturn, Optional
|
||||
|
||||
|
||||
def parse_arguments() -> argparse.Namespace:
|
||||
@ -74,7 +74,7 @@ def get_pytorch_path() -> str:
|
||||
try:
|
||||
import torch
|
||||
|
||||
torch_paths: List[str] = cast(List[str], torch.__path__)
|
||||
torch_paths: list[str] = cast(list[str], torch.__path__)
|
||||
torch_path: str = torch_paths[0]
|
||||
parent_path: str = os.path.dirname(torch_path)
|
||||
print(f"PyTorch is installed at: {torch_path}")
|
||||
@ -114,9 +114,10 @@ def download_patch(pr_number: int, repo_url: str, download_dir: str) -> str:
|
||||
patch_file = os.path.join(download_dir, f"pr-{pr_number}.patch")
|
||||
print(f"Downloading PR #{pr_number} patch from {patch_url}...")
|
||||
try:
|
||||
with urllib.request.urlopen(patch_url) as response, open(
|
||||
patch_file, "wb"
|
||||
) as out_file:
|
||||
with (
|
||||
urllib.request.urlopen(patch_url) as response,
|
||||
open(patch_file, "wb") as out_file,
|
||||
):
|
||||
shutil.copyfileobj(response, out_file)
|
||||
if not os.path.isfile(patch_file):
|
||||
print(f"Failed to download patch for PR #{pr_number}")
|
||||
|
Reference in New Issue
Block a user