2016-10-30 09:46:26 +00:00
|
|
|
|
# SOME DESCRIPTIVE TITLE.
|
|
|
|
|
# Copyright (C) 2001-2016, Python Software Foundation
|
|
|
|
|
# This file is distributed under the same license as the Python package.
|
|
|
|
|
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
|
|
|
|
#
|
|
|
|
|
#, fuzzy
|
|
|
|
|
msgid ""
|
|
|
|
|
msgstr ""
|
|
|
|
|
"Project-Id-Version: Python 3.6\n"
|
|
|
|
|
"Report-Msgid-Bugs-To: \n"
|
2017-05-27 17:46:38 +00:00
|
|
|
|
"POT-Creation-Date: 2017-05-27 19:40+0200\n"
|
2016-10-30 09:46:26 +00:00
|
|
|
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
|
|
|
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
|
|
|
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
2017-05-23 22:40:56 +00:00
|
|
|
|
"Language: fr\n"
|
2016-10-30 09:46:26 +00:00
|
|
|
|
"MIME-Version: 1.0\n"
|
|
|
|
|
"Content-Type: text/plain; charset=UTF-8\n"
|
|
|
|
|
"Content-Transfer-Encoding: 8bit\n"
|
|
|
|
|
|
|
|
|
|
#: ../Doc/library/typing.rst:2
|
|
|
|
|
msgid ":mod:`typing` --- Support for type hints"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
|
|
|
|
#: ../Doc/library/typing.rst:9
|
|
|
|
|
msgid "**Source code:** :source:`Lib/typing.py`"
|
|
|
|
|
msgstr "**Code source :** :source:`Lib/typing.py`"
|
|
|
|
|
|
|
|
|
|
#: ../Doc/library/typing.rst:13
|
|
|
|
|
msgid ""
|
2017-04-02 20:14:06 +00:00
|
|
|
|
"The typing module has been included in the standard library on a :term:"
|
|
|
|
|
"`provisional basis <provisional api>`. New features might be added and API "
|
|
|
|
|
"may change even between minor releases if deemed necessary by the core "
|
|
|
|
|
"developers."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
|
|
|
|
#: ../Doc/library/typing.rst:20
|
|
|
|
|
msgid ""
|
2016-10-30 09:46:26 +00:00
|
|
|
|
"This module supports type hints as specified by :pep:`484` and :pep:`526`. "
|
2017-04-02 20:14:06 +00:00
|
|
|
|
"The most fundamental support consists of the types :data:`Any`, :data:"
|
2016-10-30 09:46:26 +00:00
|
|
|
|
"`Union`, :data:`Tuple`, :data:`Callable`, :class:`TypeVar`, and :class:"
|
|
|
|
|
"`Generic`. For full specification please see :pep:`484`. For a simplified "
|
|
|
|
|
"introduction to type hints see :pep:`483`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:27
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"The function below takes and returns a string and is annotated as follows::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:32
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"In the function ``greeting``, the argument ``name`` is expected to be of "
|
|
|
|
|
"type :class:`str` and the return type :class:`str`. Subtypes are accepted as "
|
|
|
|
|
"arguments."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:37
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Type aliases"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:39
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"A type alias is defined by assigning the type to the alias. In this example, "
|
|
|
|
|
"``Vector`` and ``List[float]`` will be treated as interchangeable synonyms::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:51
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Type aliases are useful for simplifying complex type signatures. For "
|
|
|
|
|
"example::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:69
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Note that ``None`` as a type hint is a special case and is replaced by "
|
|
|
|
|
"``type(None)``."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:75
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "NewType"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:77
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Use the :func:`NewType` helper function to create distinct types::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:84
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"The static type checker will treat the new type as if it were a subclass of "
|
|
|
|
|
"the original type. This is useful in helping catch logical errors::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:96
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"You may still perform all ``int`` operations on a variable of type "
|
|
|
|
|
"``UserId``, but the result will always be of type ``int``. This lets you "
|
|
|
|
|
"pass in a ``UserId`` wherever an ``int`` might be expected, but will prevent "
|
|
|
|
|
"you from accidentally creating a ``UserId`` in an invalid way::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:104
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Note that these checks are enforced only by the static type checker. At "
|
|
|
|
|
"runtime the statement ``Derived = NewType('Derived', Base)`` will make "
|
|
|
|
|
"``Derived`` a function that immediately returns whatever parameter you pass "
|
|
|
|
|
"it. That means the expression ``Derived(some_value)`` does not create a new "
|
|
|
|
|
"class or introduce any overhead beyond that of a regular function call."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:110
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"More precisely, the expression ``some_value is Derived(some_value)`` is "
|
|
|
|
|
"always true at runtime."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:113
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"This also means that it is not possible to create a subtype of ``Derived`` "
|
|
|
|
|
"since it is an identity function at runtime, not an actual type. Similarly, "
|
|
|
|
|
"it is not possible to create another :func:`NewType` based on a ``Derived`` "
|
|
|
|
|
"type::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:127
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "See :pep:`484` for more details."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:131
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Recall that the use of a type alias declares two types to be *equivalent* to "
|
|
|
|
|
"one another. Doing ``Alias = Original`` will make the static type checker "
|
|
|
|
|
"treat ``Alias`` as being *exactly equivalent* to ``Original`` in all cases. "
|
|
|
|
|
"This is useful when you want to simplify complex type signatures."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:136
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"In contrast, ``NewType`` declares one type to be a *subtype* of another. "
|
|
|
|
|
"Doing ``Derived = NewType('Derived', Original)`` will make the static type "
|
|
|
|
|
"checker treat ``Derived`` as a *subclass* of ``Original``, which means a "
|
|
|
|
|
"value of type ``Original`` cannot be used in places where a value of type "
|
|
|
|
|
"``Derived`` is expected. This is useful when you want to prevent logic "
|
|
|
|
|
"errors with minimal runtime cost."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:144
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Callable"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:146
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Frameworks expecting callback functions of specific signatures might be type "
|
|
|
|
|
"hinted using ``Callable[[Arg1Type, Arg2Type], ReturnType]``."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:149
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "For example::"
|
|
|
|
|
msgstr "Par exemple : ::"
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:160
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"It is possible to declare the return type of a callable without specifying "
|
|
|
|
|
"the call signature by substituting a literal ellipsis for the list of "
|
|
|
|
|
"arguments in the type hint: ``Callable[..., ReturnType]``."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:165
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Generics"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:167
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Since type information about objects kept in containers cannot be statically "
|
|
|
|
|
"inferred in a generic way, abstract base classes have been extended to "
|
|
|
|
|
"support subscription to denote expected types for container elements."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:178
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Generics can be parametrized by using a new factory available in typing "
|
|
|
|
|
"called :class:`TypeVar`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:192
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "User-defined generic types"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:194
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A user-defined class can be defined as a generic class."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:220
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"``Generic[T]`` as a base class defines that the class ``LoggedVar`` takes a "
|
|
|
|
|
"single type parameter ``T`` . This also makes ``T`` valid as a type within "
|
|
|
|
|
"the class body."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:224
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"The :class:`Generic` base class uses a metaclass that defines :meth:"
|
|
|
|
|
"`__getitem__` so that ``LoggedVar[t]`` is valid as a type::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:233
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"A generic type can have any number of type variables, and type variables may "
|
|
|
|
|
"be constrained::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:245
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Each type variable argument to :class:`Generic` must be distinct. This is "
|
|
|
|
|
"thus invalid::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:256
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "You can use multiple inheritance with :class:`Generic`::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:265
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"When inheriting from generic classes, some type variables could be fixed::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:274
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "In this case ``MyDict`` has a single parameter, ``T``."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:276
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Using a generic class without specifying type parameters assumes :data:`Any` "
|
|
|
|
|
"for each position. In the following example, ``MyIterable`` is not generic "
|
|
|
|
|
"but implicitly inherits from ``Iterable[Any]``::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:284
|
|
|
|
|
msgid "User defined generic type aliases are also supported. Examples::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
|
|
|
|
#: ../Doc/library/typing.rst:300
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"The metaclass used by :class:`Generic` is a subclass of :class:`abc."
|
|
|
|
|
"ABCMeta`. A generic class can be an ABC by including abstract methods or "
|
|
|
|
|
"properties, and generic classes can also have ABCs as base classes without a "
|
|
|
|
|
"metaclass conflict. Generic metaclasses are not supported. The outcome of "
|
|
|
|
|
"parameterizing generics is cached, and most types in the typing module are "
|
|
|
|
|
"hashable and comparable for equality."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:309
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "The :data:`Any` type"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:311
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"A special kind of type is :data:`Any`. A static type checker will treat "
|
|
|
|
|
"every type as being compatible with :data:`Any` and :data:`Any` as being "
|
|
|
|
|
"compatible with every type."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:315
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"This means that it is possible to perform any operation or method call on a "
|
|
|
|
|
"value of type on :data:`Any` and assign it to any variable::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:333
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Notice that no typechecking is performed when assigning a value of type :"
|
|
|
|
|
"data:`Any` to a more precise type. For example, the static type checker did "
|
|
|
|
|
"not report an error when assigning ``a`` to ``s`` even though ``s`` was "
|
|
|
|
|
"declared to be of type :class:`str` and receives an :class:`int` value at "
|
|
|
|
|
"runtime!"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:339
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Furthermore, all functions without a return type or parameter types will "
|
|
|
|
|
"implicitly default to using :data:`Any`::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:352
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"This behavior allows :data:`Any` to be used as an *escape hatch* when you "
|
|
|
|
|
"need to mix dynamically and statically typed code."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:355
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Contrast the behavior of :data:`Any` with the behavior of :class:`object`. "
|
|
|
|
|
"Similar to :data:`Any`, every type is a subtype of :class:`object`. However, "
|
|
|
|
|
"unlike :data:`Any`, the reverse is not true: :class:`object` is *not* a "
|
|
|
|
|
"subtype of every other type."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:360
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"That means when the type of a value is :class:`object`, a type checker will "
|
|
|
|
|
"reject almost all operations on it, and assigning it to a variable (or using "
|
|
|
|
|
"it as a return value) of a more specialized type is a type error. For "
|
|
|
|
|
"example::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:382
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Use :class:`object` to indicate that a value could be any type in a typesafe "
|
|
|
|
|
"manner. Use :data:`Any` to indicate that a value is dynamically typed."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:386
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Classes, functions, and decorators"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:388
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "The module defines the following classes, functions and decorators:"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:392
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Type variable."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:394 ../Doc/library/typing.rst:789
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Usage::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:399
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"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 class Generic for more information on generic "
|
|
|
|
|
"types. Generic functions work as follows::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:412
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"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 :class:`str`, the return type is "
|
|
|
|
|
"still plain :class:`str`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:417
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"At runtime, ``isinstance(x, T)`` will raise :exc:`TypeError`. In general, :"
|
|
|
|
|
"func:`isinstance` and :func:`issubclass` should not be used with types."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:420
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"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`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:430
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Abstract base class for generic types."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:432
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"A generic type is typically declared by inheriting from an instantiation of "
|
|
|
|
|
"this class with one or more type variables. For example, a generic mapping "
|
|
|
|
|
"type might be defined as::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:441
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "This class can then be used as follows::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:454
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"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::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:463
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Note that ``Type[C]`` is covariant::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:475
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"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`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:483
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"The only legal parameters for :class:`Type` are classes, unions of classes, "
|
|
|
|
|
"and :data:`Any`. For example::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:488
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"``Type[Any]`` is equivalent to ``Type`` which in turn is equivalent to "
|
|
|
|
|
"``type``, which is the root of Python's metaclass hierarchy."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:493
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.Iterable`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:497
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.Iterator`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:501
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.Reversible`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:505
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "An ABC with one abstract method ``__int__``."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:509
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "An ABC with one abstract method ``__float__``."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-04-02 20:14:06 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:513
|
2017-05-27 17:46:38 +00:00
|
|
|
|
msgid "An ABC with one abstract method ``__complex__``."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
|
|
|
|
#: ../Doc/library/typing.rst:517
|
|
|
|
|
msgid "An ABC with one abstract method ``__bytes__``."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
|
|
|
|
#: ../Doc/library/typing.rst:521
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"An ABC with one abstract method ``__abs__`` that is covariant in its return "
|
|
|
|
|
"type."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:526
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"An ABC with one abstract method ``__round__`` that is covariant in its "
|
|
|
|
|
"return type."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:531
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.Container`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:535
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "An alias to :class:`collections.abc.Hashable`"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:539
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "An alias to :class:`collections.abc.Sized`"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:543
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.Collection`"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:549
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.Set`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:553
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.MutableSet`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:557
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.Mapping`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:561
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.MutableMapping`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:565
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.Sequence`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:569
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.MutableSequence`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:573
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.ByteString`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:575
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"This type represents the types :class:`bytes`, :class:`bytearray`, and :"
|
|
|
|
|
"class:`memoryview`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:578
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"As a shorthand for this type, :class:`bytes` can be used to annotate "
|
|
|
|
|
"arguments of any of the types mentioned above."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:583
|
2017-04-02 20:14:06 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.deque`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:589
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Generic version of :class:`list`. Useful for annotating return types. To "
|
|
|
|
|
"annotate arguments it is preferred to use abstract collection types such as :"
|
|
|
|
|
"class:`Mapping`, :class:`Sequence`, or :class:`AbstractSet`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:594
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "This type may be used as follows::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:606
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`builtins.set <set>`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:610
|
2017-04-02 20:14:06 +00:00
|
|
|
|
msgid "A generic version of :class:`builtins.frozenset <frozenset>`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:614
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.MappingView`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:618
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.KeysView`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:622
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.ItemsView`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:626
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.ValuesView`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:630
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.Awaitable`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:634
|
2017-04-02 20:14:06 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"A generic version of :class:`collections.abc.Coroutine`. The variance and "
|
|
|
|
|
"order of type variables correspond to those of :class:`Generator`, for "
|
|
|
|
|
"example::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:647
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.AsyncIterable`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:651
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`collections.abc.AsyncIterator`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:655
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "A generic version of :class:`contextlib.AbstractContextManager`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:661
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"A generic version of :class:`dict`. The usage of this type is as follows::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:669
|
|
|
|
|
msgid "A generic version of :class:`collections.defaultdict`."
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:673
|
|
|
|
|
msgid "A generic version of :class:`collections.Counter`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
|
|
|
|
#: ../Doc/library/typing.rst:679
|
|
|
|
|
msgid "A generic version of :class:`collections.ChainMap`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
|
|
|
|
#: ../Doc/library/typing.rst:685
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"A generator can be annotated by the generic type ``Generator[YieldType, "
|
|
|
|
|
"SendType, ReturnType]``. For example::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:694
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Note that unlike many other generics in the typing module, the ``SendType`` "
|
|
|
|
|
"of :class:`Generator` behaves contravariantly, not covariantly or "
|
|
|
|
|
"invariantly."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:698
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"If your generator will only yield values, set the ``SendType`` and "
|
|
|
|
|
"``ReturnType`` to ``None``::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:706
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Alternatively, annotate your generator as having a return type of either "
|
|
|
|
|
"``Iterable[YieldType]`` or ``Iterator[YieldType]``::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:716
|
2017-04-02 20:14:06 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"An async generator can be annotated by the generic type "
|
|
|
|
|
"``AsyncGenerator[YieldType, SendType]``. For example::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:725
|
2017-04-02 20:14:06 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Unlike normal generators, async generators cannot return a value, so there "
|
|
|
|
|
"is no ``ReturnType`` type parameter. As with :class:`Generator`, the "
|
|
|
|
|
"``SendType`` behaves contravariantly."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:729
|
2017-04-02 20:14:06 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"If your generator will only yield values, set the ``SendType`` to ``None``::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:737
|
2017-04-02 20:14:06 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Alternatively, annotate your generator as having a return type of either "
|
|
|
|
|
"``AsyncIterable[YieldType]`` or ``AsyncIterator[YieldType]``::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:749
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"``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``."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:753
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"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::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:761
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Wrapper namespace for I/O stream types."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:763
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"This defines the generic type ``IO[AnyStr]`` and aliases ``TextIO`` and "
|
2017-05-27 17:46:38 +00:00
|
|
|
|
"``BinaryIO`` for respectively ``IO[str]`` and ``IO[bytes]``. These represent "
|
|
|
|
|
"the types of I/O streams such as returned by :func:`open`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
|
|
|
|
#: ../Doc/library/typing.rst:768
|
|
|
|
|
msgid ""
|
|
|
|
|
"These types are also accessible directly as ``typing.IO``, ``typing."
|
|
|
|
|
"TextIO``, and ``typing.BinaryIO``."
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:773
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Wrapper namespace for regular expression matching types."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:775
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"This defines the type aliases ``Pattern`` and ``Match`` which correspond to "
|
|
|
|
|
"the return types from :func:`re.compile` and :func:`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]``."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:782
|
|
|
|
|
msgid ""
|
|
|
|
|
"These types are also accessible directly as ``typing.Pattern`` and ``typing."
|
|
|
|
|
"Match``."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
|
|
|
|
#: ../Doc/library/typing.rst:787
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Typed version of namedtuple."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:795
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "This is equivalent to::"
|
|
|
|
|
msgstr "C’est équivalent à ::"
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:799
|
2017-04-02 20:14:06 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"To give a field a default value, you can assign to it in the class body::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:808
|
2017-04-02 20:14:06 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Fields with a default value must come after any fields without a default."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:810
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
2017-04-02 20:14:06 +00:00
|
|
|
|
"The resulting class has two extra attributes: ``_field_types``, giving a "
|
2017-05-27 17:46:38 +00:00
|
|
|
|
"dict mapping field names to types, and ``_field_defaults``, a dict mapping "
|
2017-04-02 20:14:06 +00:00
|
|
|
|
"field names to default values. (The field names are in the ``_fields`` "
|
2016-10-30 09:46:26 +00:00
|
|
|
|
"attribute, which is part of the namedtuple API.)"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:815
|
|
|
|
|
msgid "``NamedTuple`` subclasses can also have docstrings and methods::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
|
|
|
|
#: ../Doc/library/typing.rst:825
|
2017-04-02 20:14:06 +00:00
|
|
|
|
msgid "Backward-compatible usage::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:829
|
2017-04-02 20:14:06 +00:00
|
|
|
|
msgid "Added support for :pep:`526` variable annotation syntax."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:832
|
|
|
|
|
msgid "Added support for default values, methods, and docstrings."
|
2017-04-02 20:14:06 +00:00
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:837
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"A helper function to indicate a distinct types to a typechecker, see :ref:"
|
|
|
|
|
"`distinct`. At runtime it returns a function that returns its argument. "
|
|
|
|
|
"Usage::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:846
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Cast a value to a type."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:848
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"This returns the value unchanged. To the type checker this signals that the "
|
|
|
|
|
"return value has the designated type, but at runtime we intentionally don't "
|
|
|
|
|
"check anything (we want this to be as fast as possible)."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:855
|
2017-04-02 20:14:06 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"Return a dictionary containing type hints for a function, method, module or "
|
|
|
|
|
"class object."
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:858
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
2017-04-02 20:14:06 +00:00
|
|
|
|
"This is often the same as ``obj.__annotations__``. In addition, forward "
|
|
|
|
|
"references encoded as string literals are handled by evaluating them in "
|
|
|
|
|
"``globals`` and ``locals`` namespaces. If necessary, ``Optional[t]`` is "
|
|
|
|
|
"added for function and method annotations if a default value equal to "
|
|
|
|
|
"``None`` is set. For a class ``C``, return a dictionary constructed by "
|
|
|
|
|
"merging all the ``__annotations__`` along ``C.__mro__`` in reverse order."
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:868
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"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::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:892
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "See :pep:`484` for details and comparison with other typing semantics."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:896
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Decorator to indicate that annotations are not type hints."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:898
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"The argument must be a class or function; if it is a class, it applies "
|
|
|
|
|
"recursively to all methods defined in that class (but not to methods defined "
|
|
|
|
|
"in its superclasses or subclasses)."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:902
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "This mutates the function(s) in place."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:906
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Decorator to give another decorator the :func:`no_type_check` effect."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:908
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"This wraps the decorator with something that wraps the decorated function "
|
|
|
|
|
"in :func:`no_type_check`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:913
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Special type indicating an unconstrained type."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:915
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Every type is compatible with :data:`Any`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:916
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ":data:`Any` is compatible with every type."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:920
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Union type; ``Union[X, Y]`` means either X or Y."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:922
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "To define a union, use e.g. ``Union[int, str]``. Details:"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:924
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "The arguments must be types and there must be at least one."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:926
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Unions of unions are flattened, e.g.::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:930
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Unions of a single argument vanish, e.g.::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:934
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Redundant arguments are skipped, e.g.::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:938
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "When comparing unions, the argument order is ignored, e.g.::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:942
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"When a class and its subclass are present, the former is skipped, e.g.::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:946
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "You cannot subclass or instantiate a union."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:948
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "You cannot write ``Union[X][Y]``."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:950
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "You can use ``Optional[X]`` as a shorthand for ``Union[X, None]``."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:954
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Optional type."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:956
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "``Optional[X]`` is equivalent to ``Union[X, None]``."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:958
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"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 needn't use the "
|
|
|
|
|
"``Optional`` qualifier on its type annotation (although it is inferred if "
|
|
|
|
|
"the default is ``None``). A mandatory argument may still have an "
|
|
|
|
|
"``Optional`` type if an explicit value of ``None`` is allowed."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:967
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"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."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:970
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"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."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:974
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"To specify a variable-length tuple of homogeneous type, use literal "
|
|
|
|
|
"ellipsis, e.g. ``Tuple[int, ...]``. A plain :data:`Tuple` is equivalent to "
|
2017-04-02 20:14:06 +00:00
|
|
|
|
"``Tuple[Any, ...]``, and in turn to :class:`tuple`."
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:980
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Callable type; ``Callable[[int], str]`` is a function of (int) -> str."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:982
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"The subscription syntax must always be used with exactly two values: the "
|
|
|
|
|
"argument list and the return type. The argument list must be a list of "
|
2017-04-02 20:14:06 +00:00
|
|
|
|
"types or an ellipsis; the return type must be a single type."
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:987
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"There is no syntax to indicate optional or keyword arguments; such function "
|
|
|
|
|
"types are rarely used as callback types. ``Callable[..., ReturnType]`` "
|
|
|
|
|
"(literal ellipsis) can be used to type hint a callable taking any number of "
|
|
|
|
|
"arguments and returning ``ReturnType``. A plain :data:`Callable` is "
|
|
|
|
|
"equivalent to ``Callable[..., Any]``, and in turn to :class:`collections.abc."
|
|
|
|
|
"Callable`."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:997
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid "Special type construct to mark class variables."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:999
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"As introduced in :pep:`526`, a variable annotation wrapped in ClassVar "
|
|
|
|
|
"indicates that a given attribute is intended to be used as a class variable "
|
|
|
|
|
"and should not be set on instances of that class. Usage::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:1007
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ":data:`ClassVar` accepts only types and cannot be further subscribed."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:1009
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
":data:`ClassVar` is not a class itself, and should not be used with :func:"
|
2017-05-27 17:46:38 +00:00
|
|
|
|
"`isinstance` or :func:`issubclass`. :data:`ClassVar` does not change Python "
|
|
|
|
|
"runtime behavior, but it can be used by third-party type checkers. For "
|
|
|
|
|
"example, a type checker might flag the following code as an error::"
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:1023
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"``AnyStr`` is a type variable defined as ``AnyStr = TypeVar('AnyStr', str, "
|
|
|
|
|
"bytes)``."
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:1026
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"It is meant to be used for functions that may accept any kind of string "
|
|
|
|
|
"without allowing different kinds of strings to mix. For example::"
|
|
|
|
|
msgstr ""
|
|
|
|
|
|
2017-05-27 17:46:38 +00:00
|
|
|
|
#: ../Doc/library/typing.rst:1038
|
2016-10-30 09:46:26 +00:00
|
|
|
|
msgid ""
|
|
|
|
|
"A special constant that is assumed to be ``True`` by 3rd party static type "
|
|
|
|
|
"checkers. It is ``False`` at runtime. Usage::"
|
|
|
|
|
msgstr ""
|
2017-05-27 17:46:38 +00:00
|
|
|
|
|
|
|
|
|
#: ../Doc/library/typing.rst:1047
|
|
|
|
|
msgid ""
|
|
|
|
|
"Note that 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."
|
|
|
|
|
msgstr ""
|