@@ -12,7 +12,7 @@ msgid ""
1212msgstr ""
1313"Project-Id-Version : Python 3.14\n "
1414"Report-Msgid-Bugs-To : \n "
15- "POT-Creation-Date : 2026-03-05 14:41 +0000\n "
15+ "POT-Creation-Date : 2026-03-07 14:18 +0000\n "
1616"PO-Revision-Date : 2025-09-16 00:00+0000\n "
1717"Last-Translator : digdugdog, 2026\n "
1818"Language-Team : Japanese (https://app.transifex.com/python-doc/teams/5390/ "
@@ -129,6 +129,11 @@ msgid ""
129129"practice in Python versions 3.10 and newer is to call :func:`getattr` with "
130130"three arguments, for example ``getattr(o, '__annotations__', None)``."
131131msgstr ""
132+ "しかし、それ以外の callable (例えば、 :func:`functools.partial` で作られたも"
133+ "の) は ``__annotations__`` 属性が定義されていない可能性があります。この属性が"
134+ "あるかどうか不明なオブジェクトの場合は、Python 3.10 以降では、 :func:"
135+ "`getattr` に3つの引数を渡して呼び出す (例えば ``getattr(o, "
136+ "'__annotations__', None)`` ) のを推奨します。"
132137
133138#: ../../howto/annotations.rst:65
134139msgid ""
@@ -137,17 +142,24 @@ msgid ""
137142"parent's ``__annotations__``. In Python 3.10 and newer, the child class's "
138143"annotations will be an empty dict instead."
139144msgstr ""
145+ "Python 3.10 より前のバージョンでは、親クラスにアノテーションがあるが自身はア"
146+ "ノテーションを定義していないようなクラスの場合、 ``__annotations__`` を取得す"
147+ "ると親クラスの ``__annotations__`` が返されます。3.10 以降では、代わりに空の"
148+ "辞書が返されます。"
140149
141150#: ../../howto/annotations.rst:73
142151msgid "Accessing The Annotations Dict Of An Object In Python 3.9 And Older"
143- msgstr ""
152+ msgstr "オブジェクトのアノテーション辞書へのアクセス (Python 3.9 以前) "
144153
145154#: ../../howto/annotations.rst:75
146155msgid ""
147156"In Python 3.9 and older, accessing the annotations dict of an object is much "
148157"more complicated than in newer versions. The problem is a design flaw in "
149158"these older versions of Python, specifically to do with class annotations."
150159msgstr ""
160+ "Python 3.9 以前では、オブジェクトのアノテーション辞書を取得するのはより複雑で"
161+ "す。原因は、3.9 以前のバージョンの設計上の欠陥 (具体的にはクラスのアノテー"
162+ "ション) です。"
151163
152164#: ../../howto/annotations.rst:80
153165msgid ""
@@ -157,6 +169,10 @@ msgid ""
157169"should use three-argument :func:`getattr` to access the object's "
158170"``__annotations__`` attribute."
159171msgstr ""
172+ "クラス以外のオブジェクト (関数や他の callable、モジュール) のアノテーションを"
173+ "取得する推奨の方法は、3.10と同じです。 :func:`inspect.get_annotations` ではな"
174+ "く、 :func:`getattr` に3つの引数を渡すことで ``__annotations__`` 属性を取得"
175+ "するのがいいです。"
160176
161177#: ../../howto/annotations.rst:87
162178msgid ""
@@ -166,6 +182,10 @@ msgid ""
166182"``__annotations__`` attribute of a class may inadvertently return the "
167183"annotations dict of a *base class.* As an example::"
168184msgstr ""
185+ "ただし、クラスについては推奨方法が異なります。なぜなら、クラスには "
186+ "``__annotations__`` は必須ではなく、属性はベースクラスから継承されるので、 "
187+ "``__annotations__`` 属性にアクセスするとベースクラスのアノテーション辞書を取"
188+ "得してしまうという問題があるからです。例えば::"
169189
170190#: ../../howto/annotations.rst:94
171191msgid ""
@@ -178,10 +198,19 @@ msgid ""
178198"\n"
179199"print(Derived.__annotations__)"
180200msgstr ""
201+ "class Base:\n"
202+ " a: int = 3\n"
203+ " b: str = 'abc'\n"
204+ "\n"
205+ "class Derived(Base):\n"
206+ " pass\n"
207+ "\n"
208+ "print(Derived.__annotations__)"
181209
182210#: ../../howto/annotations.rst:103
183211msgid "This will print the annotations dict from ``Base``, not ``Derived``."
184212msgstr ""
213+ "このコードでは ``Derived`` ではなく ``Base`` のアノテーションが表示されます。"
185214
186215#: ../../howto/annotations.rst:106
187216msgid ""
@@ -192,13 +221,21 @@ msgid ""
192221"dictionary. Since the class may or may not have annotations defined, best "
193222"practice is to call the :meth:`~dict.get` method on the class dict."
194223msgstr ""
224+ "クラス (``isinstance(o, type)``) のアノテーションを取得するためには、新たに分"
225+ "岐を追加する必要があります。推奨する方法では、 Python 3.9 以前の実装に依存し"
226+ "た方法をとります。クラスにアノテーションがあれば、 :attr:`~type.__dict__` の"
227+ "辞書に格納されるという実装になっています。クラスにはアノテーションがない場合"
228+ "もあるため、この辞書の :meth:`~dict.get` メソッドを使ってアノテーションを取得"
229+ "する、というのが推奨の方法です。"
195230
196231#: ../../howto/annotations.rst:114
197232msgid ""
198233"To put it all together, here is some sample code that safely accesses the "
199234"``__annotations__`` attribute on an arbitrary object in Python 3.9 and "
200235"before::"
201236msgstr ""
237+ "以上を踏まえると、Python 3.9 以前では、以下のサンプルコードで任意のオブジェク"
238+ "トの ``__annotations__`` 属性を安全に取得することができます::"
202239
203240#: ../../howto/annotations.rst:118
204241msgid ""
@@ -207,24 +244,34 @@ msgid ""
207244"else:\n"
208245" ann = getattr(o, '__annotations__', None)"
209246msgstr ""
247+ "if isinstance(o, type):\n"
248+ " ann = o.__dict__.get('__annotations__', None)\n"
249+ "else:\n"
250+ " ann = getattr(o, '__annotations__', None)"
210251
211252#: ../../howto/annotations.rst:123
212253msgid ""
213254"After running this code, ``ann`` should be either a dictionary or ``None``. "
214255"You're encouraged to double-check the type of ``ann`` using :func:"
215256"`isinstance` before further examination."
216257msgstr ""
258+ "このコードを実行すると、 ``ann`` の値は辞書か ``None`` となります。さらに "
259+ "``ann`` の値を調べるには、 :func:`isinstance` で型を再度確認することを推奨し"
260+ "ます。"
217261
218262#: ../../howto/annotations.rst:128
219263msgid ""
220264"Note that some exotic or malformed type objects may not have a :attr:`~type."
221265"__dict__` attribute, so for extra safety you may also wish to use :func:"
222266"`getattr` to access :attr:`!__dict__`."
223267msgstr ""
268+ "ただし、一部の特殊な型オブジェクトや不正な形式の型オブジェクトは :attr:"
269+ "`~type.__dict__` 属性がないこともあるため、さらに安全をとるには :func:"
270+ "`getattr` を使って :attr:`!__dict__` を取得したほうがいいです。"
224271
225272#: ../../howto/annotations.rst:134
226273msgid "Manually Un-Stringizing Stringized Annotations"
227- msgstr ""
274+ msgstr "文字列指定のアノテーションを手動で解決する方法 "
228275
229276#: ../../howto/annotations.rst:136
230277msgid ""
@@ -233,6 +280,8 @@ msgid ""
233280"really is best to call :func:`inspect.get_annotations` to do this work for "
234281"you."
235282msgstr ""
283+ "アノテーションは文字列として指定されている場合があり、それを評価して Python "
284+ "の値に変換するには、 :func:`inspect.get_annotations` を使うのが一番です。"
236285
237286#: ../../howto/annotations.rst:142
238287msgid ""
@@ -241,25 +290,34 @@ msgid ""
241290"encouraged to examine the implementation of :func:`inspect.get_annotations` "
242291"in the current Python version and follow a similar approach."
243292msgstr ""
293+ "Python 3.9 以前を使っているか、もしくは何らかの理由で :func:`inspect."
294+ "get_annotations` を使えない場合は、自分で実装する必要があります。現状の "
295+ "Python バージョンの :func:`inspect.get_annotations` の実装を確認して、同様の"
296+ "処理を実装することを推奨します。"
244297
245298#: ../../howto/annotations.rst:148
246299msgid ""
247300"In a nutshell, if you wish to evaluate a stringized annotation on an "
248301"arbitrary object ``o``:"
249302msgstr ""
303+ "すなわち、任意のオブジェクト ``o`` の文字列アノテーションを評価するには:"
250304
251305#: ../../howto/annotations.rst:151
252306msgid ""
253307"If ``o`` is a module, use ``o.__dict__`` as the ``globals`` when calling :"
254308"func:`eval`."
255309msgstr ""
310+ "``o`` がモジュールならば、 ``o.__dict__`` を ``globals`` として :func:`eval` "
311+ "を呼ぶ。"
256312
257313#: ../../howto/annotations.rst:153
258314msgid ""
259315"If ``o`` is a class, use ``sys.modules[o.__module__].__dict__`` as the "
260316"``globals``, and ``dict(vars(o))`` as the ``locals``, when calling :func:"
261317"`eval`."
262318msgstr ""
319+ "``o`` がクラスならば、 ``sys.modules[o.__module__].__dict__`` を ``globals`` "
320+ "とし、 ``dict(vars(o))`` を ``locals`` として :func:`eval` を呼ぶ。"
263321
264322#: ../../howto/annotations.rst:156
265323msgid ""
@@ -268,12 +326,17 @@ msgid ""
268326"accessing either ``o.__wrapped__`` or ``o.func`` as appropriate, until you "
269327"have found the root unwrapped function."
270328msgstr ""
329+ "``o`` が :func:`functools.update_wrapper` か :func:`functools.wraps` か :"
330+ "func:`functools.partial` でラップされた callable ならば、一番内部の関数に到達"
331+ "するまで、 ``o.__wrapped__`` か ``o.func`` のどちらかを繰り返し取得する。"
271332
272333#: ../../howto/annotations.rst:160
273334msgid ""
274335"If ``o`` is a callable (but not a class), use :attr:`o.__globals__ <function."
275336"__globals__>` as the globals when calling :func:`eval`."
276337msgstr ""
338+ "``o`` がクラス以外の callable であれば、 :attr:`o.__globals__ <function."
339+ "__globals__>` を globals として :func:`eval` を呼ぶ。"
277340
278341#: ../../howto/annotations.rst:164
279342msgid ""
@@ -283,18 +346,25 @@ msgid ""
283346"hints that require annotating with string values that specifically *can't* "
284347"be evaluated. For example:"
285348msgstr ""
349+ "しかし、必ずしもアノテーションの文字列が :func:`eval` で Python の値に変換で"
350+ "きるとは限りません。理論上どんな文字列も指定可能であり、変換できない文字列を"
351+ "型ヒントとして指定する必要がある場合が実際にあります。例えば:"
286352
287353#: ../../howto/annotations.rst:171
288354msgid ""
289355":pep:`604` union types using ``|``, before support for this was added to "
290356"Python 3.10."
291357msgstr ""
358+ "``|`` を使った :pep:`604` のユニオン型 (これが追加された Python 3.10 より前の"
359+ "バージョン)"
292360
293361#: ../../howto/annotations.rst:173
294362msgid ""
295363"Definitions that aren't needed at runtime, only imported when :const:`typing."
296364"TYPE_CHECKING` is true."
297365msgstr ""
366+ ":const:`typing.TYPE_CHECKING` が True の時だけインポートされ、実行時には必要"
367+ "ない型定義。"
298368
299369#: ../../howto/annotations.rst:176
300370msgid ""
@@ -303,49 +373,61 @@ msgid ""
303373"it's recommended to only attempt to evaluate string values when explicitly "
304374"requested to by the caller."
305375msgstr ""
376+ ":func:`eval` で上記のような値を評価しようとすると、失敗し例外が発生します。そ"
377+ "のため、アノテーションを扱うライブラリ API を作る際は、呼び出し側が明示的に要"
378+ "求したときのみ、文字列を評価することが推奨されます。"
306379
307380#: ../../howto/annotations.rst:184
308381msgid "Best Practices For ``__annotations__`` In Any Python Version"
309- msgstr ""
382+ msgstr "``__annotations__`` のベストプラクティス (全 Python バージョン共通) "
310383
311384#: ../../howto/annotations.rst:186
312385msgid ""
313386"You should avoid assigning to the ``__annotations__`` member of objects "
314387"directly. Let Python manage setting ``__annotations__``."
315388msgstr ""
389+ "オブジェクトの ``__annotations__`` 属性に直接代入することは避けるべきです。"
390+ "Python に任せましょう。 "
316391
317392#: ../../howto/annotations.rst:189
318393msgid ""
319394"If you do assign directly to the ``__annotations__`` member of an object, "
320395"you should always set it to a ``dict`` object."
321396msgstr ""
397+ "直接 ``__annotations__`` 属性に代入するなら、必ず ``dict`` オブジェクトを代入"
398+ "するべきです。"
322399
323400#: ../../howto/annotations.rst:192
324401msgid ""
325402"You should avoid accessing ``__annotations__`` directly on any object. "
326403"Instead, use :func:`annotationlib.get_annotations` (Python 3.14+) or :func:"
327404"`inspect.get_annotations` (Python 3.10+)."
328405msgstr ""
406+ "どういうオブジェクトかに関わらず、直接 ``__annotations__`` にアクセスするのは"
407+ "避けるべきです。Python 3.14 以降は :func:`annotationlib.get_annotations` 、 "
408+ "Python 3.10 以降は :func:`inspect.get_annotations` を使いましょう。"
329409
330410#: ../../howto/annotations.rst:196
331411msgid ""
332412"If you do directly access the ``__annotations__`` member of an object, you "
333413"should ensure that it's a dictionary before attempting to examine its "
334414"contents."
335415msgstr ""
416+ "直接 ``__annotations__`` メンバーにアクセスするなら、まず値が辞書であることを"
417+ "チェックしてから中身を調べるべきです。"
336418
337419#: ../../howto/annotations.rst:200
338420msgid "You should avoid modifying ``__annotations__`` dicts."
339- msgstr ""
421+ msgstr "``__annotations__`` 辞書を書き換えるのは避けるべきです。 "
340422
341423#: ../../howto/annotations.rst:202
342424msgid ""
343425"You should avoid deleting the ``__annotations__`` attribute of an object."
344- msgstr ""
426+ msgstr "``__annotations__`` 属性を削除するのは避けるべきです。 "
345427
346428#: ../../howto/annotations.rst:207
347429msgid "``__annotations__`` Quirks"
348- msgstr ""
430+ msgstr "``__annotations__`` の注意点 "
349431
350432#: ../../howto/annotations.rst:209
351433msgid ""
0 commit comments