@@ -322,6 +322,9 @@ msgid ""
322
322
" discussed below. It is an error to specify both ``default`` and "
323
323
"``default_factory``."
324
324
msgstr ""
325
+ "``default_factory``: 提供されていた場合、0 引数の呼び出し可能オブジェクトでなければならず、このフィールドの初期値が必要になったときに呼び出されます。\n"
326
+ "他の目的も含めて、下で議論されているように、フィールドに可変なデフォルト値を指定するのに使えます。\n"
327
+ "``default`` と ``default_factory`` の両方を指定するとエラーになります。"
325
328
326
329
#: ../../library/dataclasses.rst:212
327
330
msgid ""
@@ -541,7 +544,7 @@ msgid ""
541
544
"on the call to :func:`replace` so that they can be passed to "
542
545
":meth:`__init__` and :meth:`__post_init__`."
543
546
msgstr ""
544
- "初期化のみ行われる変数でデフォルト値を持たないものがもしあれば 、 :func:`replace` の呼び出し時に初期値が指定され、 "
547
+ "初期化限定変数でデフォルト値を持たないものがもしあれば 、 :func:`replace` の呼び出し時に初期値が指定され、 "
545
548
":meth:`__init__` と :meth:`__post_init__` に渡せるようにしなければなりません。"
546
549
547
550
#: ../../library/dataclasses.rst:375
@@ -606,13 +609,17 @@ msgid ""
606
609
"Among other uses, this allows for initializing field values that depend on "
607
610
"one or more other fields. For example::"
608
611
msgstr ""
612
+ "他の機能と組み合わせることで、他の 1 つ以上のフィールドに依存しているフィールドが初期化できます。\n"
613
+ "例えば次のようにできます::"
609
614
610
615
#: ../../library/dataclasses.rst:423
611
616
msgid ""
612
617
"See the section below on init-only variables for ways to pass parameters to "
613
618
":meth:`__post_init__`. Also see the warning about how :func:`replace` "
614
619
"handles ``init=False`` fields."
615
620
msgstr ""
621
+ "下にある初期化限定変数についての節で、 :meth:`__post_init__` にパラメータを渡す方法を参照してください。\n"
622
+ ":func:`replace` が ``init=False`` であるフィールドをどう取り扱うかについての警告も参照してください。"
616
623
617
624
#: ../../library/dataclasses.rst:428
618
625
msgid "Class variables"
@@ -628,6 +635,10 @@ msgid ""
628
635
"``ClassVar`` pseudo-fields are not returned by the module-level "
629
636
":func:`fields` function."
630
637
msgstr ""
638
+ ":func:`dataclass` が実際にフィールドの型の検査を行う 2 箇所のうち 1 つは、フィールドが :pep:`526` で定義されたクラス変数かどうかの判定です。\n"
639
+ "その判定はフィールドの型が ``typing.ClassVar`` かどうかで行います。\n"
640
+ "フィールドが ``ClassVar`` の場合、フィールドとは見なされなくなり、データクラスの機構からは無視されます。\n"
641
+ "そのような ``ClassVar`` 疑似フィールドは、モジュールレベル関数 :func:`fields` の返り値には含まれません。"
631
642
632
643
#: ../../library/dataclasses.rst:439
633
644
msgid "Init-only variables"
@@ -644,18 +655,26 @@ msgid ""
644
655
"generated :meth:`__init__` method, and are passed to the optional "
645
656
":meth:`__post_init__` method. They are not otherwise used by dataclasses."
646
657
msgstr ""
658
+ ":func:`dataclass` が型アノテーションの検査を行うもう 1 つの箇所は、フィールドが初期化限定変数かどうかの判定です。\n"
659
+ "その判定はフィールドの型が ``dataclasses.InitVar`` 型であるかどうかで行います。\n"
660
+ "フィールドが ``InitVar`` の場合、初期化限定フィールドと呼ばれる疑似フィールドと見なされます。\n"
661
+ "これは本物のフィールドではないので、モジュールレベル関数 :func:`fields` の返り値には含まれません。\n"
662
+ "初期化限定フィールドは生成された :meth:`__init__` メソッドに引数として追加され、オプションの :meth:`__post_init__` メソッドにも渡されます。\n"
663
+ "初期化限定フィールドは、データクラスからはそれ以外では使われません。"
647
664
648
665
#: ../../library/dataclasses.rst:451
649
666
msgid ""
650
667
"For example, suppose a field will be initialized from a database, if a value"
651
668
" is not provided when creating the class::"
652
- msgstr ""
669
+ msgstr "例えば、あるフィールドがデータベースから初期化されると仮定して、クラスを作成するときには値が与えられない次の場合を考えます:: "
653
670
654
671
#: ../../library/dataclasses.rst:466
655
672
msgid ""
656
673
"In this case, :func:`fields` will return :class:`Field` objects for ``i`` "
657
674
"and ``j``, but not for ``database``."
658
675
msgstr ""
676
+ "このケースでは、 :func:`fields` は ``i`` と ``j`` の :class:`Field` オブジェクトは返しますが、 "
677
+ "``database`` の :class:`Field` オブジェクトは返しません。"
659
678
660
679
#: ../../library/dataclasses.rst:470
661
680
msgid "Frozen instances"
0 commit comments