Conversation
mattwang44
reviewed
Sep 29, 2026
| "在某些 Python 版本中,類別實例可能會帶有 ``__annotations__`` 的屬性,但這並非" | ||
| "受支援的功能。如果你需要取得實例的註釋,可以用 :func:`type` 來存取實例的類別" | ||
| "(例如在 Python 3.14+ 中使用 " | ||
| "``annotationlib.get_annotations(type(myinstance))`` )." |
Collaborator
There was a problem hiding this comment.
Suggested change
| "``annotationlib.get_annotations(type(myinstance))`` )." | |
| "``annotationlib.get_annotations(type(myinstance))``)。" |
Comment on lines
+388
to
+390
| "你應該避免直接存取物件的 ``__annotations__`` 。請改" | ||
| "用 :func:`annotationlib.get_annotations` (Python 3.14+) " | ||
| "或 :func:`inspect.get_annotations` (Python 3.10+)." |
Collaborator
There was a problem hiding this comment.
Suggested change
| "你應該避免直接存取物件的 ``__annotations__`` 。請改" | |
| "用 :func:`annotationlib.get_annotations` (Python 3.14+) " | |
| "或 :func:`inspect.get_annotations` (Python 3.10+)." | |
| "你應該避免直接存取物件的 ``__annotations__``。請改" | |
| "用 :func:`annotationlib.get_annotations` (Python 3.14+) " | |
| "或 :func:`inspect.get_annotations` (Python 3.10+)。" |
Comment on lines
+496
to
+501
| "如果你使用的類別具有自訂的元類別,並存取該類別的 ``__annotations__`` ,你可能" | ||
| "會觀察到出乎意料的行為;請查閱 :pep:`749 <749#pep749-metaclasses>` 的例子。你" | ||
| "可以在Python 3.14+ 使用 :func:`annotationlib.get_annotations` 或者在 Python " | ||
| "3.10+ 使用 :func:`inspect.get_annotations` 來避免這些問題。在更早期的版本,你" | ||
| "可以存取類別的 :attr:`~type.__dict__` 來避免這些問題。(例如:" | ||
| "``cls.__dict__.get(‘__annotations__’, None)`` )" |
Collaborator
There was a problem hiding this comment.
Suggested change
| "如果你使用的類別具有自訂的元類別,並存取該類別的 ``__annotations__`` ,你可能" | |
| "會觀察到出乎意料的行為;請查閱 :pep:`749 <749#pep749-metaclasses>` 的例子。你" | |
| "可以在Python 3.14+ 使用 :func:`annotationlib.get_annotations` 或者在 Python " | |
| "3.10+ 使用 :func:`inspect.get_annotations` 來避免這些問題。在更早期的版本,你" | |
| "可以存取類別的 :attr:`~type.__dict__` 來避免這些問題。(例如:" | |
| "``cls.__dict__.get(‘__annotations__’, None)`` )" | |
| "如果你使用的類別具有自訂的元類別且會存取該類別的 ``__annotations__`` ,你可能" | |
| "會觀察到不預期的行為;請查閱 :pep:`749 <749#pep749-metaclasses>` 的例子。你" | |
| "可以在 Python 3.14+ 使用 :func:`annotationlib.get_annotations` 或者在 Python " | |
| "3.10+ 使用 :func:`inspect.get_annotations` 來避免這些問題。在更早期的版本,你" | |
| "可以存取類別的 :attr:`~type.__dict__` 來避免這些問題(例如:" | |
| "``cls.__dict__.get('__annotations__', None)``)。" |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolve #1241