Repository navigation
Expand file tree
/
Copy pathannotations.po
More file actions
213 lines (161 loc) · 28.8 KB
/
Copy pathannotations.po
File metadata and controls
213 lines (161 loc) · 28.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001 Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# Danial Behzadi <[email protected]>, 2025
# Rafael Fontenelle <[email protected]>, 2025
# Revisto <[email protected]>, 2025
# Sepehr Rasouli <[email protected]>, 2026
#
msgid ""
msgstr ""
"Project-Id-Version: Python 3.14\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-10-01 14:41+0330\n"
"PO-Revision-Date: 2026-09-15 07:30+0330\n"
"Last-Translator: Sepehr Rasouli <[email protected]>, 2026\n"
"Language-Team: Persian (https://github.com/python/python-docs-fa/)\n"
"Language: fa\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 3.6\n"
msgid "Annotations Best Practices"
msgstr "بهترین شیوههای حاشیهنویسی"
msgid "Abstract"
msgstr "چکیده"
msgid "This document is designed to encapsulate the best practices for working with annotations dicts. If you write Python code that examines ``__annotations__`` on Python objects, we encourage you to follow the guidelines described below."
msgstr "این سند طراحی شده است تا بهترین شیوهها را برای کار با دیکشنریهای حاشیهنویسی در بر بگیرد. اگر کد پایتونی مینویسید که ``__annotations__`` را روی اشیای پایتون بررسی میکند، توصیه میکنیم دستورالعملهای شرحدادهشده در زیر را دنبال کنید."
msgid "The document is organized into four sections: best practices for accessing the annotations of an object in Python versions 3.10 and newer, best practices for accessing the annotations of an object in Python versions 3.9 and older, other best practices for ``__annotations__`` that apply to any Python version, and quirks of ``__annotations__``."
msgstr "این سند در چهار بخش سازماندهی شده است: بهترین شیوههای دسترسی به حاشیهنویسیهای یک شیء در نسخههای 3.10 و جدیدتر پایتون، بهترین شیوههای دسترسی به حاشیهنویسیهای یک شیءدر نسخههای 3.9 و قدیمیتر پایتون، سایر بهترین شیوهها برای ``__annotations__`` که برای همه نسخههای پایتون اعمال میشوند، و نکات خاص ``__annotations__``."
msgid "Note that this document is specifically about working with ``__annotations__``, not uses *for* annotations. If you're looking for information on how to use \"type hints\" in your code, please see the :mod:`typing` module."
msgstr "توجه داشته باشید که این سند بهطور خاص دربارهی کار با ``__annotations__`` است، نه کاربردهایی *برای* annotations. اگر به دنبال اطلاعاتی دربارهی نحوهی استفاده از «راهنمای نوع» در کد خود هستید، لطفاً ماژول :mod:`typing` را ببینید."
msgid "Accessing The Annotations Dict Of An Object In Python 3.10 And Newer"
msgstr "دسترسی به دیکشنری حاشیهنویسیهای یک شیء در پایتون 3.10 و جدیدتر"
msgid "Python 3.10 adds a new function to the standard library: :func:`inspect.get_annotations`. In Python versions 3.10 through 3.13, calling this function is the best practice for accessing the annotations dict of any object that supports annotations. This function can also \"un-stringize\" stringized annotations for you."
msgstr "پایتون 3.10 یک تابع جدید به کتابخانه استاندارد میافزاید: :func:`inspect.get_annotations`. در نسخههای 3.10 تا 3.13 پایتون، فراخوانی این تابع بهترین روش برای دسترسی به دیکشنری حاشیهنویسیهای هر شیءای است که از حاشیهنویسی پشتیبانی میکند. این تابع همچنین میتواند حاشیهنویسیهای رشتهایشده را برای شما از حالت رشتهای خارج کند (un-stringize)."
msgid "In Python 3.14, there is a new :mod:`annotationlib` module with functionality for working with annotations. This includes a :func:`annotationlib.get_annotations` function, which supersedes :func:`inspect.get_annotations`."
msgstr "در پایتون 3.14، ماژول جدید :mod:`annotationlib` با قابلیتهایی برای کار با حاشیهنویسیهاوجود دارد. این ماژول شامل یک تابع :func:`annotationlib.get_annotations` است که جایگزین :func:`inspect.get_annotations` شده است."
msgid "If for some reason :func:`inspect.get_annotations` isn't viable for your use case, you may access the ``__annotations__`` data member manually. Best practice for this changed in Python 3.10 as well: as of Python 3.10, ``o.__annotations__`` is guaranteed to *always* work on Python functions, classes, and modules. If you're certain the object you're examining is one of these three *specific* objects, you may simply use ``o.__annotations__`` to get at the object's annotations dict."
msgstr "اگر به هر دلیلی :func:`inspect.get_annotations` برای مورد استفاده شما قابلاستفاده نیست، میتوانید بهصورت دستی به عضو دادهای ``__annotations__`` دسترسی پیدا کنید. بهترین رویه برای این کار نیز در Python 3.10 تغییر کرد: از Python 3.10 به بعد، تضمین شده است که ``o.__annotations__`` *همیشه* برای توابع، کلاسها و ماژولهای پایتون کار میکند. اگر مطمئن هستید شیء مورد بررسی شما یکی از این سه شیء *خاص* است، میتوانید بهسادگی از ``o.__annotations__`` برای دسترسی به دیکشنری حاشیهنویسیهای شیء استفاده کنید."
msgid "However, other types of callables--for example, callables created by :func:`functools.partial`--may not have an ``__annotations__`` attribute defined. When accessing the ``__annotations__`` of a possibly unknown object, best practice in Python versions 3.10 and newer is to call :func:`getattr` with three arguments, for example ``getattr(o, '__annotations__', None)``."
msgstr "با این حال، سایر انواع اشیای فراخوانیپذیر—برای مثال، آنهایی که توسط :func:`functools.partial` ایجاد شدهاند—ممکن است ویژگی ``__annotations__`` تعریفشدهای نداشته باشند. هنگام دسترسی به ``__annotations__`` شیءای که ممکن است ناشناخته باشد، بهترین روش در نسخههای 3.10 و جدیدتر پایتون این است که :func:`getattr` را با ۳ آرگومان فراخوانی کنید، برای مثال ``getattr(o, '__annotations__', None)``."
msgid "Before Python 3.10, accessing ``__annotations__`` on a class that defines no annotations but that has a parent class with annotations would return the parent's ``__annotations__``. In Python 3.10 and newer, the child class's annotations will be an empty dict instead."
msgstr "پیش از پایتون 3.10، دسترسی به ``__annotations__`` در کلاسی که هیچ حاشیهنویسیایتعریف نمیکند، اما کلاس والد آن حاشیهنویسی دارد، ``__annotations__`` کلاس والد را برمیگرداند. در پایتون 3.10 و نسخههای جدیدتر، حاشیهنویسیهای کلاس فرزند در عوض یک دیکشنری خالی خواهد بود."
msgid "Accessing The Annotations Dict Of An Object In Python 3.9 And Older"
msgstr "دسترسی به دیکشنری حاشیهنویسیهامتعلق به یک شیء در پایتون 3.9 و قدیمیتر"
msgid "In Python 3.9 and older, accessing the annotations dict of an object is much more complicated than in newer versions. The problem is a design flaw in these older versions of Python, specifically to do with class annotations."
msgstr "در پایتون 3.9 و نسخههای قدیمیتر، دسترسی به دیکشنری حاشیهنویسیها برای یک شیء، بسیار پیچیدهتر از نسخههای جدیدتر است. این مشکل یک نقص طراحی در این نسخههای قدیمیتر پایتون است، بهویژه مربوط به حاشیهنویسیهای کلاس (class annotations)."
msgid "Best practice for accessing the annotations dict of other objects--functions, other callables, and modules--is the same as best practice for 3.10, assuming you aren't calling :func:`inspect.get_annotations`: you should use three-argument :func:`getattr` to access the object's ``__annotations__`` attribute."
msgstr "بهترین روش برای دسترسی به دیکشنری حاشیهنویسیهادر اشیای دیگر--توابع، سایر اشیای فراخوانیپذیر و ماژولها--همان بهترین روش برای 3.10 است، با فرض اینکه شما :func:`inspect.get_annotations` را فراخوانی نمیکنید: باید برای دسترسی به ویژگی ``__annotations__`` شیء، از :func:`getattr` با سه آرگومان استفاده کنید."
msgid "Unfortunately, this isn't best practice for classes. The problem is that, since ``__annotations__`` is optional on classes, and because classes can inherit attributes from their base classes, accessing the ``__annotations__`` attribute of a class may inadvertently return the annotations dict of a *base class.* As an example::"
msgstr "متأسفانه، این بهترین روش برای کلاسها نیست. مشکل این است که از آنجا که ``__annotations__`` در کلاسها اختیاری است و چون کلاسها میتوانند ویژگیها را از کلاسهای پایه خود به ارث ببرند، دسترسی به ویژگی ``__annotations__`` یک کلاس ممکن است ناخواسته دیکشنری حاشیهنویسیهای یک *کلاس پایه* را برگرداند. بهعنوان مثال::"
msgid ""
"class Base:\n"
" a: int = 3\n"
" b: str = 'abc'\n"
"\n"
"class Derived(Base):\n"
" pass\n"
"\n"
"print(Derived.__annotations__)"
msgstr ""
"class Base:\n"
" a: int = 3\n"
" b: str = 'abc'\n"
"\n"
"class Derived(Base):\n"
" pass\n"
"\n"
"print(Derived.__annotations__)"
msgid "This will print the annotations dict from ``Base``, not ``Derived``."
msgstr "این، دیکشنری حاشیهنویسی را از ``Base`` چاپ میکند، نه ``Derived``."
msgid "Your code will have to have a separate code path if the object you're examining is a class (``isinstance(o, type)``). In that case, best practice relies on an implementation detail of Python 3.9 and before: if a class has annotations defined, they are stored in the class's :attr:`~type.__dict__` dictionary. Since the class may or may not have annotations defined, best practice is to call the :meth:`~dict.get` method on the class dict."
msgstr "اگر شیءای که بررسی میکنید یک کلاس باشد (``isinstance(o, type)``)، کد شما باید مسیر کد جداگانهای داشته باشد. در این صورت، بهترین روش به یک جزئیات پیادهسازی در پایتون 3.9 و نسخههای پیش از آن متکی است: اگر برای کلاسی حاشیهنویسیهاییتعریف شده باشند، آنها در دیکشنری :attr:`~type.__dict__` کلاس ذخیره میشوند. از آنجا که ممکن است برای کلاس حاشیهنویسیهاییتعریف شده باشند یا نشده باشند، بهترین روش این است که متد :meth:`~dict.get` را روی دیکشنری کلاس فراخوانی کنید."
msgid "To put it all together, here is some sample code that safely accesses the ``__annotations__`` attribute on an arbitrary object in Python 3.9 and before::"
msgstr "برای جمعبندی همه موارد، در ادامه کد نمونهای آمده است که بهطور امن به ویژگی ``__annotations__`` یک شیء دلخواه در پایتون 3.9 و پیش از آن دسترسی پیدا میکند::"
msgid ""
"if isinstance(o, type):\n"
" ann = o.__dict__.get('__annotations__', None)\n"
"else:\n"
" ann = getattr(o, '__annotations__', None)"
msgstr ""
"if isinstance(o, type):\n"
" ann = o.__dict__.get('__annotations__', None)\n"
"else:\n"
" ann = getattr(o, '__annotations__', None)"
msgid "After running this code, ``ann`` should be either a dictionary or ``None``. You're encouraged to double-check the type of ``ann`` using :func:`isinstance` before further examination."
msgstr "پس از اجرای این کد، ``ann`` باید یا یک دیکشنری باشد یا ``None``. توصیه میشود پیش از بررسی بیشتر، نوع ``ann`` را با استفاده از :func:`isinstance` دوباره بررسی کنید."
msgid "Note that some exotic or malformed type objects may not have a :attr:`~type.__dict__` attribute, so for extra safety you may also wish to use :func:`getattr` to access :attr:`!__dict__`."
msgstr "توجه داشته باشید که برخی اشیای نوع غیرعادی یا نقصدار ممکن است ویژگی :attr:`~type.__dict__` را نداشته باشند، بنابراین برای احتیاط بیشتر، ممکن است بخواهید برای دسترسی به :attr:`!__dict__` از :func:`getattr` نیز استفاده کنید."
msgid "Manually Un-Stringizing Stringized Annotations"
msgstr "غیررشتهایسازی دستی حاشیهنویسیهای رشتهایشده"
msgid "In situations where some annotations may be \"stringized\", and you wish to evaluate those strings to produce the Python values they represent, it really is best to call :func:`inspect.get_annotations` to do this work for you."
msgstr "در موقعیتهایی که برخی حاشیهنویسیهاممکن است «رشتهایشده» (stringized) باشند و شما میخواهید آن رشتهها را ارزیابی کنید تا مقادیر پایتونی متناظر با آنها تولید شوند، واقعاً بهترین کار این است که :func:`inspect.get_annotations` را فراخوانی کنید تا این کار را برای شما انجام دهد."
msgid "If you're using Python 3.9 or older, or if for some reason you can't use :func:`inspect.get_annotations`, you'll need to duplicate its logic. You're encouraged to examine the implementation of :func:`inspect.get_annotations` in the current Python version and follow a similar approach."
msgstr "اگر از پایتون 3.9 یا نسخههای قدیمیتر استفاده میکنید، یا اگر به هر دلیلی نمیتوانید از :func:`inspect.get_annotations` استفاده کنید، باید همان منطق را پیادهسازی کنید. به شما توصیه میشود پیادهسازی :func:`inspect.get_annotations` را در نسخهی فعلی پایتون بررسی کنید و رویکرد مشابهی را دنبال کنید."
msgid "In a nutshell, if you wish to evaluate a stringized annotation on an arbitrary object ``o``:"
msgstr "بهطور خلاصه، اگر میخواهید یک حاشیهنویسی رشتهشده (stringized annotation) را روی یک شیء دلخواه ``o`` ارزیابی کنید:"
msgid "If ``o`` is a module, use ``o.__dict__`` as the ``globals`` when calling :func:`eval`."
msgstr "اگر ``o`` یک ماژول باشد، از ``o.__dict__`` بهعنوان ``globals`` هنگام فراخوانی :func:`eval` استفاده کنید."
msgid "If ``o`` is a class, use ``sys.modules[o.__module__].__dict__`` as the ``globals``, and ``dict(vars(o))`` as the ``locals``, when calling :func:`eval`."
msgstr "اگر ``o`` یک کلاس باشد، هنگام فراخوانی :func:`eval`، از ``sys.modules[o.__module__].__dict__`` بهعنوان ``globals`` و از ``dict(vars(o))`` بهعنوان ``locals`` استفاده کنید."
msgid "If ``o`` is a wrapped callable using :func:`functools.update_wrapper`, :deco:`functools.wraps`, or :func:`functools.partial`, iteratively unwrap it by accessing either ``o.__wrapped__`` or ``o.func`` as appropriate, until you have found the root unwrapped function."
msgstr "اگر ``o`` یک فراخوانیپذیر پوششیشده با استفاده از :func:`functools.update_wrapper`، :deco:`functools.wraps` یا :func:`functools.partial` باشد، آن را بهصورت تکراری با دسترسی به ``o.__wrapped__`` یا ``o.func`` بسته به مورد از پوشش خارج کنید، تا تابع ریشهای بدون پوشش را پیدا کنید."
msgid "If ``o`` is a callable (but not a class), use :attr:`o.__globals__ <function.__globals__>` as the globals when calling :func:`eval`."
msgstr "اگر ``o`` فراخوانیپذیر باشد (اما کلاس نباشد)، هنگام فراخوانی :func:`eval` از :attr:`o.__globals__ <function.__globals__>` بهعنوان سراسریها استفاده کنید."
msgid "However, not all string values used as annotations can be successfully turned into Python values by :func:`eval`. String values could theoretically contain any valid string, and in practice there are valid use cases for type hints that require annotating with string values that specifically *can't* be evaluated. For example:"
msgstr "با این حال، نمیتوان همهی مقادیر رشتهای را که بهعنوان حاشیهنویسی استفاده میشوند، با موفقیت بهوسیلهی :func:`eval` به مقادیر پایتون تبدیل کرد. مقادیر رشتهای از نظر تئوری میتوانند شامل هر رشتهی معتبری باشند و در عمل موارد استفادهی معتبری برای راهنماییهای نوع وجود دارد که مستلزم حاشیهنویسی با مقادیری رشتهای هستند که مشخصاً *نمیتوانند* ارزیابی شوند. برای مثال:"
msgid ":pep:`604` union types using ``|``, before support for this was added to Python 3.10."
msgstr "انواع اجتماعی (union types) :pep:`604` با استفاده از ``|``، پیش از آنکه پشتیبانی از این قابلیت به Python 3.10 اضافه شود."
msgid "Definitions that aren't needed at runtime, only imported when :const:`typing.TYPE_CHECKING` is true."
msgstr "تعریفهایی که در رانتایم نیازی به آنها نیست و فقط زمانی ایمپورت میشوند که :const:`typing.TYPE_CHECKING` درست باشد."
msgid "If :func:`eval` attempts to evaluate such values, it will fail and raise an exception. So, when designing a library API that works with annotations, it's recommended to only attempt to evaluate string values when explicitly requested to by the caller."
msgstr "اگر :func:`eval` سعی در ارزیابی چنین مقادیری داشته باشد، شکست خواهد خورد و استثنایی پرتاب خواهد کرد. بنابراین، هنگام طراحی API یک کتابخانه که با حاشیهنویسیها کار میکند، توصیه میشود تنها زمانی برای ارزیابی مقادیر رشتهای اقدام کنید که فراخواننده بهصراحت این کار را درخواست کرده باشد."
msgid "Best Practices For ``__annotations__`` In Any Python Version"
msgstr "بهترین شیوهها برای ``__annotations__`` در هر نسخهای از پایتون"
msgid "You should avoid assigning to the ``__annotations__`` member of objects directly. Let Python manage setting ``__annotations__``."
msgstr "باید از انتساب مستقیم به عضو ``__annotations__`` شیءها خودداری کنید. اجازه دهید پایتون تنظیم ``__annotations__`` را مدیریت کند."
msgid "If you do assign directly to the ``__annotations__`` member of an object, you should always set it to a ``dict`` object."
msgstr "اگر مستقیماً به عضو ``__annotations__`` یک شیء انتساب میدهید، باید همیشه آن را روی یک شیء ``dict`` تنظیم کنید."
msgid "You should avoid accessing ``__annotations__`` directly on any object. Instead, use :func:`annotationlib.get_annotations` (Python 3.14+) or :func:`inspect.get_annotations` (Python 3.10+)."
msgstr "باید از دسترسی مستقیم به ``__annotations__`` روی هر شیء اجتناب کنید. بهجای آن، از :func:`annotationlib.get_annotations` (پایتون 3.14+) یا :func:`inspect.get_annotations` (پایتون 3.10+) استفاده کنید."
msgid "If you do directly access the ``__annotations__`` member of an object, you should ensure that it's a dictionary before attempting to examine its contents."
msgstr "اگر مستقیماً به عضو ``__annotations__`` یک شیء دسترسی دارید، باید پیش از تلاش برای بررسی محتوای آن، اطمینان حاصل کنید که یک دیکشنری است."
msgid "You should avoid modifying ``__annotations__`` dicts."
msgstr "شما باید از تغییر دیکشنریهای ``__annotations__`` خودداری کنید."
msgid "You should avoid deleting the ``__annotations__`` attribute of an object."
msgstr "شما باید از حذف ویژگی ``__annotations__`` یک شیء خودداری کنید."
msgid "``__annotations__`` Quirks"
msgstr "رفتارهای عجیب ``__annotations__``"
msgid "In all versions of Python 3, function objects lazy-create an annotations dict if no annotations are defined on that object. You can delete the ``__annotations__`` attribute using ``del fn.__annotations__``, but if you then access ``fn.__annotations__`` the object will create a new empty dict that it will store and return as its annotations. Deleting the annotations on a function before it has lazily created its annotations dict will throw an ``AttributeError``; using ``del fn.__annotations__`` twice in a row is guaranteed to always throw an ``AttributeError``."
msgstr "در تمام نسخههای Python 3، اشیای تابع اگر هیچیک از حاشیهنویسیها برای آنها تعریف نشده باشد، یک دیکشنری حاشیهنویسیها را بهصورت تنبل (lazy-create) ایجاد میکنند. شما میتوانید ویژگی ``__annotations__`` را با استفاده از ``del fn.__annotations__`` حذف کنید، اما اگر سپس به ``fn.__annotations__`` دسترسی پیدا کنید، شیء یک دیکشنری خالی جدید ایجاد میکند که آن را ذخیره میکند و بهعنوان حاشیهنویسیهای خود بازمیگرداند. حذف حاشیهنویسیهای یک تابع پیش از آنکه دیکشنری حاشیهنویسیهای خود را بهصورت تنبل ایجاد کرده باشد، یک ``AttributeError`` را پرتاب میکند؛ تضمین میشود که استفاده از ``del fn.__annotations__`` دو بار پشت سر هم، همیشه یک ``AttributeError`` را پرتاب کند."
msgid "Everything in the above paragraph also applies to class and module objects in Python 3.10 and newer."
msgstr "همه موارد پاراگراف بالا، در پایتون 3.10 و نسخههای جدیدتر، برای اشیای کلاس و ماژول نیز اعمال میشود."
msgid "In all versions of Python 3, you can set ``__annotations__`` on a function object to ``None``. However, subsequently accessing the annotations on that object using ``fn.__annotations__`` will lazy-create an empty dictionary as per the first paragraph of this section. This is *not* true of modules and classes, in any Python version; those objects permit setting ``__annotations__`` to any Python value, and will retain whatever value is set."
msgstr "در همه نسخههای پایتون 3، میتوانید ``__annotations__`` را روی یک شیء تابع به ``None`` تنظیم کنید. با این حال، دسترسی بعدی به حاشیهنویسیهای آن شیء با استفاده از ``fn.__annotations__``، مطابق پاراگراف اول این بخش، یک دیکشنری خالی را بهصورت تنبل ایجاد میکند. این موضوع در هیچ نسخهای از پایتون برای ماژولها و کلاسها *صادق نیست*؛ آن اشیاء اجازه میدهند ``__annotations__`` را به هر مقدار پایتون تنظیم کنید، و هر مقداری را که تنظیم شده باشد حفظ میکنند."
msgid "If Python stringizes your annotations for you (using ``from __future__ import annotations``), and you specify a string as an annotation, the string will itself be quoted. In effect the annotation is quoted *twice.* For example::"
msgstr "اگر پایتون حاشیهنویسیهای شمارا برایتان به رشته تبدیل کند (با استفاده از ``from __future__ import annotations``) و شما یک رشته را بهعنوان حاشیهنویسی مشخص کنید، خود رشته داخل علامت نقلقول قرار خواهد گرفت. در عمل، حاشیهنویسی داخل علامت نقلقول قرار میگیرد، *دو بار.* برای مثال::"
msgid ""
"from __future__ import annotations\n"
"def foo(a: \"str\"): pass\n"
"\n"
"print(foo.__annotations__)"
msgstr ""
"from __future__ import annotations\n"
"def foo(a: \"str\"): pass\n"
"\n"
"print(foo.__annotations__)"
msgid "This prints ``{'a': \"'str'\"}``. This shouldn't really be considered a \"quirk\"; it's mentioned here simply because it might be surprising."
msgstr "این ``{'a': \"'str'\"}`` را چاپ میکند. این واقعاً نباید یک «رفتار عجیب» تلقی شود؛ اینجا صرفاً به این دلیل ذکر شده است که ممکن است غافلگیرکننده باشد."
msgid "If you use a class with a custom metaclass and access ``__annotations__`` on the class, you may observe unexpected behavior; see :pep:`749 <749#pep749-metaclasses>` for some examples. You can avoid these quirks by using :func:`annotationlib.get_annotations` on Python 3.14+ or :func:`inspect.get_annotations` on Python 3.10+. On earlier versions of Python, you can avoid these bugs by accessing the annotations from the class's :attr:`~type.__dict__` (for example, ``cls.__dict__.get('__annotations__', None)``)."
msgstr "اگر از کلاسی با فراکلاس سفارشی استفاده کنید و به ``__annotations__`` کلاس دسترسی پیدا کنید، ممکن است رفتار غیرمنتظرهای را مشاهده کنید؛ برای مشاهده چند مثال، :pep:`749 <749#pep749-metaclasses>` را ببینید. میتوانید با استفاده از :func:`annotationlib.get_annotations` در پایتون 3.14+ یا :func:`inspect.get_annotations` در پایتون 3.10+ از این رفتارهای عجیب اجتناب کنید. در نسخههای پیشین پایتون، میتوانید با دسترسی به حاشیهنویسیها از طریق :attr:`~type.__dict__` کلاس، از این اشکالها اجتناب کنید (برای مثال، ``cls.__dict__.get('__annotations__', None)``)."
msgid "In some versions of Python, instances of classes may have an ``__annotations__`` attribute. However, this is not supported functionality. If you need the annotations of an instance, you can use :func:`type` to access its class (for example, ``annotationlib.get_annotations(type(myinstance))`` on Python 3.14+)."
msgstr "در برخی نسخههای پایتون، نمونههای کلاسها ممکن است دارای ویژگی ``__annotations__`` باشند. با این حال، این یک قابلیت پشتیبانیشده نیست. اگر به حاشیهنویسیهای یک نمونهنیاز دارید، میتوانید از :func:`type` برای دسترسی به کلاس آن استفاده کنید (برای مثال، ``annotationlib.get_annotations(type(myinstance))`` در پایتون 3.14+)."
#~ msgid "author"
#~ msgstr "نویسنده"
#~ msgid "Larry Hastings"
#~ msgstr "لری هیستینگز"