77msgstr ""
88"Project-Id-Version :Python 3.11\n "
99"Report-Msgid-Bugs-To :\n "
10- "POT-Creation-Date :2022-06-03 00:13 +0000\n "
10+ "POT-Creation-Date :2022-12-25 00:16 +0000\n "
1111"PO-Revision-Date :YEAR-MO-DA HO:MI+ZONE\n "
1212"Last-Translator :FULL NAME <EMAIL@ADDRESS>\n "
1313"Language-Team :Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
@@ -91,18 +91,26 @@ msgid ""
9191"three arguments, for example ``getattr(o, '__annotations__', None)``."
9292msgstr ""
9393
94- #: ../../howto/annotations.rst:62
94+ #: ../../howto/annotations.rst:60
95+ msgid ""
96+ "Before Python 3.10, accessing ``__annotations__`` on a class that defines no "
97+ "annotations but that has a parent class with annotations would return the "
98+ "parent's ``__annotations__``. In Python 3.10 and newer, the child class's "
99+ "annotations will be an empty dict instead."
100+ msgstr ""
101+
102+ #: ../../howto/annotations.rst:68
95103msgid "Accessing The Annotations Dict Of An Object In Python 3.9 And Older"
96104msgstr ""
97105
98- #: ../../howto/annotations.rst:64
106+ #: ../../howto/annotations.rst:70
99107msgid ""
100108"In Python 3.9 and older, accessing the annotations dict of an object is much "
101109"more complicated than in newer versions. The problem is a design flaw in "
102110"these older versions of Python, specifically to do with class annotations."
103111msgstr ""
104112
105- #: ../../howto/annotations.rst:69
113+ #: ../../howto/annotations.rst:75
106114msgid ""
107115"Best practice for accessing the annotations dict of other objects--"
108116"functions, other callables, and modules--is the same as best practice for "
@@ -111,7 +119,7 @@ msgid ""
111119"``__annotations__`` attribute."
112120msgstr ""
113121
114- #: ../../howto/annotations.rst:76
122+ #: ../../howto/annotations.rst:82
115123msgid ""
116124"Unfortunately, this isn't best practice for classes. The problem is that, "
117125"since ``__annotations__`` is optional on classes, and because classes can "
@@ -120,11 +128,11 @@ msgid ""
120128"annotations dict of a *base class.* As an example::"
121129msgstr ""
122130
123- #: ../../howto/annotations.rst:92
131+ #: ../../howto/annotations.rst:98
124132msgid "This will print the annotations dict from ``Base``, not ``Derived``."
125133msgstr ""
126134
127- #: ../../howto/annotations.rst:95
135+ #: ../../howto/annotations.rst:101
128136msgid ""
129137"Your code will have to have a separate code path if the object you're "
130138"examining is a class (``isinstance(o, type)``). In that case, best practice "
@@ -134,81 +142,81 @@ msgid ""
134142"practice is to call the ``get`` method on the class dict."
135143msgstr ""
136144
137- #: ../../howto/annotations.rst:103
145+ #: ../../howto/annotations.rst:109
138146msgid ""
139147"To put it all together, here is some sample code that safely accesses the "
140148"``__annotations__`` attribute on an arbitrary object in Python 3.9 and "
141149"before::"
142150msgstr ""
143151
144- #: ../../howto/annotations.rst:112
152+ #: ../../howto/annotations.rst:118
145153msgid ""
146154"After running this code, ``ann`` should be either a dictionary or ``None``. "
147155"You're encouraged to double-check the type of ``ann`` using :func:"
148156"`isinstance` before further examination."
149157msgstr ""
150158
151- #: ../../howto/annotations.rst:117
159+ #: ../../howto/annotations.rst:123
152160msgid ""
153161"Note that some exotic or malformed type objects may not have a ``__dict__`` "
154162"attribute, so for extra safety you may also wish to use :func:`getattr` to "
155163"access ``__dict__``."
156164msgstr ""
157165
158- #: ../../howto/annotations.rst:123
166+ #: ../../howto/annotations.rst:129
159167msgid "Manually Un-Stringizing Stringized Annotations"
160168msgstr ""
161169
162- #: ../../howto/annotations.rst:125
170+ #: ../../howto/annotations.rst:131
163171msgid ""
164172"In situations where some annotations may be\" stringized\" , and you wish to "
165173"evaluate those strings to produce the Python values they represent, it "
166174"really is best to call :func:`inspect.get_annotations` to do this work for "
167175"you."
168176msgstr ""
169177
170- #: ../../howto/annotations.rst:131
178+ #: ../../howto/annotations.rst:137
171179msgid ""
172180"If you're using Python 3.9 or older, or if for some reason you can't use :"
173181"func:`inspect.get_annotations`, you'll need to duplicate its logic. You're "
174182"encouraged to examine the implementation of :func:`inspect.get_annotations` "
175183"in the current Python version and follow a similar approach."
176184msgstr ""
177185
178- #: ../../howto/annotations.rst:137
186+ #: ../../howto/annotations.rst:143
179187msgid ""
180188"In a nutshell, if you wish to evaluate a stringized annotation on an "
181189"arbitrary object ``o``:"
182190msgstr ""
183191
184- #: ../../howto/annotations.rst:140
192+ #: ../../howto/annotations.rst:146
185193msgid ""
186194"If ``o`` is a module, use ``o.__dict__`` as the ``globals`` when calling :"
187195"func:`eval`."
188196msgstr ""
189197
190- #: ../../howto/annotations.rst:142
198+ #: ../../howto/annotations.rst:148
191199msgid ""
192200"If ``o`` is a class, use ``sys.modules[o.__module__].__dict__`` as the "
193201"``globals``, and ``dict(vars(o))`` as the ``locals``, when calling :func:"
194202"`eval`."
195203msgstr ""
196204
197- #: ../../howto/annotations.rst:145
205+ #: ../../howto/annotations.rst:151
198206msgid ""
199207"If ``o`` is a wrapped callable using :func:`functools.update_wrapper`, :func:"
200208"`functools.wraps`, or :func:`functools.partial`, iteratively unwrap it by "
201209"accessing either ``o.__wrapped__`` or ``o.func`` as appropriate, until you "
202210"have found the root unwrapped function."
203211msgstr ""
204212
205- #: ../../howto/annotations.rst:149
213+ #: ../../howto/annotations.rst:155
206214msgid ""
207215"If ``o`` is a callable (but not a class), use ``o.__globals__`` as the "
208216"globals when calling :func:`eval`."
209217msgstr ""
210218
211- #: ../../howto/annotations.rst:152
219+ #: ../../howto/annotations.rst:158
212220msgid ""
213221"However, not all string values used as annotations can be successfully "
214222"turned into Python values by :func:`eval`. String values could theoretically "
@@ -217,63 +225,63 @@ msgid ""
217225"be evaluated. For example:"
218226msgstr ""
219227
220- #: ../../howto/annotations.rst:159
228+ #: ../../howto/annotations.rst:165
221229msgid ""
222230":pep:`604` union types using ``|``, before support for this was added to "
223231"Python 3.10."
224232msgstr ""
225233
226- #: ../../howto/annotations.rst:161
234+ #: ../../howto/annotations.rst:167
227235msgid ""
228236"Definitions that aren't needed at runtime, only imported when :const:`typing."
229237"TYPE_CHECKING` is true."
230238msgstr ""
231239
232- #: ../../howto/annotations.rst:164
240+ #: ../../howto/annotations.rst:170
233241msgid ""
234242"If :func:`eval` attempts to evaluate such values, it will fail and raise an "
235243"exception. So, when designing a library API that works with annotations, "
236244"it's recommended to only attempt to evaluate string values when explicitly "
237245"requested to by the caller."
238246msgstr ""
239247
240- #: ../../howto/annotations.rst:172
248+ #: ../../howto/annotations.rst:178
241249msgid "Best Practices For ``__annotations__`` In Any Python Version"
242250msgstr ""
243251
244- #: ../../howto/annotations.rst:174
252+ #: ../../howto/annotations.rst:180
245253msgid ""
246254"You should avoid assigning to the ``__annotations__`` member of objects "
247255"directly. Let Python manage setting ``__annotations__``."
248256msgstr ""
249257
250- #: ../../howto/annotations.rst:177
258+ #: ../../howto/annotations.rst:183
251259msgid ""
252260"If you do assign directly to the ``__annotations__`` member of an object, "
253261"you should always set it to a ``dict`` object."
254262msgstr ""
255263
256- #: ../../howto/annotations.rst:180
264+ #: ../../howto/annotations.rst:186
257265msgid ""
258266"If you directly access the ``__annotations__`` member of an object, you "
259267"should ensure that it's a dictionary before attempting to examine its "
260268"contents."
261269msgstr ""
262270
263- #: ../../howto/annotations.rst:184
271+ #: ../../howto/annotations.rst:190
264272msgid "You should avoid modifying ``__annotations__`` dicts."
265273msgstr ""
266274
267- #: ../../howto/annotations.rst:186
275+ #: ../../howto/annotations.rst:192
268276msgid ""
269277"You should avoid deleting the ``__annotations__`` attribute of an object."
270278msgstr ""
271279
272- #: ../../howto/annotations.rst:191
280+ #: ../../howto/annotations.rst:197
273281msgid "``__annotations__`` Quirks"
274282msgstr ""
275283
276- #: ../../howto/annotations.rst:193
284+ #: ../../howto/annotations.rst:199
277285msgid ""
278286"In all versions of Python 3, function objects lazy-create an annotations "
279287"dict if no annotations are defined on that object. You can delete the "
@@ -285,13 +293,13 @@ msgid ""
285293"guaranteed to always throw an ``AttributeError``."
286294msgstr ""
287295
288- #: ../../howto/annotations.rst:203
296+ #: ../../howto/annotations.rst:209
289297msgid ""
290298"Everything in the above paragraph also applies to class and module objects "
291299"in Python 3.10 and newer."
292300msgstr ""
293301
294- #: ../../howto/annotations.rst:206
302+ #: ../../howto/annotations.rst:212
295303msgid ""
296304"In all versions of Python 3, you can set ``__annotations__`` on a function "
297305"object to ``None``. However, subsequently accessing the annotations on that "
@@ -302,15 +310,15 @@ msgid ""
302310"set."
303311msgstr ""
304312
305- #: ../../howto/annotations.rst:214
313+ #: ../../howto/annotations.rst:220
306314msgid ""
307315"If Python stringizes your annotations for you (using ``from __future__ "
308316"import annotations``), and you specify a string as an annotation, the string "
309317"will itself be quoted. In effect the annotation is quoted *twice.* For "
310318"example::"
311319msgstr ""
312320
313- #: ../../howto/annotations.rst:225
321+ #: ../../howto/annotations.rst:231
314322msgid ""
315323"This prints ``{'a':\" 'str'\" }``. This shouldn't really be considered a "
316324"\" quirk\" ; it's mentioned here simply because it might be surprising."