@@ -190,7 +190,7 @@ msgid ""
190
190
"``eq`` and ``frozen`` flags in the :func:`dataclass` decorator."
191
191
msgstr ""
192
192
":meth:`__hash__` は、組み込みの :meth:`hash()` から使われたり、 dict や set のようなハッシュ化されたコレクションにオブジェクトを追加するときに使われます。\n"
193
- ":meth:`__hash__` があるということはそのクラスのインスタンスが変更不能であることを意味します 。\n"
193
+ ":meth:`__hash__` があるということはそのクラスのインスタンスが不変 (イミュータブル) であることを意味します 。\n"
194
194
"可変性というのは複雑な性質で、プログラマの意図、 :meth:`__eq__` が存在しているかどうかとその振る舞い、 :func:`dataclass` デコレータの ``eq`` フラグと ``frozen`` フラグの値に依存します。"
195
195
196
196
#: ../../library/dataclasses.rst:131
@@ -214,6 +214,10 @@ msgid ""
214
214
" your class is logically immutable but can nonetheless be mutated. This is a"
215
215
" specialized use case and should be considered carefully."
216
216
msgstr ""
217
+ ":meth:`__hash__` が明示的に定義されていなかったり、 ``None`` に設定されていた場合は、 :func:`dataclass` は暗黙的に :meth:`__hash__` メソッドを追加する *かもしれません* 。\n"
218
+ "推奨はできませんが、 ``unsafe_hash=True`` とすることで :func:`dataclass` に :meth:`__hash__` メソッドを作成させられます。\n"
219
+ "こうしてしまうと、クラスが論理的には不変だがそれにもかかわらず変更できてしまう場合、問題になり得ます。\n"
220
+ "こうするのは特別なユースケースで、慎重に検討するべきです。"
217
221
218
222
#: ../../library/dataclasses.rst:144
219
223
msgid ""
@@ -222,6 +226,8 @@ msgid ""
222
226
" dataclass and set ``unsafe_hash=True``; this will result in a "
223
227
":exc:`TypeError`."
224
228
msgstr ""
229
+ ":meth:`__hash__` メソッドが暗黙的に作られるかどうかを決定する規則は次の通りです。\n"
230
+ "データクラスに明示的な :meth:`__hash__` メソッドを持たせた上で、 ``unsafe_hash=True`` と設定することはできません; こうすると :exc:`TypeError` になります。"
225
231
226
232
#: ../../library/dataclasses.rst:149
227
233
msgid ""
@@ -233,6 +239,9 @@ msgid ""
233
239
"of the superclass will be used (if the superclass is :class:`object`, this "
234
240
"means it will fall back to id-based hashing)."
235
241
msgstr ""
242
+ "``eq`` と ``frozen`` が両方とも真だった場合、デフォルトでは :func:`dataclass` は :meth:`__hash__` メソッドを生成します。\n"
243
+ "``eq`` が真で ``frozen`` が偽の場合、:meth:`__hash__` は ``None`` に設定され、(可変なので) ハッシュ化不可能とされます。\n"
244
+ "``eq`` が偽の場合は、 :meth:`__hash__` は手を付けないまま、つまりスーパークラスの :meth:`__hash__` メソッドが使われることになります (スーパークラスが :class:`object` だった場合は、 id に基づいたハッシュ化にフォールバックするということになります)。"
236
245
237
246
#: ../../library/dataclasses.rst:157
238
247
msgid ""
0 commit comments