neulab/docprompting-conala huggingface dataset:
typing.Literal  
A type that can be used to indicate to type checkers that the corresponding variable or function parameter has a value equivalent to the provided literal (or one of several literals). For example: def validate_simple(data: Any) -> Literal[True]:  # always returns True
    ...

MODE = Literal['r', 'rb', 'w', 'wb']
def open_helper(file: str, mode: MODE) -> str:
    ...

open_helper('/some/path', 'r')  # Passes type check
open_helper('/other/path', 'typo')  # Error in type checker
 Literal[...] cannot be subclassed. At runtime, an arbitrary value is allowed as type argument to Literal[...], but type checkers may impose restrictions. See PEP 586 for more details about literal types.  New in version 3.8.   Changed in version 3.9.1: Literal now de-duplicates parameters. Equality comparison of Literal objects are no longer order dependent. Literal objects will now raise a TypeError exception during equality comparisons if one of their parameters are not immutable.
class typing.Mapping(Sized, Collection[KT], Generic[VT_co])  
A generic version of collections.abc.Mapping. This type can be used as follows: def get_position_in_index(word_list: Mapping[str, int], word: str) -> int:
    return word_list[word]
  Deprecated since version 3.9: collections.abc.Mapping now supports []. See PEP 585 and Generic Alias Type.
class typing.MappingView(Sized, Iterable[T_co])  
A generic version of collections.abc.MappingView.  Deprecated since version 3.9: collections.abc.MappingView now supports []. See PEP 585 and Generic Alias Type.
class typing.Pattern  
class typing.Match  
These type aliases correspond to the return types from re.compile() and re.match(). These types (and the corresponding functions) are generic in AnyStr and can be made specific by writing Pattern[str], Pattern[bytes], Match[str], or Match[bytes]. These types are also in the typing.re namespace.  Deprecated since version 3.9: Classes Pattern and Match from re now support []. See PEP 585 and Generic Alias Type.
class typing.MutableMapping(Mapping[KT, VT])  
A generic version of collections.abc.MutableMapping.  Deprecated since version 3.9: collections.abc.MutableMapping now supports []. See PEP 585 and Generic Alias Type.
class typing.MutableSequence(Sequence[T])  
A generic version of collections.abc.MutableSequence.  Deprecated since version 3.9: collections.abc.MutableSequence now supports []. See PEP 585 and Generic Alias Type.
class typing.MutableSet(AbstractSet[T])  
A generic version of collections.abc.MutableSet.  Deprecated since version 3.9: collections.abc.MutableSet now supports []. See PEP 585 and Generic Alias Type.
class typing.NamedTuple  
Typed version of collections.namedtuple(). Usage: class Employee(NamedTuple):
    name: str
    id: int
 This is equivalent to: Employee = collections.namedtuple('Employee', ['name', 'id'])
 To give a field a default value, you can assign to it in the class body: class Employee(NamedTuple):
    name: str
    id: int = 3

employee = Employee('Guido')
assert employee.id == 3
 Fields with a default value must come after any fields without a default. The resulting class has an extra attribute __annotations__ giving a dict that maps the field names to the field types. (The field names are in the _fields attribute and the default values are in the _field_defaults attribute both of which are part of the namedtuple API.) NamedTuple subclasses can also have docstrings and methods: class Employee(NamedTuple):
    """Represents an employee."""
    name: str
    id: int = 3

    def __repr__(self) -> str:
        return f'<Employee {self.name}, id={self.id}>'
 Backward-compatible usage: Employee = NamedTuple('Employee', [('name', str), ('id', int)])
  Changed in version 3.6: Added support for PEP 526 variable annotation syntax.   Changed in version 3.6.1: Added support for default values, methods, and docstrings.   Changed in version 3.8: The _field_types and __annotations__ attributes are now regular dictionaries instead of instances of OrderedDict.   Changed in version 3.9: Removed the _field_types attribute in favor of the more standard __annotations__ attribute which has the same information.
typing.NewType(name, tp)  
A helper function to indicate a distinct type to a typechecker, see NewType. At runtime it returns a function that returns its argument. Usage: UserId = NewType('UserId', int)
first_user = UserId(1)
  New in version 3.5.2.
typing.NoReturn  
Special type indicating that a function never returns. For example: from typing import NoReturn

def stop() -> NoReturn:
    raise RuntimeError('no way')
  New in version 3.5.4.   New in version 3.6.2.
@typing.no_type_check  
Decorator to indicate that annotations are not type hints. This works as class or function decorator. With a class, it applies recursively to all methods defined in that class (but not to methods defined in its superclasses or subclasses). This mutates the function(s) in place.
@typing.no_type_check_decorator  
Decorator to give another decorator the no_type_check() effect. This wraps the decorator with something that wraps the decorated function in no_type_check().
typing.Optional  
Optional type. Optional[X] is equivalent to Union[X, None]. Note that this is not the same concept as an optional argument, which is one that has a default. An optional argument with a default does not require the Optional qualifier on its type annotation just because it is optional. For example: def foo(arg: int = 0) -> None:
    ...
 On the other hand, if an explicit value of None is allowed, the use of Optional is appropriate, whether the argument is optional or not. For example: def foo(arg: Optional[int] = None) -> None:
    ...
class typing.OrderedDict(collections.OrderedDict, MutableMapping[KT, VT])  
A generic version of collections.OrderedDict.  New in version 3.7.2.   Deprecated since version 3.9: collections.OrderedDict now supports []. See PEP 585 and Generic Alias Type.
@typing.overload  
The @overload decorator allows describing functions and methods that support multiple different combinations of argument types. A series of @overload-decorated definitions must be followed by exactly one non-@overload-decorated definition (for the same function/method). The @overload-decorated definitions are for the benefit of the type checker only, since they will be overwritten by the non-@overload-decorated definition, while the latter is used at runtime but should be ignored by a type checker. At runtime, calling a @overload-decorated function directly will raise NotImplementedError. An example of overload that gives a more precise type than can be expressed using a union or a type variable: @overload
def process(response: None) -> None:
    ...
@overload
def process(response: int) -> tuple[int, str]:
    ...
@overload
def process(response: bytes) -> str:
    ...
def process(response):
    <actual implementation>
 See PEP 484 for details and comparison with other typing semantics.
class typing.Protocol(Generic)  
Base class for protocol classes. Protocol classes are defined like this: class Proto(Protocol):
    def meth(self) -> int:
        ...
 Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing), for example: class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check
 See PEP 544 for details. Protocol classes decorated with runtime_checkable() (described later) act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, for example: class GenProto(Protocol[T]):
    def meth(self) -> T:
        ...
  New in version 3.8.
class typing.Reversible(Iterable[T_co])  
A generic version of collections.abc.Reversible.  Deprecated since version 3.9: collections.abc.Reversible now supports []. See PEP 585 and Generic Alias Type.
@typing.runtime_checkable  
Mark a protocol class as a runtime protocol. Such a protocol can be used with isinstance() and issubclass(). This raises TypeError when applied to a non-protocol class. This allows a simple-minded structural check, very similar to “one trick ponies” in collections.abc such as Iterable. For example: @runtime_checkable
class Closable(Protocol):
    def close(self): ...

assert isinstance(open('/some/file'), Closable)
  Note runtime_checkable() will check only the presence of the required methods, not their type signatures! For example, builtins.complex implements __float__(), therefore it passes an issubclass() check against SupportsFloat. However, the complex.__float__ method exists only to raise a TypeError with a more informative message.   New in version 3.8.
class typing.Sequence(Reversible[T_co], Collection[T_co])  
A generic version of collections.abc.Sequence.  Deprecated since version 3.9: collections.abc.Sequence now supports []. See PEP 585 and Generic Alias Type.
class typing.Set(set, MutableSet[T])  
A generic version of builtins.set. Useful for annotating return types. To annotate arguments it is preferred to use an abstract collection type such as AbstractSet.  Deprecated since version 3.9: builtins.set now supports []. See PEP 585 and Generic Alias Type.
class typing.SupportsAbs  
An ABC with one abstract method __abs__ that is covariant in its return type.
class typing.SupportsIndex  
An ABC with one abstract method __index__.  New in version 3.8.
class typing.SupportsRound  
An ABC with one abstract method __round__ that is covariant in its return type.
class typing.Text  
Text is an alias for str. It is provided to supply a forward compatible path for Python 2 code: in Python 2, Text is an alias for unicode. Use Text to indicate that a value must contain a unicode string in a manner that is compatible with both Python 2 and Python 3: def add_unicode_checkmark(text: Text) -> Text:
    return text + u' \u2713'
  New in version 3.5.2.
typing.Tuple  
Tuple type; Tuple[X, Y] is the type of a tuple of two items with the first item of type X and the second of type Y. The type of the empty tuple can be written as Tuple[()]. Example: Tuple[T1, T2] is a tuple of two elements corresponding to type variables T1 and T2. Tuple[int, float, str] is a tuple of an int, a float and a string. To specify a variable-length tuple of homogeneous type, use literal ellipsis, e.g. Tuple[int, ...]. A plain Tuple is equivalent to Tuple[Any, ...], and in turn to tuple.  Deprecated since version 3.9: builtins.tuple now supports []. See PEP 585 and Generic Alias Type.
class typing.Type(Generic[CT_co])  
A variable annotated with C may accept a value of type C. In contrast, a variable annotated with Type[C] may accept values that are classes themselves – specifically, it will accept the class object of C. For example: a = 3         # Has type 'int'
b = int       # Has type 'Type[int]'
c = type(a)   # Also has type 'Type[int]'
 Note that Type[C] is covariant: class User: ...
class BasicUser(User): ...
class ProUser(User): ...
class TeamUser(User): ...

# Accepts User, BasicUser, ProUser, TeamUser, ...
def make_new_user(user_class: Type[User]) -> User:
    # ...
    return user_class()
 The fact that Type[C] is covariant implies that all subclasses of C should implement the same constructor signature and class method signatures as C. The type checker should flag violations of this, but should also allow constructor calls in subclasses that match the constructor calls in the indicated base class. How the type checker is required to handle this particular case may change in future revisions of PEP 484. The only legal parameters for Type are classes, Any, type variables, and unions of any of these types. For example: def new_non_team_user(user_class: Type[Union[BasicUser, ProUser]]): ...
 Type[Any] is equivalent to Type which in turn is equivalent to type, which is the root of Python’s metaclass hierarchy.  New in version 3.5.2.   Deprecated since version 3.9: builtins.type now supports []. See PEP 585 and Generic Alias Type.
class typing.TypedDict(dict)  
Special construct to add type hints to a dictionary. At runtime it is a plain dict. TypedDict declares a dictionary type that expects all of its instances to have a certain set of keys, where each key is associated with a value of a consistent type. This expectation is not checked at runtime but is only enforced by type checkers. Usage: class Point2D(TypedDict):
    x: int
    y: int
    label: str

a: Point2D = {'x': 1, 'y': 2, 'label': 'good'}  # OK
b: Point2D = {'z': 3, 'label': 'bad'}           # Fails type check

assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first')
 The type info for introspection can be accessed via Point2D.__annotations__ and Point2D.__total__. To allow using this feature with older versions of Python that do not support PEP 526, TypedDict supports two additional equivalent syntactic forms: Point2D = TypedDict('Point2D', x=int, y=int, label=str)
Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})
 By default, all keys must be present in a TypedDict. It is possible to override this by specifying totality. Usage: class point2D(TypedDict, total=False):
    x: int
    y: int
 This means that a point2D TypedDict can have any of the keys omitted. A type checker is only expected to support a literal False or True as the value of the total argument. True is the default, and makes all items defined in the class body be required. See PEP 589 for more examples and detailed rules of using TypedDict.  New in version 3.8.
class typing.TypeVar  
Type variable. Usage: T = TypeVar('T')  # Can be anything
A = TypeVar('A', str, bytes)  # Must be str or bytes
 Type variables exist primarily for the benefit of static type checkers. They serve as the parameters for generic types as well as for generic function definitions. See Generic for more information on generic types. Generic functions work as follows: def repeat(x: T, n: int) -> Sequence[T]:
    """Return a list containing n references to x."""
    return [x]*n

def longest(x: A, y: A) -> A:
    """Return the longest of two strings."""
    return x if len(x) >= len(y) else y
 The latter example’s signature is essentially the overloading of (str, str) -> str and (bytes, bytes) -> bytes. Also note that if the arguments are instances of some subclass of str, the return type is still plain str. At runtime, isinstance(x, T) will raise TypeError. In general, isinstance() and issubclass() should not be used with types. Type variables may be marked covariant or contravariant by passing covariant=True or contravariant=True. See PEP 484 for more details. By default type variables are invariant. Alternatively, a type variable may specify an upper bound using bound=<type>. This means that an actual type substituted (explicitly or implicitly) for the type variable must be a subclass of the boundary type, see PEP 484.
typing.TYPE_CHECKING  
A special constant that is assumed to be True by 3rd party static type checkers. It is False at runtime. Usage: if TYPE_CHECKING:
    import expensive_mod

def fun(arg: 'expensive_mod.SomeType') -> None:
    local_var: expensive_mod.AnotherType = other_fun()
 The first type annotation must be enclosed in quotes, making it a “forward reference”, to hide the expensive_mod reference from the interpreter runtime. Type annotations for local variables are not evaluated, so the second annotation does not need to be enclosed in quotes.  Note If from __future__ import annotations is used in Python 3.7 or later, annotations are not evaluated at function definition time. Instead, they are stored as strings in __annotations__, This makes it unnecessary to use quotes around the annotation. (see PEP 563).   New in version 3.5.2.
@typing.type_check_only  
Decorator to mark a class or function to be unavailable at runtime. This decorator is itself not available at runtime. It is mainly intended to mark classes that are defined in type stub files if an implementation returns an instance of a private class: @type_check_only
class Response:  # private or not available at runtime
    code: int
    def get_header(self, name: str) -> str: ...

def fetch_response() -> Response: ...
 Note that returning instances of private classes is not recommended. It is usually preferable to make such classes public.
typing.Union  
Union type; Union[X, Y] means either X or Y. To define a union, use e.g. Union[int, str]. Details:  The arguments must be types and there must be at least one. 
Unions of unions are flattened, e.g.: Union[Union[int, str], float] == Union[int, str, float]
  
Unions of a single argument vanish, e.g.: Union[int] == int  # The constructor actually returns int
  
Redundant arguments are skipped, e.g.: Union[int, str, int] == Union[int, str]
  
When comparing unions, the argument order is ignored, e.g.: Union[int, str] == Union[str, int]
  You cannot subclass or instantiate a union. You cannot write Union[X][Y]. You can use Optional[X] as a shorthand for Union[X, None].   Changed in version 3.7: Don’t remove explicit subclasses from unions at runtime.
class typing.ValuesView(MappingView[VT_co])  
A generic version of collections.abc.ValuesView.  Deprecated since version 3.9: collections.abc.ValuesView now supports []. See PEP 585 and Generic Alias Type.
exception UnboundLocalError  
Raised when a reference is made to a local variable in a function or method, but no value has been bound to that variable. This is a subclass of NameError.
unicodedata.bidirectional(chr)  
Returns the bidirectional class assigned to the character chr as string. If no such value is defined, an empty string is returned.
unicodedata.category(chr)  
Returns the general category assigned to the character chr as string.
unicodedata.combining(chr)  
Returns the canonical combining class assigned to the character chr as integer. Returns 0 if no combining class is defined.
unicodedata.decimal(chr[, default])  
Returns the decimal value assigned to the character chr as integer. If no such value is defined, default is returned, or, if not given, ValueError is raised.
unicodedata.decomposition(chr)  
Returns the character decomposition mapping assigned to the character chr as string. An empty string is returned in case no such mapping is defined.
unicodedata.digit(chr[, default])  
Returns the digit value assigned to the character chr as integer. If no such value is defined, default is returned, or, if not given, ValueError is raised.
unicodedata.east_asian_width(chr)  
Returns the east asian width assigned to the character chr as string.
unicodedata.is_normalized(form, unistr)  
Return whether the Unicode string unistr is in the normal form form. Valid values for form are ‘NFC’, ‘NFKC’, ‘NFD’, and ‘NFKD’.  New in version 3.8.
unicodedata.lookup(name)  
Look up character by name. If a character with the given name is found, return the corresponding character. If not found, KeyError is raised.  Changed in version 3.3: Support for name aliases 1 and named sequences 2 has been added.
unicodedata.mirrored(chr)  
Returns the mirrored property assigned to the character chr as integer. Returns 1 if the character has been identified as a “mirrored” character in bidirectional text, 0 otherwise.
unicodedata.name(chr[, default])  
Returns the name assigned to the character chr as a string. If no name is defined, default is returned, or, if not given, ValueError is raised.
unicodedata.normalize(form, unistr)  
Return the normal form form for the Unicode string unistr. Valid values for form are ‘NFC’, ‘NFKC’, ‘NFD’, and ‘NFKD’. The Unicode standard defines various normalization forms of a Unicode string, based on the definition of canonical equivalence and compatibility equivalence. In Unicode, several characters can be expressed in various way. For example, the character U+00C7 (LATIN CAPITAL LETTER C WITH CEDILLA) can also be expressed as the sequence U+0043 (LATIN CAPITAL LETTER C) U+0327 (COMBINING CEDILLA). For each character, there are two normal forms: normal form C and normal form D. Normal form D (NFD) is also known as canonical decomposition, and translates each character into its decomposed form. Normal form C (NFC) first applies a canonical decomposition, then composes pre-combined characters again. In addition to these two forms, there are two additional normal forms based on compatibility equivalence. In Unicode, certain characters are supported which normally would be unified with other characters. For example, U+2160 (ROMAN NUMERAL ONE) is really the same thing as U+0049 (LATIN CAPITAL LETTER I). However, it is supported in Unicode for compatibility with existing character sets (e.g. gb2312). The normal form KD (NFKD) will apply the compatibility decomposition, i.e. replace all compatibility characters with their equivalents. The normal form KC (NFKC) first applies the compatibility decomposition, followed by the canonical composition. Even if two unicode strings are normalized and look the same to a human reader, if one has combining characters and the other doesn’t, they may not compare equal.
unicodedata.numeric(chr[, default])  
Returns the numeric value assigned to the character chr as float. If no such value is defined, default is returned, or, if not given, ValueError is raised.
unicodedata.ucd_3_2_0  
This is an object that has the same methods as the entire module, but uses the Unicode database version 3.2 instead, for applications that require this specific version of the Unicode database (such as IDNA).
unicodedata.unidata_version  
The version of the Unicode database used in this module.
exception UnicodeDecodeError  
Raised when a Unicode-related error occurs during decoding. It is a subclass of UnicodeError.
exception UnicodeEncodeError  
Raised when a Unicode-related error occurs during encoding. It is a subclass of UnicodeError.
exception UnicodeError  
Raised when a Unicode-related encoding or decoding error occurs. It is a subclass of ValueError. UnicodeError has attributes that describe the encoding or decoding error. For example, err.object[err.start:err.end] gives the particular invalid input that the codec failed on.  
encoding  
The name of the encoding that raised the error. 
  
reason  
A string describing the specific codec error. 
  
object  
The object the codec was attempting to encode or decode. 
  
start  
The first index of invalid data in object. 
  
end  
The index after the last invalid data in object.
exception UnicodeTranslateError  
Raised when a Unicode-related error occurs during translating. It is a subclass of UnicodeError.
unittest.addModuleCleanup(function, /, *args, **kwargs)  
Add a function to be called after tearDownModule() to cleanup resources used during the test class. Functions will be called in reverse order to the order they are added (LIFO). They are called with any arguments and keyword arguments passed into addModuleCleanup() when they are added. If setUpModule() fails, meaning that tearDownModule() is not called, then any cleanup functions added will still be called.  New in version 3.8.
unittest.defaultTestLoader  
Instance of the TestLoader class intended to be shared. If no customization of the TestLoader is needed, this instance can be used instead of repeatedly creating new instances.
unittest.doModuleCleanups()  
This function is called unconditionally after tearDownModule(), or after setUpModule() if setUpModule() raises an exception. It is responsible for calling all the cleanup functions added by addCleanupModule(). If you need cleanup functions to be called prior to tearDownModule() then you can call doModuleCleanups() yourself. doModuleCleanups() pops methods off the stack of cleanup functions one at a time, so it can be called at any time.  New in version 3.8.
@unittest.expectedFailure  
Mark the test as an expected failure or error. If the test fails or errors it will be considered a success. If the test passes, it will be considered a failure.
class unittest.FunctionTestCase(testFunc, setUp=None, tearDown=None, description=None)  
This class implements the portion of the TestCase interface which allows the test runner to drive the test, but does not provide the methods which test code can use to check and report errors. This is used to create test cases using legacy test code, allowing it to be integrated into a unittest-based test framework.