From 0515436f5ede204bfb224bc6bcf8f744a8a14e58 Mon Sep 17 00:00:00 2001 From: BO ZHANG Date: Sat, 16 Sep 2023 22:57:46 +0800 Subject: [PATCH] add optional and union cases --- docs/source/demo_type_annotation.ipynb | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/source/demo_type_annotation.ipynb b/docs/source/demo_type_annotation.ipynb index 258e0a0..e413869 100644 --- a/docs/source/demo_type_annotation.ipynb +++ b/docs/source/demo_type_annotation.ipynb @@ -67,6 +67,28 @@ "- Any表示任意类型" ] }, + { + "cell_type": "code", + "execution_count": 3, + "id": "3b323abd-7689-4abd-aa02-049b1de7bfcb", + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'Optional' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[3], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m x0: Optional[\u001b[38;5;28mint\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n", + "\u001b[0;31mNameError\u001b[0m: name 'Optional' is not defined" + ] + } + ], + "source": [ + "fx0: Optional[int] = None" + ] + }, { "cell_type": "markdown", "id": "4906826b-2817-4a5b-b3ac-a993fa96b315", @@ -80,7 +102,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "d93f8b14-5f88-4579-a671-1693d04ce144", "metadata": {}, "outputs": [], @@ -92,7 +114,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "14b83562-b6c6-4873-8936-ad9d0c9c0e6f", "metadata": {}, "outputs": [], -- GitLab