Try dropping Torch from typeshed_internal (#69926)

Summary:
Removes the internal typeshed for PyTorch and replaces it with PyTorch's own type annotations.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/69926

Generated files are in P471601595, P471601643, P471601662

Based on an example in D26410012

Test Plan: Sandcastle

Reviewed By: malfet, pradeep90

Differential Revision: D32292834

fbshipit-source-id: 5223f514cbdccd02c08ef0a027a48d92cdebed2c
This commit is contained in:
Richard Barnes 2021-12-17 14:06:40 -08:00 committed by Facebook GitHub Bot
parent e35bf56461
commit 70ed4f3ffc
2 changed files with 9 additions and 8 deletions

View File

@ -1,11 +1,11 @@
import re
import contextlib
import functools
import hashlib
import os
import re
import textwrap
from typing import Tuple, List, Iterable, Iterator, Callable, Sequence, TypeVar, Optional, Dict, Any, Union, Set, NoReturn
from enum import Enum
import contextlib
import textwrap
import hashlib
import functools
from tools.codegen.code_template import CodeTemplate
@ -139,6 +139,8 @@ class FileManager:
except IOError:
old_contents = None
if contents != old_contents:
# Create output directory if it doesn't exist
os.makedirs(os.path.dirname(filename), exist_ok=True)
with open(filename, 'w') as f:
f.write(contents)

View File

@ -1,8 +1,7 @@
import argparse
import collections
from pprint import pformat
import argparse
from tools.codegen.model import Variant
from tools.codegen.api.python import (PythonSignatureGroup,
PythonSignatureNativeFunctionPair)
@ -10,7 +9,7 @@ from tools.codegen.gen import parse_native_yaml
from tools.codegen.utils import FileManager
from typing import Sequence, List, Dict
from ..autograd.gen_python_functions import should_generate_py_binding, load_signatures, group_overloads
from tools.autograd.gen_python_functions import should_generate_py_binding, load_signatures, group_overloads
"""
This module implements generation of type stubs for PyTorch,