Expand Up @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: Python 3.12\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-06-03 00:03+0000\n" "PO-Revision-Date: 2024-03-26 11:30 +0800\n" "PO-Revision-Date: 2024-07-11 11:12 +0800\n" "Last-Translator: Li-Hung Wang <therockleona@gmail.com>\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" Expand All @@ -16,7 +16,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" "X-Generator: Poedit 3.4\n" "X-Generator: Poedit 3.4.4 \n" #: ../../library/typing.rst:3 msgid ":mod:`typing` --- Support for type hints" Expand All @@ -41,7 +41,7 @@ msgstr "此模組提供 runtime 型別提示支援。" #: ../../library/typing.rst:28 msgid "Consider the function below::" msgstr "" msgstr "動腦筋思考下面的函式: :: " #: ../../library/typing.rst:33 msgid "" Expand All @@ -50,13 +50,18 @@ msgid "" "The function is expected to return an instance of :class:`str`, as indicated " "by the ``-> str`` hint." msgstr "" "函式 ``moon_weight`` 需要一個引數且預期是一個 :class:`float` 的實例,如 " "``earth_weight: float`` 所指出的\\ *型別提示*。這個函式預期會回傳一個 :class:" "`str` 的實例,如 ``-> str`` 所指出的提示。" #: ../../library/typing.rst:37 msgid "" "While type hints can be simple classes like :class:`float` or :class:`str`, " "they can also be more complex. The :mod:`typing` module provides a " "vocabulary of more advanced type hints." msgstr "" "儘管型別提示可以是簡單類別,像是 :class:`float` 或 :class:`str`,他們也可以變" "得更為複雜。模組 :mod:`typing` 提供一組更高階的型別提示詞彙。" #: ../../library/typing.rst:41 msgid "" Expand Down Expand Up @@ -113,14 +118,17 @@ msgstr "" #: ../../library/typing.rst:63 msgid "Specification for the Python Type System" msgstr "" msgstr "Python 型別系統的技術規範 " #: ../../library/typing.rst:65 msgid "" "The canonical, up-to-date specification of the Python type system can be " "found at `\"Specification for the Python type system\" <https://typing." "readthedocs.io/en/latest/spec/index.html>`_." msgstr "" "關於 Python 型別系統標準的 (canonical)、最新的技術規範可以在\\ `「Python 型別" "系統的技術規範」 <https://typing.readthedocs.io/en/latest/spec/index." "html>`_\\ 找到。" #: ../../library/typing.rst:71 msgid "Type aliases" Expand Down Expand Up @@ -885,14 +893,16 @@ msgid "" ":data:`!Never` and :data:`!NoReturn` have the same meaning in the type " "system and static type checkers treat both equivalently." msgstr "" ":data:`!Never` 以及 :data:`!NoReturn` 在型別系統中具有相同的意義且靜態型別檢" "查器會將兩者視為相等。" #: ../../library/typing.rst:883 msgid "Added :data:`NoReturn`." msgstr "" msgstr "新增 :data:`NoReturn`。 " #: ../../library/typing.rst:887 msgid "Added :data:`Never`." msgstr "" msgstr "新增 :data:`Never`。 " #: ../../library/typing.rst:891 msgid "Special type to represent the current enclosed class." Expand Down Expand Up @@ -983,67 +993,73 @@ msgstr "" #: ../../library/typing.rst:991 msgid "Special forms" msgstr "" msgstr "特別型式 " #: ../../library/typing.rst:993 msgid "" "These can be used as types in annotations. They all support subscription " "using ``[]``, but each has a unique syntax." msgstr "" "這些在註釋中可以當作型別使用。他們全都支援 ``[]`` 的下標使用,但每個都具有獨" "特的語法。" #: ../../library/typing.rst:998 msgid "" "Union type; ``Union[X, Y]`` is equivalent to ``X | Y`` and means either X or " "Y." msgstr "" "聯集型別;``Union[X, Y]`` 與 ``X | Y`` 是相等的,且都意味著 X 或 Y 兩者其一。" #: ../../library/typing.rst:1000 msgid "" "To define a union, use e.g. ``Union[int, str]`` or the shorthand ``int | " "str``. Using that shorthand is recommended. Details:" msgstr "" "為了定義聯集,例如可以使用 ``Union[int, str]`` 或是使用簡寫 (shorthand) " "``int | str``。使用這種簡寫是非常推薦的。詳細請看: ::" #: ../../library/typing.rst:1002 msgid "The arguments must be types and there must be at least one." msgstr "" msgstr "引數必須為型別且必須有至少一個。 " #: ../../library/typing.rst:1004 msgid "Unions of unions are flattened, e.g.::" msgstr "" msgstr "聯集中的聯集會是扁平化的 (flattened),舉例來說: :: " #: ../../library/typing.rst:1008 msgid "Unions of a single argument vanish, e.g.::" msgstr "" msgstr "單一引數的聯集會消失不見,舉例來說: :: " #: ../../library/typing.rst:1012 msgid "Redundant arguments are skipped, e.g.::" msgstr "" msgstr "多餘的引數會被略過,舉例來說: :: " #: ../../library/typing.rst:1016 msgid "When comparing unions, the argument order is ignored, e.g.::" msgstr "" msgstr "當比較聯集時,引數的順序會被忽略,舉例來說: :: " #: ../../library/typing.rst:1020 msgid "You cannot subclass or instantiate a ``Union``." msgstr "" msgstr "你不能建立 ``Union`` 的子類別或是實例。 " #: ../../library/typing.rst:1022 msgid "You cannot write ``Union[X][Y]``." msgstr "你不能寫成 ``Union[X][Y]``。" #: ../../library/typing.rst:1024 msgid "Don't remove explicit subclasses from unions at runtime." msgstr "" msgstr "請勿在 runtime 中將顯性子類別從聯集中移除。 " #: ../../library/typing.rst:1027 msgid "" "Unions can now be written as ``X | Y``. See :ref:`union type " "expressions<types-union>`." msgstr "" "現在可以將聯集寫成 ``X | Y``。請見\\ :ref:`聯集型別運算式 <types-union>`。" #: ../../library/typing.rst:1033 msgid "``Optional[X]`` is equivalent to ``X | None`` (or ``Union[X, None]``)." msgstr "" msgstr "``Optional[X]`` 與 ``X | None`` 是相等的(或是 ``Union[X, None]``)。 " #: ../../library/typing.rst:1035 msgid "" Expand All @@ -1052,23 +1068,30 @@ msgid "" "the ``Optional`` qualifier on its type annotation just because it is " "optional. For example::" msgstr "" "請注意,這與具有預設值的選擇性引數 (optional argument) 不是相同的概念。一個具" "有預設值的選擇性引數的型別註釋中不具有 ``Optional`` 限定符 (qualifier),單純" "的因為它就是選擇性的。舉例來說: ::" #: ../../library/typing.rst:1043 msgid "" "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::" msgstr "" "另一方面,如果一個顯性的值 ``None`` 是被允許的,不論引數是不是選擇性的," "``Optional`` 都適用。舉例來說: ::" #: ../../library/typing.rst:1050 msgid "" "Optional can now be written as ``X | None``. See :ref:`union type " "expressions<types-union>`." msgstr "" "現在可以將 Optional 寫成 ``X | None``。請見\\ :ref:`聯集型別運算式 <types-" "union>`。" #: ../../library/typing.rst:1056 msgid "Special form for annotating higher-order functions." msgstr "" msgstr "用於註釋高階函式的特別型式。 " #: ../../library/typing.rst:1058 msgid "" Expand All @@ -1080,6 +1103,13 @@ msgid "" "a :ref:`Callable <annotating-callables>`. The last parameter to " "``Concatenate`` must be a :class:`ParamSpec` or ellipsis (``...``)." msgstr "" "``Concatenate`` 可以被用在\\ :ref:`可呼叫物件 <annotating-callables>`\\ 與 :" "class:`ParamSpec` 的接合 (conjunction) 並註釋一個高階的 Callable 物件可以新" "增、移除、轉換另一個 Callable 物件的參數。使用方法是依照這個格式 " "``Concatenate[Arg1Type, Arg2Type, ..., ParamSpecVariable]``。``Concatenate`` " "目前只在 :ref:`Callable 物件 <annotating-callables>`\\ 中第一個引數使用時有" "效。``Concatenate`` 的最後一個參數必須為一個 :class:`ParamSpec` 或是刪節號 " "(``...``)。" #: ../../library/typing.rst:1067 msgid "" Expand All @@ -1091,12 +1121,17 @@ msgid "" "parameter types are dependent on the parameter types of the callable being " "passed in::" msgstr "" "舉例來說,註釋一個為裝飾過後的函式提供 :class:`threading.Lock` 的裝飾器 " "``with_lock``,``Concatenate`` 可以用於指出 ``with_lock`` 預期一個 Callable " "物件,該物件可以接受 ``Lock`` 作為第一引數,並回傳一個具有不同型別簽名 " "Callable 物件。在這種情況下,:class:`ParamSpec` 指出回傳的 Callable 物件的參" "數型別會依賴傳遞的 Callable 物件的參數型別: ::" #: ../../library/typing.rst:1103 ../../library/typing.rst:1865 msgid "" ":pep:`612` -- Parameter Specification Variables (the PEP which introduced " "``ParamSpec`` and ``Concatenate``)" msgstr "" msgstr ":pep:`612` -- 參數技術規範變數 " #: ../../library/typing.rst:1105 msgid ":class:`ParamSpec`" Expand All @@ -1108,20 +1143,24 @@ msgstr ":ref:`annotating-callables`" #: ../../library/typing.rst:1110 msgid "Special typing form to define \"literal types\"." msgstr "" msgstr "特殊型別格式,用於定義「文本型別 (literal type)」。 " #: ../../library/typing.rst:1112 msgid "" "``Literal`` can be used to indicate to type checkers that the annotated " "object has a value equivalent to one of the provided literals." msgstr "" "``Literal`` 可以用於型別檢查器並指出註釋物件具有一個與提供的文本相同的值。" #: ../../library/typing.rst:1128 msgid "" "``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." msgstr "" "``Literal[...]`` 不可以進行子類別化。在 runtime 之中,任意的值是允許作為 " "``Literal[...]`` 的型別引數,但型別檢查器可能會加強限制。更多有關文本型別的詳" "細資訊請看 :pep:`586`。" #: ../../library/typing.rst:1134 msgid "" Expand All @@ -1130,21 +1169,27 @@ msgid "" "now raise a :exc:`TypeError` exception during equality comparisons if one of " "their parameters are not :term:`hashable`." msgstr "" "``Literal``現在可以刪除重複 (de-deplicate) 的參數。``Literal`` 物件的相等性比" "較不再依照相依性排序。``Literal`` 物件現在會在相等性比較期間,若任一個其中的" "參數無法 :term:`hashable` 時,則會引發一個 :exc:`TypeError` 例外。" #: ../../library/typing.rst:1142 msgid "Special type construct to mark class variables." msgstr "" msgstr "特殊型別建構,用來標記類別變數。 " #: ../../library/typing.rst:1144 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 "" "如同在 :pep:`526` 中的介紹,一個變數註解被包裝在 ClassVar 中時,會指出一個給" "定的屬性 (attribute) 意圖被當作類別變數使用,且不該被設定成該類別的實例。使用" "方法如下: ::" #: ../../library/typing.rst:1152 msgid ":data:`ClassVar` accepts only types and cannot be further subscribed." msgstr "" msgstr ":data:`ClassVar` 只接受型別請不得使用下標。 " #: ../../library/typing.rst:1154 msgid "" Expand All @@ -1153,26 +1198,33 @@ msgid "" "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::" msgstr "" ":data:`ClassVar` 並不代表該類別本身,而且不應該和 :func:`isinstance` 或是 :" "func:`issubclass` 一起使用。:data:`ClassVar` 不會改變 Python runtime 的行為," "但它可以被第三方的型別檢查器使用。舉例來說,一個型別檢查器可能會標記下方的程" "式碼為一個錯誤: ::" #: ../../library/typing.rst:1168 msgid "Special typing construct to indicate final names to type checkers." msgstr "" msgstr "特殊型別建構,用來指出最終名稱給型別檢查器。 " #: ../../library/typing.rst:1170 msgid "" "Final names cannot be reassigned in any scope. Final names declared in class " "scopes cannot be overridden in subclasses." msgstr "" "最終名稱不可以在任何作用域 (scope) 中重新賦值。在類別作用域中宣告的最終名稱," "不得在子類別中進行覆寫 (override)。" #: ../../library/typing.rst:1184 ../../library/typing.rst:2785 msgid "" "There is no runtime checking of these properties. See :pep:`591` for more " "details." msgstr "" "這些屬性 (property) 不會在 runtime 時進行檢查。更多詳細資訊請看 :pep:`591`。" #: ../../library/typing.rst:1191 msgid "Special typing construct to mark a :class:`TypedDict` key as required." msgstr "" msgstr "特殊型別建構,用來標記一個 :class:`TypedDict` 鍵值是必須的。 " #: ../../library/typing.rst:1193 msgid "" Expand All @@ -1186,7 +1238,7 @@ msgstr "" msgid "" "Special typing construct to mark a :class:`TypedDict` key as potentially " "missing." msgstr "" msgstr "特殊型別建構,用來標記一個 :class:`TypedDict` 鍵值是可能消失的。 " #: ../../library/typing.rst:1203 msgid "See :class:`TypedDict` and :pep:`655` for more details." Expand Down