@@ -14,7 +14,7 @@ msgid ""
1414msgstr ""
1515"Project-Id-Version : Python 3.11\n "
1616"Report-Msgid-Bugs-To : \n "
17- "POT-Creation-Date : 2022-12-09 16:16 +0000\n "
17+ "POT-Creation-Date : 2022-12-25 16:15 +0000\n "
1818"PO-Revision-Date : 2021-06-28 00:52+0000\n "
1919"Last-Translator : Nicolas Evangelista, 2022\n "
2020"Language-Team : Portuguese (Brazil) (https://www.transifex.com/python-doc/ "
@@ -121,20 +121,28 @@ msgid ""
121121"three arguments, for example ``getattr(o, '__annotations__', None)``."
122122msgstr ""
123123
124- #: ../../howto/annotations.rst:62
124+ #: ../../howto/annotations.rst:60
125+ msgid ""
126+ "Before Python 3.10, accessing ``__annotations__`` on a class that defines no "
127+ "annotations but that has a parent class with annotations would return the "
128+ "parent's ``__annotations__``. In Python 3.10 and newer, the child class's "
129+ "annotations will be an empty dict instead."
130+ msgstr ""
131+
132+ #: ../../howto/annotations.rst:68
125133msgid "Accessing The Annotations Dict Of An Object In Python 3.9 And Older"
126134msgstr ""
127135"Acessando O Dicionário De Anotações De Um Objeto No Python 3.9 E Nas Versões "
128136"Mais Antigas."
129137
130- #: ../../howto/annotations.rst:64
138+ #: ../../howto/annotations.rst:70
131139msgid ""
132140"In Python 3.9 and older, accessing the annotations dict of an object is much "
133141"more complicated than in newer versions. The problem is a design flaw in "
134142"these older versions of Python, specifically to do with class annotations."
135143msgstr ""
136144
137- #: ../../howto/annotations.rst:69
145+ #: ../../howto/annotations.rst:75
138146msgid ""
139147"Best practice for accessing the annotations dict of other objects--"
140148"functions, other callables, and modules--is the same as best practice for "
@@ -143,7 +151,7 @@ msgid ""
143151"``__annotations__`` attribute."
144152msgstr ""
145153
146- #: ../../howto/annotations.rst:76
154+ #: ../../howto/annotations.rst:82
147155msgid ""
148156"Unfortunately, this isn't best practice for classes. The problem is that, "
149157"since ``__annotations__`` is optional on classes, and because classes can "
@@ -152,11 +160,11 @@ msgid ""
152160"annotations dict of a *base class.* As an example::"
153161msgstr ""
154162
155- #: ../../howto/annotations.rst:92
163+ #: ../../howto/annotations.rst:98
156164msgid "This will print the annotations dict from ``Base``, not ``Derived``."
157165msgstr ""
158166
159- #: ../../howto/annotations.rst:95
167+ #: ../../howto/annotations.rst:101
160168msgid ""
161169"Your code will have to have a separate code path if the object you're "
162170"examining is a class (``isinstance(o, type)``). In that case, best practice "
@@ -166,81 +174,81 @@ msgid ""
166174"practice is to call the ``get`` method on the class dict."
167175msgstr ""
168176
169- #: ../../howto/annotations.rst:103
177+ #: ../../howto/annotations.rst:109
170178msgid ""
171179"To put it all together, here is some sample code that safely accesses the "
172180"``__annotations__`` attribute on an arbitrary object in Python 3.9 and "
173181"before::"
174182msgstr ""
175183
176- #: ../../howto/annotations.rst:112
184+ #: ../../howto/annotations.rst:118
177185msgid ""
178186"After running this code, ``ann`` should be either a dictionary or ``None``. "
179187"You're encouraged to double-check the type of ``ann`` using :func:"
180188"`isinstance` before further examination."
181189msgstr ""
182190
183- #: ../../howto/annotations.rst:117
191+ #: ../../howto/annotations.rst:123
184192msgid ""
185193"Note that some exotic or malformed type objects may not have a ``__dict__`` "
186194"attribute, so for extra safety you may also wish to use :func:`getattr` to "
187195"access ``__dict__``."
188196msgstr ""
189197
190- #: ../../howto/annotations.rst:123
198+ #: ../../howto/annotations.rst:129
191199msgid "Manually Un-Stringizing Stringized Annotations"
192200msgstr ""
193201
194- #: ../../howto/annotations.rst:125
202+ #: ../../howto/annotations.rst:131
195203msgid ""
196204"In situations where some annotations may be \" stringized\" , and you wish to "
197205"evaluate those strings to produce the Python values they represent, it "
198206"really is best to call :func:`inspect.get_annotations` to do this work for "
199207"you."
200208msgstr ""
201209
202- #: ../../howto/annotations.rst:131
210+ #: ../../howto/annotations.rst:137
203211msgid ""
204212"If you're using Python 3.9 or older, or if for some reason you can't use :"
205213"func:`inspect.get_annotations`, you'll need to duplicate its logic. You're "
206214"encouraged to examine the implementation of :func:`inspect.get_annotations` "
207215"in the current Python version and follow a similar approach."
208216msgstr ""
209217
210- #: ../../howto/annotations.rst:137
218+ #: ../../howto/annotations.rst:143
211219msgid ""
212220"In a nutshell, if you wish to evaluate a stringized annotation on an "
213221"arbitrary object ``o``:"
214222msgstr ""
215223
216- #: ../../howto/annotations.rst:140
224+ #: ../../howto/annotations.rst:146
217225msgid ""
218226"If ``o`` is a module, use ``o.__dict__`` as the ``globals`` when calling :"
219227"func:`eval`."
220228msgstr ""
221229
222- #: ../../howto/annotations.rst:142
230+ #: ../../howto/annotations.rst:148
223231msgid ""
224232"If ``o`` is a class, use ``sys.modules[o.__module__].__dict__`` as the "
225233"``globals``, and ``dict(vars(o))`` as the ``locals``, when calling :func:"
226234"`eval`."
227235msgstr ""
228236
229- #: ../../howto/annotations.rst:145
237+ #: ../../howto/annotations.rst:151
230238msgid ""
231239"If ``o`` is a wrapped callable using :func:`functools.update_wrapper`, :func:"
232240"`functools.wraps`, or :func:`functools.partial`, iteratively unwrap it by "
233241"accessing either ``o.__wrapped__`` or ``o.func`` as appropriate, until you "
234242"have found the root unwrapped function."
235243msgstr ""
236244
237- #: ../../howto/annotations.rst:149
245+ #: ../../howto/annotations.rst:155
238246msgid ""
239247"If ``o`` is a callable (but not a class), use ``o.__globals__`` as the "
240248"globals when calling :func:`eval`."
241249msgstr ""
242250
243- #: ../../howto/annotations.rst:152
251+ #: ../../howto/annotations.rst:158
244252msgid ""
245253"However, not all string values used as annotations can be successfully "
246254"turned into Python values by :func:`eval`. String values could theoretically "
@@ -249,63 +257,63 @@ msgid ""
249257"be evaluated. For example:"
250258msgstr ""
251259
252- #: ../../howto/annotations.rst:159
260+ #: ../../howto/annotations.rst:165
253261msgid ""
254262":pep:`604` union types using ``|``, before support for this was added to "
255263"Python 3.10."
256264msgstr ""
257265
258- #: ../../howto/annotations.rst:161
266+ #: ../../howto/annotations.rst:167
259267msgid ""
260268"Definitions that aren't needed at runtime, only imported when :const:`typing."
261269"TYPE_CHECKING` is true."
262270msgstr ""
263271
264- #: ../../howto/annotations.rst:164
272+ #: ../../howto/annotations.rst:170
265273msgid ""
266274"If :func:`eval` attempts to evaluate such values, it will fail and raise an "
267275"exception. So, when designing a library API that works with annotations, "
268276"it's recommended to only attempt to evaluate string values when explicitly "
269277"requested to by the caller."
270278msgstr ""
271279
272- #: ../../howto/annotations.rst:172
280+ #: ../../howto/annotations.rst:178
273281msgid "Best Practices For ``__annotations__`` In Any Python Version"
274282msgstr ""
275283
276- #: ../../howto/annotations.rst:174
284+ #: ../../howto/annotations.rst:180
277285msgid ""
278286"You should avoid assigning to the ``__annotations__`` member of objects "
279287"directly. Let Python manage setting ``__annotations__``."
280288msgstr ""
281289
282- #: ../../howto/annotations.rst:177
290+ #: ../../howto/annotations.rst:183
283291msgid ""
284292"If you do assign directly to the ``__annotations__`` member of an object, "
285293"you should always set it to a ``dict`` object."
286294msgstr ""
287295
288- #: ../../howto/annotations.rst:180
296+ #: ../../howto/annotations.rst:186
289297msgid ""
290298"If you directly access the ``__annotations__`` member of an object, you "
291299"should ensure that it's a dictionary before attempting to examine its "
292300"contents."
293301msgstr ""
294302
295- #: ../../howto/annotations.rst:184
303+ #: ../../howto/annotations.rst:190
296304msgid "You should avoid modifying ``__annotations__`` dicts."
297305msgstr ""
298306
299- #: ../../howto/annotations.rst:186
307+ #: ../../howto/annotations.rst:192
300308msgid ""
301309"You should avoid deleting the ``__annotations__`` attribute of an object."
302310msgstr ""
303311
304- #: ../../howto/annotations.rst:191
312+ #: ../../howto/annotations.rst:197
305313msgid "``__annotations__`` Quirks"
306314msgstr ""
307315
308- #: ../../howto/annotations.rst:193
316+ #: ../../howto/annotations.rst:199
309317msgid ""
310318"In all versions of Python 3, function objects lazy-create an annotations "
311319"dict if no annotations are defined on that object. You can delete the "
@@ -317,13 +325,13 @@ msgid ""
317325"guaranteed to always throw an ``AttributeError``."
318326msgstr ""
319327
320- #: ../../howto/annotations.rst:203
328+ #: ../../howto/annotations.rst:209
321329msgid ""
322330"Everything in the above paragraph also applies to class and module objects "
323331"in Python 3.10 and newer."
324332msgstr ""
325333
326- #: ../../howto/annotations.rst:206
334+ #: ../../howto/annotations.rst:212
327335msgid ""
328336"In all versions of Python 3, you can set ``__annotations__`` on a function "
329337"object to ``None``. However, subsequently accessing the annotations on that "
@@ -334,15 +342,15 @@ msgid ""
334342"set."
335343msgstr ""
336344
337- #: ../../howto/annotations.rst:214
345+ #: ../../howto/annotations.rst:220
338346msgid ""
339347"If Python stringizes your annotations for you (using ``from __future__ "
340348"import annotations``), and you specify a string as an annotation, the string "
341349"will itself be quoted. In effect the annotation is quoted *twice.* For "
342350"example::"
343351msgstr ""
344352
345- #: ../../howto/annotations.rst:225
353+ #: ../../howto/annotations.rst:231
346354msgid ""
347355"This prints ``{'a': \" 'str'\" }``. This shouldn't really be considered a "
348356"\" quirk\" ; it's mentioned here simply because it might be surprising."
0 commit comments