| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -757,9 +757,19 @@ This section discusses some specific operations in more detail. | |
| should be allowed for TypedDict objects, for an arbitrary expression | ||
| ``e`` with type ``str``. The motivation is that these are safe and | ||
| can be useful for introspecting TypedDict objects. The static type | ||
| of ``d.get(e)`` should be the union of all possible item types in ``d`` | ||
| if the string value of ``e`` cannot be determined statically. | ||
| (This simplifies to ``object`` if ``d`` is :term:`open`.) | ||
| of ``d.get(e)`` depends on what is known about the value of ``e``: | ||
|
|
||
| - If ``e`` is a string literal equal to a defined key of ``d``, the | ||
| return type is the declared type of that key combined with ``None`` | ||
| for non-required keys. For required keys, type checkers may return | ||
| either the declared type ``T`` or ``T | None``. | ||
| - If ``e`` is a string literal that is **not** a defined key of ``d``, | ||
| no error should be reported. The return type is the union of all | ||
| possible value types in ``d`` combined with ``None``. | ||
| - If the string value of ``e`` cannot be determined statically, the | ||
| return type is the union of all possible value types in ``d`` | ||
| combined with ``None``. (This simplifies to ``object | None`` if | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhich is just object.
Sorry, something went wrong.
All reactions
|
||
| ``d`` is :term:`open`.) | ||
|
|
||
| * ``clear()`` is not safe on :term:`open` TypedDicts since it could remove required items, some of which | ||
| may not be directly visible because of :term:`structural` | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhy leave this as an option? If the key is required, then it must be present so .get() can't return None.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.