Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb2c8920

Browse files
[po] auto sync
1 parentb801abe commitb2c8920

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

‎.stat.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"translation":"99.66%","updated_at":"2025-10-28T15:15:17Z"}
1+
{"translation":"99.67%","updated_at":"2025-10-29T02:45:51Z"}

‎library/dataclasses.po‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ msgid ""
1212
msgstr ""
1313
"Project-Id-Version:Python 3.14\n"
1414
"Report-Msgid-Bugs-To:\n"
15-
"POT-Creation-Date:2025-10-25 14:12+0000\n"
15+
"POT-Creation-Date:2025-10-27 14:15+0000\n"
1616
"PO-Revision-Date:2025-09-16 00:01+0000\n"
1717
"Last-Translator:Freesand Leo <yuqinju@163.com>, 2025\n"
1818
"Language-Team:Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n"
@@ -1112,6 +1112,10 @@ msgid ""
11121112
"``ClassVar`` pseudo-fields are not returned by the module-level "
11131113
":func:`fields` function."
11141114
msgstr""
1115+
":deco:`dataclass` 会实际检查字段类型的少数几个地方是确定字段是否是在 :pep:`526` 中定义的类变量。 "
1116+
"它通过检查字段的类型是否为 :data:`typing.ClassVar` 来做到这一点。 如果一个字段是 "
1117+
"``ClassVar``,它将被排除在字段范围之外并会被数据类机制所忽略。 这样的 ``ClassVar`` 伪字段将不会被模块层级的 "
1118+
":func:`fields` 函数返回。"
11151119

11161120
#:../../library/dataclasses.rst:613
11171121
msgid"Init-only variables"
@@ -1128,6 +1132,11 @@ msgid ""
11281132
"generated :meth:`~object.__init__` method, and are passed to the optional "
11291133
":meth:`__post_init__` method. They are not otherwise used by dataclasses."
11301134
msgstr""
1135+
"另一个 :deco:`dataclass` 会检查类型标注的地方是为了确定一个字段是否为仅限初始化的变量。 它通过检查字段的类型是否为 "
1136+
":class:`InitVar` 类型来做到这一点。 如果一个字段是 :class:`InitVar`,它会被当作是一个名为仅限初始化字段的伪字段。 "
1137+
"因为它不是一个真正的字段,所以它不会被模块层及的 :func:`fields` 函数返回。 仅限初始化字段会作为形参被添加到所生成的 "
1138+
":meth:`~object.__init__` 方法中,并会被传递给可选的 :meth:`__post_init__` 方法。 "
1139+
"在其他情况下它们将不会被数据类所使用。"
11311140

11321141
#:../../library/dataclasses.rst:625
11331142
msgid""
@@ -1181,6 +1190,9 @@ msgid ""
11811190
":meth:`~object.__setattr__` and :meth:`~object.__delattr__` methods to the "
11821191
"class. These methods will raise a :exc:`FrozenInstanceError` when invoked."
11831192
msgstr""
1193+
"创建真正不可变的 Python 对象是不可能的。 不过,你可以通过将 ``frozen=True`` 传递给 :deco:`dataclass` "
1194+
"装饰器来模拟出不可变性。 在这种情况下,数据类将向类添加 :meth:`~object.__setattr__` 和 "
1195+
":meth:`~object.__delattr__` 方法。 当被唤起时这些方法将会引发 :exc:`FrozenInstanceError`。"
11841196

11851197
#:../../library/dataclasses.rst:654
11861198
msgid""
@@ -1206,6 +1218,10 @@ msgid ""
12061218
"ordered mapping of fields. Because the fields are in insertion order, "
12071219
"derived classes override base classes. An example::"
12081220
msgstr""
1221+
"当数据类由 :deco:`dataclass` 装饰器创建时,它会按 MRO 的反序(也就是说,从 :class:`object` "
1222+
"开始)查看它的所有基类,然后,对于它找到的每个数据类,将基类中的字段添加到一个有序映射中。 "
1223+
"在添加完所有基类字段后,它会将它自己的字段添加到这个有序映射中。 所有被生成的方法都将使用这个包含合并后的、计算好的字段的有序映射。 "
1224+
"因为这些字段会保持插入顺序,所以派生的类会重写其基类。 一个例子::"
12091225

12101226
#:../../library/dataclasses.rst:675
12111227
msgid""
@@ -1448,6 +1464,11 @@ msgid ""
14481464
"assumption is that if a value is unhashable, it is mutable. This is a "
14491465
"partial solution, but it does protect against many common errors."
14501466
msgstr""
1467+
"这具有与使用 :class:`!C` 类的原始示例相同的问题。 也就是说,当创建类实例时如果 :class:`!D` 类的两个实例没有为 "
1468+
":attr:`!x` 指定值则将共享同一个 :attr:`!x` 的副本。 因为数据类只是使用普通的 Python "
1469+
"类创建机制所以排泄物不能会共享此行为。 数据类没有任何通用方式来检测这种情况。 相反地,:deco:`dataclass` "
1470+
"装饰器在检测到不可哈希的默认形参时将会引发 :exc:`ValueError`。 这一行为假定如果一个值是不可哈希的,那么它就是可变对象。 "
1471+
"这是一个部分解决方案,但它确实能防止许多常见错误。"
14511472

14521473
#:../../library/dataclasses.rst:794
14531474
msgid""
@@ -1515,6 +1536,9 @@ msgid ""
15151536
"hand, if the descriptor raises :exc:`AttributeError` in this situation, no "
15161537
"default value will be provided for the field."
15171538
msgstr""
1539+
"为了确定一个字段是否包含默认值 ,:deco:`dataclass` 会使用类访问形式调用描述器的 :meth:`!__get__` 方法: "
1540+
"``descriptor.__get__(obj=None, type=cls)``。 如果在此情况下描述器返回了一个值,它将被用作字段的默认值。 "
1541+
"另一方面,如果在此情况下描述器引发了 :exc:`AttributeError`,则不会为字段提供默认值。"
15181542

15191543
#:../../library/dataclasses.rst:833
15201544
msgid""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp