René's URL Explorer Experiment


Title: how to correctly create a dict subclass with typing · python/typing · Discussion #1033 · GitHub

Open Graph Title: how to correctly create a dict subclass with typing · python/typing · Discussion #1033

X Title: how to correctly create a dict subclass with typing · python/typing · Discussion #1033

Description: how to correctly create a dict subclass with typing

Open Graph Description: we have a lot of classes that subclass dict for the purpose of storing keys and values in different ways, providing different ways of returning defaults, etc. I'm not able to create a custom subcla...

X Description: we have a lot of classes that subclass dict for the purpose of storing keys and values in different ways, providing different ways of returning defaults, etc. I'm not able to create a custom su...

Opengraph URL: https://github.com/python/typing/discussions/1033

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"how to correctly create a dict subclass with typing","text":"\u003cp dir=\"auto\"\u003ewe have a lot of classes that subclass \u003ccode class=\"notranslate\"\u003edict\u003c/code\u003e for the purpose of storing keys and values in different ways, providing different ways of returning defaults, etc.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eI'm not able to create a custom subclass of \u003ccode class=\"notranslate\"\u003etyping.Dict\u003c/code\u003e where all methods are accepted by mypy.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eCurrently, trying to figure out the \u003ccode class=\"notranslate\"\u003e.values()\u003c/code\u003e method.  Mypy insists that the return type here be the \u003ccode class=\"notranslate\"\u003edict_values\u003c/code\u003e type.  However this is a private Python type; while it seems to be somewhat part of \"builtins\", it's not actually there and you can't import it without typing and runtime errors.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eWhat's the correct return type for \u003ccode class=\"notranslate\"\u003edict.values()\u003c/code\u003e, or is it no longer good practice to subclass Dict and I need to instead create a wrapping object with a real dict on the inside (this would be very unfortunate and surprising?)  ?     Or am I supposed to build a custom protocol that matches dict_values somehow?   typing.ValuesView is not accepted if you are subclassing \u003ccode class=\"notranslate\"\u003eDict\u003c/code\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eexample below\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Module \u0026quot;builtins\u0026quot; has no attribute \u0026quot;dict_values\u0026quot;\nfrom builtins import dict_values  # type: ignore\n\nimport time\nfrom typing import Any\nfrom typing import cast\nfrom typing import Dict, List\nfrom typing import Tuple\nfrom typing import TypeVar\nfrom typing import ValuesView\n\n\n_KT = TypeVar(\u0026quot;_KT\u0026quot;, bound=Any)\n_VT = TypeVar(\u0026quot;_VT\u0026quot;, bound=Any)\n\n\n\nclass MyDict(Dict[_KT, _VT]):\n    \u0026quot;\u0026quot;\u0026quot;a dictionary that stores values as a two-tuple with a timestamp.\n\n    the exposed values however are those that were originally passed in.\n\n    \u0026quot;\u0026quot;\u0026quot;\n\n    def __getitem__(self, __k: _KT) -\u0026gt; _VT:\n        super_dict = cast(Dict[_KT, Tuple[_VT, float]], super())\n        try:\n            value = super_dict.__getitem__(__k)\n        except KeyError:\n            raise\n        else:\n            return value[0]\n\n    def __setitem__(self, __k: _KT, v: _VT) -\u0026gt; None:\n        super_dict = cast(Dict[_KT, Tuple[_VT, float]], super())\n        return super_dict.__setitem__(__k, (v, time.time()))\n\n    # values like a normal person - return a list\n    # Return type \u0026quot;List[_VT]\u0026quot; of \u0026quot;values\u0026quot; incompatible with return type \u0026quot;dict_values[_KT, _VT]\u0026quot; in supertype \u0026quot;dict\u0026quot;\n    # Return type \u0026quot;List[_VT]\u0026quot; of \u0026quot;values\u0026quot; incompatible with return type \u0026quot;ValuesView[_VT]\u0026quot; in supertype \u0026quot;Mapping\u0026quot;\n\n    # def values(self) -\u0026gt; List[_VT]:\n    #     super_dict = cast(Dict[_KT, Tuple[_VT, float]], super())\n    #     return [v[0] for k, v in super_dict.items()]\n\n    # try to use real ValuesView\n    # Return type \u0026quot;ValuesView[_VT]\u0026quot; of \u0026quot;values\u0026quot; incompatible with return type \u0026quot;dict_values[_KT, _VT]\u0026quot; in supertype \u0026quot;dict\u0026quot;\n\n    # def values(self) -\u0026gt; ValuesView[_VT]:\n    #     super_dict = cast(Dict[_KT, Tuple[_VT, float]], super())\n    #     return ValuesView({k: v[0] for k, v in super_dict.items()})\n\n    # try to use the dict_values mypy is claiming -\n    # not possible, because we cannot import private dict_values\n    def values(self) -\u0026gt; dict_values[_KT, _VT]:\n        super_dict = cast(Dict[_KT, Tuple[_VT, float]], super())\n        return ValuesView({k: v[0] for k, v in super_dict.items()})\n\nmd: MyDict[str, str] = MyDict()\n\n# fails, revealed type is Any, because we had to ignore type\n# on dict_values\nreveal_type(md.values())\"\u003e\u003cpre class=\"notranslate\"\u003e\u003cspan class=\"pl-c\"\u003e# Module \"builtins\" has no attribute \"dict_values\"\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003efrom\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ebuiltins\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003edict_values\u003c/span\u003e  \u003cspan class=\"pl-c\"\u003e# type: ignore\u003c/span\u003e\n\n\u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003etime\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003efrom\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003etyping\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-v\"\u003eAny\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003efrom\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003etyping\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ecast\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003efrom\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003etyping\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-v\"\u003eDict\u003c/span\u003e, \u003cspan class=\"pl-v\"\u003eList\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003efrom\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003etyping\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-v\"\u003eTuple\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003efrom\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003etyping\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-v\"\u003eTypeVar\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003efrom\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003etyping\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-v\"\u003eValuesView\u003c/span\u003e\n\n\n\u003cspan class=\"pl-s1\"\u003e_KT\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-en\"\u003eTypeVar\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003e\"_KT\"\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003ebound\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e\u003cspan class=\"pl-v\"\u003eAny\u003c/span\u003e)\n\u003cspan class=\"pl-s1\"\u003e_VT\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-en\"\u003eTypeVar\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003e\"_VT\"\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003ebound\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e\u003cspan class=\"pl-v\"\u003eAny\u003c/span\u003e)\n\n\n\n\u003cspan class=\"pl-k\"\u003eclass\u003c/span\u003e \u003cspan class=\"pl-v\"\u003eMyDict\u003c/span\u003e(\u003cspan class=\"pl-v\"\u003eDict\u003c/span\u003e[\u003cspan class=\"pl-s1\"\u003e_KT\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003e_VT\u003c/span\u003e]):\n    \u003cspan class=\"pl-s\"\u003e\"\"\"a dictionary that stores values as a two-tuple with a timestamp.\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e    the exposed values however are those that were originally passed in.\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e\u003c/span\u003e\n\u003cspan class=\"pl-s\"\u003e    \"\"\"\u003c/span\u003e\n\n    \u003cspan class=\"pl-k\"\u003edef\u003c/span\u003e \u003cspan class=\"pl-en\"\u003e__getitem__\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003e__k\u003c/span\u003e: \u003cspan class=\"pl-smi\"\u003e_KT\u003c/span\u003e) \u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-smi\"\u003e_VT\u003c/span\u003e:\n        \u003cspan class=\"pl-s1\"\u003esuper_dict\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-en\"\u003ecast\u003c/span\u003e(\u003cspan class=\"pl-v\"\u003eDict\u003c/span\u003e[\u003cspan class=\"pl-s1\"\u003e_KT\u003c/span\u003e, \u003cspan class=\"pl-v\"\u003eTuple\u003c/span\u003e[\u003cspan class=\"pl-s1\"\u003e_VT\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003efloat\u003c/span\u003e]], \u003cspan class=\"pl-en\"\u003esuper\u003c/span\u003e())\n        \u003cspan class=\"pl-k\"\u003etry\u003c/span\u003e:\n            \u003cspan class=\"pl-s1\"\u003evalue\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003esuper_dict\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003e__getitem__\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003e__k\u003c/span\u003e)\n        \u003cspan class=\"pl-k\"\u003eexcept\u003c/span\u003e \u003cspan class=\"pl-v\"\u003eKeyError\u003c/span\u003e:\n            \u003cspan class=\"pl-k\"\u003eraise\u003c/span\u003e\n        \u003cspan class=\"pl-k\"\u003eelse\u003c/span\u003e:\n            \u003cspan class=\"pl-k\"\u003ereturn\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003evalue\u003c/span\u003e[\u003cspan class=\"pl-c1\"\u003e0\u003c/span\u003e]\n\n    \u003cspan class=\"pl-k\"\u003edef\u003c/span\u003e \u003cspan class=\"pl-en\"\u003e__setitem__\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003e__k\u003c/span\u003e: \u003cspan class=\"pl-smi\"\u003e_KT\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003ev\u003c/span\u003e: \u003cspan class=\"pl-smi\"\u003e_VT\u003c/span\u003e) \u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003eNone\u003c/span\u003e:\n        \u003cspan class=\"pl-s1\"\u003esuper_dict\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-en\"\u003ecast\u003c/span\u003e(\u003cspan class=\"pl-v\"\u003eDict\u003c/span\u003e[\u003cspan class=\"pl-s1\"\u003e_KT\u003c/span\u003e, \u003cspan class=\"pl-v\"\u003eTuple\u003c/span\u003e[\u003cspan class=\"pl-s1\"\u003e_VT\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003efloat\u003c/span\u003e]], \u003cspan class=\"pl-en\"\u003esuper\u003c/span\u003e())\n        \u003cspan class=\"pl-k\"\u003ereturn\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003esuper_dict\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003e__setitem__\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003e__k\u003c/span\u003e, (\u003cspan class=\"pl-s1\"\u003ev\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003etime\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003etime\u003c/span\u003e()))\n\n    \u003cspan class=\"pl-c\"\u003e# values like a normal person - return a list\u003c/span\u003e\n    \u003cspan class=\"pl-c\"\u003e# Return type \"List[_VT]\" of \"values\" incompatible with return type \"dict_values[_KT, _VT]\" in supertype \"dict\"\u003c/span\u003e\n    \u003cspan class=\"pl-c\"\u003e# Return type \"List[_VT]\" of \"values\" incompatible with return type \"ValuesView[_VT]\" in supertype \"Mapping\"\u003c/span\u003e\n\n    \u003cspan class=\"pl-c\"\u003e# def values(self) -\u0026gt; List[_VT]:\u003c/span\u003e\n    \u003cspan class=\"pl-c\"\u003e#     super_dict = cast(Dict[_KT, Tuple[_VT, float]], super())\u003c/span\u003e\n    \u003cspan class=\"pl-c\"\u003e#     return [v[0] for k, v in super_dict.items()]\u003c/span\u003e\n\n    \u003cspan class=\"pl-c\"\u003e# try to use real ValuesView\u003c/span\u003e\n    \u003cspan class=\"pl-c\"\u003e# Return type \"ValuesView[_VT]\" of \"values\" incompatible with return type \"dict_values[_KT, _VT]\" in supertype \"dict\"\u003c/span\u003e\n\n    \u003cspan class=\"pl-c\"\u003e# def values(self) -\u0026gt; ValuesView[_VT]:\u003c/span\u003e\n    \u003cspan class=\"pl-c\"\u003e#     super_dict = cast(Dict[_KT, Tuple[_VT, float]], super())\u003c/span\u003e\n    \u003cspan class=\"pl-c\"\u003e#     return ValuesView({k: v[0] for k, v in super_dict.items()})\u003c/span\u003e\n\n    \u003cspan class=\"pl-c\"\u003e# try to use the dict_values mypy is claiming -\u003c/span\u003e\n    \u003cspan class=\"pl-c\"\u003e# not possible, because we cannot import private dict_values\u003c/span\u003e\n    \u003cspan class=\"pl-k\"\u003edef\u003c/span\u003e \u003cspan class=\"pl-en\"\u003evalues\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e) \u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003edict_values\u003c/span\u003e[\u003cspan class=\"pl-smi\"\u003e_KT\u003c/span\u003e, \u003cspan class=\"pl-smi\"\u003e_VT\u003c/span\u003e]:\n        \u003cspan class=\"pl-s1\"\u003esuper_dict\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-en\"\u003ecast\u003c/span\u003e(\u003cspan class=\"pl-v\"\u003eDict\u003c/span\u003e[\u003cspan class=\"pl-s1\"\u003e_KT\u003c/span\u003e, \u003cspan class=\"pl-v\"\u003eTuple\u003c/span\u003e[\u003cspan class=\"pl-s1\"\u003e_VT\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003efloat\u003c/span\u003e]], \u003cspan class=\"pl-en\"\u003esuper\u003c/span\u003e())\n        \u003cspan class=\"pl-k\"\u003ereturn\u003c/span\u003e \u003cspan class=\"pl-en\"\u003eValuesView\u003c/span\u003e({\u003cspan class=\"pl-s1\"\u003ek\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003ev\u003c/span\u003e[\u003cspan class=\"pl-c1\"\u003e0\u003c/span\u003e] \u003cspan class=\"pl-k\"\u003efor\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ek\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003ev\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003ein\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003esuper_dict\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eitems\u003c/span\u003e()})\n\n\u003cspan class=\"pl-s1\"\u003emd\u003c/span\u003e: \u003cspan class=\"pl-v\"\u003eMyDict\u003c/span\u003e[\u003cspan class=\"pl-smi\"\u003estr\u003c/span\u003e, \u003cspan class=\"pl-smi\"\u003estr\u003c/span\u003e] \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-en\"\u003eMyDict\u003c/span\u003e()\n\n\u003cspan class=\"pl-c\"\u003e# fails, revealed type is Any, because we had to ignore type\u003c/span\u003e\n\u003cspan class=\"pl-c\"\u003e# on dict_values\u003c/span\u003e\n\u003cspan class=\"pl-en\"\u003ereveal_type\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003emd\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003evalues\u003c/span\u003e())\u003c/pre\u003e\u003c/div\u003e","upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"\u003cp dir=\"auto\"\u003eYeah this was broken in 3.10, see here: \u003ca href=\"https://bugs.python.org/issue46399\" rel=\"nofollow\"\u003ehttps://bugs.python.org/issue46399\u003c/a\u003e\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eWe're trying to figure out some solutions!\u003c/p\u003e","upvoteCount":2,"url":"https://github.com/python/typing/discussions/1033#discussioncomment-1986298"}}}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/discussions/:number(.:format)
route-controllerdiscussions
route-actionshow
fetch-noncev2:43f4ece1-6325-4601-f0bc-8eac49b3dccf
current-catalog-service-hash9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be
request-idA68E:2A0045:3014279:3F82D40:6B002A4E
html-safe-nonce312d64ebb7a144a9ca063da4d9733d28a78809d2891ea79e7344ba5ccecf8164
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjhFOjJBMDA0NTozMDE0Mjc5OjNGODJENDA6NkIwMDJBNEUiLCJ2aXNpdG9yX2lkIjoiOTkwMDg2ODIzNjI1NjMyMzM0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac1af956115319b30cbc1a7c039cc4892c69dae941a1844c5649e524df35022843
hovercard-subject-tagdiscussion:3806199
github-keyboard-shortcutsrepository,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///discussions/show
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/typing/discussions/1033
twitter:imagehttps://opengraph.githubassets.com/8438a486224eaac7eacaabcc0801e9ccff468c933b1a4f34dcb69d21922ba7c7/python/typing/discussions/1033
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/8438a486224eaac7eacaabcc0801e9ccff468c933b1a4f34dcb69d21922ba7c7/python/typing/discussions/1033
og:image:altwe have a lot of classes that subclass dict for the purpose of storing keys and values in different ways, providing different ways of returning defaults, etc. I'm not able to create a custom subcla...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0
turbo-cache-controlno-preview
go-importgithub.com/python/typing git https://github.com/python/typing.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id24604008
octolytics-dimension-repository_nwopython/typing
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24604008
octolytics-dimension-repository_network_root_nwopython/typing
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef3f3a43ca095cdea3abbb394112e971f9fdb94fa
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/typing/discussions/1033#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftyping%2Fdiscussions%2F1033
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftyping%2Fdiscussions%2F1033
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fdiscussions%2Fshow&source=header-repo&source_repo=python%2Ftyping
Reloadhttps://github.com/python/typing/discussions/1033
Reloadhttps://github.com/python/typing/discussions/1033
Reloadhttps://github.com/python/typing/discussions/1033
pythonhttps://github.com/python
typinghttps://github.com/python/typing
Codehttps://github.com/python/typing
Issues206 (206)https://github.com/python/typing/issues
Pull requests27 (27)https://github.com/python/typing/pulls
Discussionshttps://github.com/python/typing/discussions
Actionshttps://github.com/python/typing/actions
Security and qualityhttps://github.com/python/typing/security
Insightshttps://github.com/python/typing/insights
Answered https://github.com/python/typing/discussions/1033#discussioncomment-1986298
AlexWaygoodhttps://github.com/AlexWaygood
zzzeek https://github.com/zzzeek
Q&Ahttps://github.com/python/typing/discussions/categories/q-a
how to correctly create a dict subclass with typing https://github.com/python/typing/discussions/1033#top
zzzeek https://github.com/zzzeek
Answered https://github.com/python/typing/discussions/1033#discussioncomment-1986298
AlexWaygoodhttps://github.com/AlexWaygood
Return to tophttps://github.com/python/typing/discussions/1033#top
Please reload this pagehttps://github.com/python/typing/discussions/1033
https://github.com/python/typing/discussions/1033
zzzeek https://github.com/zzzeek
Jan 17, 2022 https://github.com/python/typing/discussions/1033#discussion-3806199
AlexWaygood https://github.com/AlexWaygood
Jan 17, 2022 https://github.com/python/typing/discussions/1033#discussioncomment-1986298
https://bugs.python.org/issue46399https://bugs.python.org/issue46399
View full answer https://github.com/python/typing/discussions/1033#discussioncomment-1986298
Oldest https://github.com/python/typing/discussions/1033?sort=old
Newest https://github.com/python/typing/discussions/1033?sort=new
Top https://github.com/python/typing/discussions/1033?sort=top
Please reload this pagehttps://github.com/python/typing/discussions/1033
https://github.com/python/typing/discussions/1033
AlexWaygood https://github.com/AlexWaygood
Jan 17, 2022 https://github.com/python/typing/discussions/1033#discussioncomment-1986298
https://bugs.python.org/issue46399https://bugs.python.org/issue46399
https://github.com/zzzeek
Please reload this pagehttps://github.com/python/typing/discussions/1033
https://github.com/python/typing/discussions/1033
zzzeekhttps://github.com/zzzeek
Jan 20, 2022 https://github.com/python/typing/discussions/1033#discussioncomment-2006557
https://github.com/zzzeek
Please reload this pagehttps://github.com/python/typing/discussions/1033
https://github.com/python/typing/discussions/1033
zzzeekhttps://github.com/zzzeek
Jan 20, 2022 https://github.com/python/typing/discussions/1033#discussioncomment-2006575
https://github.com/AlexWaygood
Please reload this pagehttps://github.com/python/typing/discussions/1033
https://github.com/python/typing/discussions/1033
AlexWaygoodhttps://github.com/AlexWaygood
Jan 20, 2022 https://github.com/python/typing/discussions/1033#discussioncomment-2006604
@erictrauthttps://github.com/erictraut
https://github.com/zzzeek
Please reload this pagehttps://github.com/python/typing/discussions/1033
https://github.com/python/typing/discussions/1033
zzzeekhttps://github.com/zzzeek
Jan 20, 2022 https://github.com/python/typing/discussions/1033#discussioncomment-2006674
https://github.com/erictraut
Please reload this pagehttps://github.com/python/typing/discussions/1033
https://github.com/python/typing/discussions/1033
erictrauthttps://github.com/erictraut
Jan 20, 2022 https://github.com/python/typing/discussions/1033#discussioncomment-2009053
@zzzeekhttps://github.com/zzzeek
zzzeekhttps://github.com/zzzeek
Please reload this pagehttps://github.com/python/typing/discussions/1033
https://github.com/python/typing/discussions/1033
Please reload this pagehttps://github.com/python/typing/discussions/1033
https://github.com/python/typing/discussions/1033
zzzeek https://github.com/zzzeek
Jan 17, 2022 https://github.com/python/typing/discussions/1033#discussioncomment-1986352
https://github.com/JelleZijlstra
Please reload this pagehttps://github.com/python/typing/discussions/1033
https://github.com/python/typing/discussions/1033
JelleZijlstrahttps://github.com/JelleZijlstra
Jan 17, 2022 https://github.com/python/typing/discussions/1033#discussioncomment-1986359
https://github.com/python/typeshed/blob/master/stdlib/typing.pyi#L480https://github.com/python/typeshed/blob/master/stdlib/typing.pyi#L480
Sign up for freehttps://github.com/join?source=comment-repo
Sign in to commenthttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftyping%2Fdiscussions%2F1033
🙏 Q&A https://github.com/python/typing/discussions/categories/q-a
https://github.com/zzzeek
https://github.com/JelleZijlstra
https://github.com/erictraut
https://github.com/AlexWaygood
https://github.com/python/typing/discussions/1033
https://github.com/settings/replies?return_to=1
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.