{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "4f8ce941-1492-4d4e-8ab5-70d733fe891a",
   "metadata": {},
   "outputs": [],
   "source": [
    "%config ZMQInteractiveShell.ast_node_interactivity=\"last_expr_or_assign\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "721ec705-0c65-4bfb-9809-7ed8bc534186",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Assignment statement without a semicolon\n",
    "x = 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "de50e495-17e5-41cc-94bd-565757555d7e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Assignment statement with a semicolon\n",
    "x = 1;\n",
    "x = 1;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "39e31201-23da-44eb-8684-41bba3663991",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Augmented assignment without a semicolon\n",
    "x += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "6b73d3dd-c73a-4697-9e97-e109a6c1fbab",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Augmented assignment without a semicolon\n",
    "x += 1;\n",
    "x += 1;  # comment\n",
    "# comment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "2a3e5b86-aa5b-46ba-b9c6-0386d876f58c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Multiple assignment without a semicolon\n",
    "x = y = 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "07f89e51-9357-4cfb-8fc5-76fb75e35949",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Multiple assignment with a semicolon\n",
    "x = y = 1;\n",
    "x = y = 1;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "c22b539d-473e-48f8-a236-625e58c47a00",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Tuple unpacking without a semicolon\n",
    "x, y = 1, 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "12c87940-a0d5-403b-a81c-7507eb06dc7e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Tuple unpacking with a semicolon (irrelevant)\n",
    "x, y = 1, 2;\n",
    "x, y = 1, 2;  # comment\n",
    "# comment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "5a768c76-6bc4-470c-b37e-8cc14bc6caf4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Annotated assignment statement without a semicolon\n",
    "x: int = 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "21bfda82-1a9a-4ba1-9078-74ac480804b5",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Annotated assignment statement without a semicolon\n",
    "x: int = 1;\n",
    "x: int = 1;  # comment\n",
    "# comment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "09929999-ff29-4d10-ad2b-e665af15812d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Assignment expression without a semicolon\n",
    "(x := 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "32a83217-1bad-4f61-855e-ffcdb119c763",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Assignment expression with a semicolon\n",
    "(x := 1);\n",
    "(x := 1);  # comment\n",
    "# comment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "61b81865-277e-4964-b03e-eb78f1f318eb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = 1\n",
    "# Expression without a semicolon\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "974c29be-67e1-4000-95fa-6ca118a63bad",
   "metadata": {},
   "outputs": [],
   "source": [
    "x = 1\n",
    "# Expression with a semicolon\n",
    "x;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "cfeb1757-46d6-4f13-969f-a283b6d0304f",
   "metadata": {},
   "outputs": [],
   "source": [
    "class Point:\n",
    "    def __init__(self, x, y):\n",
    "        self.x = x\n",
    "        self.y = y\n",
    "\n",
    "\n",
    "p = Point(0, 0);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "2ee7f1a5-ccfe-4004-bfa4-ef834a58da97",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Assignment statement where the left is an attribute access doesn't\n",
    "# print the value.\n",
    "p.x = 1;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "3e49370a-048b-474d-aa0a-3d1d4a73ad37",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = {}\n",
    "\n",
    "# Neither does the subscript node\n",
    "data[\"foo\"] = 1;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "d594bdd3-eaa9-41ef-8cda-cf01bc273b2d",
   "metadata": {},
   "outputs": [],
   "source": [
    "if (x := 1):\n",
    "    # It should be the top level statement\n",
    "    x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "e532f0cf-80c7-42b7-8226-6002fcf74fb6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Parentheses with comments\n",
    "(\n",
    "    x := 1  # comment\n",
    ")  # comment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "473c5d62-871b-46ed-8a34-27095243f462",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Parentheses with comments\n",
    "(\n",
    "    x := 1  # comment\n",
    ");  # comment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "8c3c2361-f49f-45fe-bbe3-7e27410a8a86",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Hello world!'"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"\"\"Hello world!\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "23dbe9b5-3f68-4890-ab2d-ab0dbfd0712a",
   "metadata": {},
   "outputs": [],
   "source": [
    "\"\"\"Hello world!\"\"\";  # comment\n",
    "# comment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "3ce33108-d95d-4c70-83d1-0d4fd36a2951",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'x = 1'"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = 1\n",
    "f\"x = {x}\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "654a4a67-de43-4684-824a-9451c67db48f",
   "metadata": {},
   "outputs": [],
   "source": [
    "x = 1\n",
    "f\"x = {x}\";\n",
    "f\"x = {x}\";  # comment\n",
    "# comment"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python (ruff-playground)",
   "language": "python",
   "name": "ruff-playground"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
