Skip to content

Commit

Permalink
chore(deps): add ipykernel dev dependency version 6.29.5 to run playg…
Browse files Browse the repository at this point in the history
…round notebook
  • Loading branch information
pwwang committed Jan 15, 2025
1 parent eddad39 commit ef769b8
Show file tree
Hide file tree
Showing 3 changed files with 800 additions and 166 deletions.
209 changes: 46 additions & 163 deletions playground/playground.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"from contextlib import contextmanager\n",
"\n",
"from varname import (\n",
" varname, nameof, will, argname,\n",
" varname, will, argname,\n",
" config,\n",
" ImproperUseError, VarnameRetrievingError, QualnameNonUniqueError\n",
")\n",
Expand All @@ -43,7 +43,7 @@
" try:\n",
" yield\n",
" except error as exc:\n",
" print(f'{error.__name__} raised!')\n",
" print(f'{type(exc).__name__} raised!')\n",
" else:\n",
" raise Exception(f'{error.__name__!r} NOT raised!')"
]
Expand Down Expand Up @@ -382,7 +382,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/workspaces/python-varname/varname/ignore.py:175: MaybeDecoratedFunctionWarning: You asked varname to ignore function 'wrapper', which may be decorated. If it is not intended, you may need to ignore all intermediate frames with a tuple of the function and the number of its decorators.\n",
"/home/pwwang/github/python-varname/varname/ignore.py:175: MaybeDecoratedFunctionWarning: You asked varname to ignore function 'wrapper', which may be decorated. If it is not intended, you may need to ignore all intermediate frames with a tuple of the function and the number of its decorators.\n",
" warnings.warn(\n"
]
}
Expand Down Expand Up @@ -471,12 +471,12 @@
"output_type": "stream",
"text": [
"[varname] DEBUG: >>> IgnoreList initiated <<<\n",
"[varname] DEBUG: Ignored by IgnoreModule('varname') [In 'varname' at /workspaces/python-varname/varname/core.py:105]\n",
"[varname] DEBUG: Ignored by IgnoreModule('module_all_calls') [In 'func' at /workspaces/python-varname/playground/module_all_calls.py:6]\n",
"[varname] DEBUG: Ignored by IgnoreModule('module_all_calls') [In 'func2' at /workspaces/python-varname/playground/module_all_calls.py:9]\n",
"[varname] DEBUG: Ignored by IgnoreModule('module_all_calls') [In 'func3' at /workspaces/python-varname/playground/module_all_calls.py:12]\n",
"[varname] DEBUG: Skipping (0 more to skip) [In 'func' at /tmp/ipykernel_16149/3068660293.py:4]\n",
"[varname] DEBUG: Gotcha! [In '<module>' at /tmp/ipykernel_16149/3068660293.py:7]\n"
"[varname] DEBUG: Ignored by IgnoreModule('varname') [In 'varname' at /home/pwwang/github/python-varname/varname/core.py:105]\n",
"[varname] DEBUG: Ignored by IgnoreModule('module_all_calls') [In 'func' at /home/pwwang/github/python-varname/playground/module_all_calls.py:6]\n",
"[varname] DEBUG: Ignored by IgnoreModule('module_all_calls') [In 'func2' at /home/pwwang/github/python-varname/playground/module_all_calls.py:9]\n",
"[varname] DEBUG: Ignored by IgnoreModule('module_all_calls') [In 'func3' at /home/pwwang/github/python-varname/playground/module_all_calls.py:12]\n",
"[varname] DEBUG: Skipping (0 more to skip) [In 'func' at /tmp/ipykernel_316759/3068660293.py:4]\n",
"[varname] DEBUG: Gotcha! [In '<module>' at /tmp/ipykernel_316759/3068660293.py:7]\n"
]
},
{
Expand Down Expand Up @@ -527,11 +527,11 @@
"output_type": "stream",
"text": [
"[varname] DEBUG: >>> IgnoreList initiated <<<\n",
"[varname] DEBUG: Ignored by IgnoreModule('varname') [In 'varname' at /workspaces/python-varname/varname/core.py:105]\n",
"[varname] DEBUG: Ignored by IgnoreModuleQualname('module_glob_qualname', '_func*') [In '_func' at /workspaces/python-varname/playground/module_glob_qualname.py:6]\n",
"[varname] DEBUG: Ignored by IgnoreModuleQualname('module_glob_qualname', '_func*') [In '_func2' at /workspaces/python-varname/playground/module_glob_qualname.py:9]\n",
"[varname] DEBUG: Skipping (0 more to skip) [In 'func3' at /workspaces/python-varname/playground/module_glob_qualname.py:12]\n",
"[varname] DEBUG: Gotcha! [In '<module>' at /tmp/ipykernel_16149/491507787.py:4]\n"
"[varname] DEBUG: Ignored by IgnoreModule('varname') [In 'varname' at /home/pwwang/github/python-varname/varname/core.py:105]\n",
"[varname] DEBUG: Ignored by IgnoreModuleQualname('module_glob_qualname', '_func*') [In '_func' at /home/pwwang/github/python-varname/playground/module_glob_qualname.py:6]\n",
"[varname] DEBUG: Ignored by IgnoreModuleQualname('module_glob_qualname', '_func*') [In '_func2' at /home/pwwang/github/python-varname/playground/module_glob_qualname.py:9]\n",
"[varname] DEBUG: Skipping (0 more to skip) [In 'func3' at /home/pwwang/github/python-varname/playground/module_glob_qualname.py:12]\n",
"[varname] DEBUG: Gotcha! [In '<module>' at /tmp/ipykernel_316759/491507787.py:4]\n"
]
},
{
Expand Down Expand Up @@ -614,10 +614,10 @@
"output_type": "stream",
"text": [
"[varname] DEBUG: >>> IgnoreList initiated <<<\n",
"[varname] DEBUG: Ignored by IgnoreModule('varname') [In 'varname' at /workspaces/python-varname/varname/core.py:105]\n",
"[varname] DEBUG: Skipping (0 more to skip) [In 'func' at /tmp/ipykernel_16149/2761136102.py:2]\n",
"[varname] DEBUG: Ignored by IgnoreOnlyQualname(None, '*<lambda>') [In '<lambda>' at /tmp/ipykernel_16149/2761136102.py:4]\n",
"[varname] DEBUG: Gotcha! [In '<module>' at /tmp/ipykernel_16149/2761136102.py:7]\n"
"[varname] DEBUG: Ignored by IgnoreModule('varname') [In 'varname' at /home/pwwang/github/python-varname/varname/core.py:105]\n",
"[varname] DEBUG: Skipping (0 more to skip) [In 'func' at /tmp/ipykernel_316759/2761136102.py:2]\n",
"[varname] DEBUG: Ignored by IgnoreOnlyQualname(None, '*<lambda>') [In '<lambda>' at /tmp/ipykernel_316759/2761136102.py:4]\n",
"[varname] DEBUG: Gotcha! [In '<module>' at /tmp/ipykernel_316759/2761136102.py:7]\n"
]
},
{
Expand Down Expand Up @@ -667,10 +667,10 @@
"output_type": "stream",
"text": [
"[varname] DEBUG: >>> IgnoreList initiated <<<\n",
"[varname] DEBUG: Ignored by IgnoreModule('varname') [In 'varname' at /workspaces/python-varname/varname/core.py:105]\n",
"[varname] DEBUG: Skipping (0 more to skip) [In '__init__' at /tmp/ipykernel_16149/641638691.py:8]\n",
"[varname] DEBUG: Ignored by IgnoreStdlib('/usr/local/python/3.10.13/lib/python3.10/') [In '__call__' at /home/codespace/.python/current/lib/python3.10/typing.py:957]\n",
"[varname] DEBUG: Gotcha! [In '<module>' at /tmp/ipykernel_16149/641638691.py:11]\n"
"[varname] DEBUG: Ignored by IgnoreModule('varname') [In 'varname' at /home/pwwang/github/python-varname/varname/core.py:105]\n",
"[varname] DEBUG: Skipping (0 more to skip) [In '__init__' at /tmp/ipykernel_316759/641638691.py:8]\n",
"[varname] DEBUG: Ignored by IgnoreStdlib('/home/pwwang/miniconda3/lib/python3.12/') [In '__call__' at /home/pwwang/miniconda3/lib/python3.12/typing.py:1140]\n",
"[varname] DEBUG: Gotcha! [In '<module>' at /tmp/ipykernel_316759/641638691.py:11]\n"
]
},
{
Expand Down Expand Up @@ -812,11 +812,11 @@
"output_type": "stream",
"text": [
"[varname] DEBUG: >>> IgnoreList initiated <<<\n",
"[varname] DEBUG: Ignored by IgnoreModule('varname') [In 'varname' at /workspaces/python-varname/varname/core.py:105]\n",
"[varname] DEBUG: Ignored by IgnoreDecorated('wrapper', 2) [In 'func' at /tmp/ipykernel_16149/652967550.py:2]\n",
"[varname] DEBUG: Skipping (1 more to skip) [In 'wrapper' at /tmp/ipykernel_16149/652967550.py:9]\n",
"[varname] DEBUG: Skipping (0 more to skip) [In 'func3' at /tmp/ipykernel_16149/652967550.py:18]\n",
"[varname] DEBUG: Gotcha! [In '<module>' at /tmp/ipykernel_16149/652967550.py:21]\n"
"[varname] DEBUG: Ignored by IgnoreModule('varname') [In 'varname' at /home/pwwang/github/python-varname/varname/core.py:105]\n",
"[varname] DEBUG: Ignored by IgnoreDecorated('wrapper', 2) [In 'func' at /tmp/ipykernel_316759/652967550.py:2]\n",
"[varname] DEBUG: Skipping (1 more to skip) [In 'wrapper' at /tmp/ipykernel_316759/652967550.py:9]\n",
"[varname] DEBUG: Skipping (0 more to skip) [In 'func3' at /tmp/ipykernel_316759/652967550.py:18]\n",
"[varname] DEBUG: Gotcha! [In '<module>' at /tmp/ipykernel_316759/652967550.py:21]\n"
]
},
{
Expand Down Expand Up @@ -883,8 +883,8 @@
"2 (a, b) = ('a', 'b')\n",
"3 a = ('a',)\n",
"4 (a, b, c) = ('a', 'b', 'c')\n",
"5 (a, b, x.c) = ('a', 'b', 'c')\n",
"ImproperUseError raised!\n"
"5 (a, b, x.c) = ('a', 'b', 'x.c')\n",
"TypeError raised!\n"
]
}
],
Expand All @@ -910,7 +910,7 @@
"a, (b, x.c) = function()\n",
"print(5, '(a, b, x.c) =', (a, b, x.c))\n",
"\n",
"with expect_raising(ImproperUseError):\n",
"with expect_raising((ImproperUseError, TypeError)):\n",
" a, b[0] = function()"
]
},
Expand Down Expand Up @@ -998,7 +998,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/workspaces/python-varname/varname/core.py:124: MultiTargetAssignmentWarning: Multiple targets in assignment, variable name on the very right is used. \n",
"/home/pwwang/github/python-varname/varname/core.py:124: MultiTargetAssignmentWarning: Multiple targets in assignment, variable name on the very right is used. \n",
" warnings.warn(\n"
]
}
Expand All @@ -1012,118 +1012,6 @@
"# f1 == f2 == 'f1' when varname < 0.8"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Use of `nameof`"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"execution": {
"iopub.execute_input": "2021-08-13T18:11:04.767662Z",
"iopub.status.busy": "2021-08-13T18:11:04.767117Z",
"iopub.status.idle": "2021-08-13T18:11:04.772991Z",
"shell.execute_reply": "2021-08-13T18:11:04.773352Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"x\n"
]
}
],
"source": [
"x = lambda: None\n",
"print(nameof(x))"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"Get full name of a chain of attributes"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"execution": {
"iopub.execute_input": "2021-08-13T18:11:04.778858Z",
"iopub.status.busy": "2021-08-13T18:11:04.777851Z",
"iopub.status.idle": "2021-08-13T18:11:04.797968Z",
"shell.execute_reply": "2021-08-13T18:11:04.797563Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"x.a\n",
"x.a.b\n",
"('x.a', 'x.a.b')\n",
"x.a()\n"
]
}
],
"source": [
"x.a = x\n",
"x.a.b = x\n",
"\n",
"print(nameof(x.a, vars_only=False))\n",
"print(nameof(x.a.b, vars_only=False))\n",
"print(nameof(x.a, x.a.b, vars_only=False))\n",
"print(nameof(x.a(), vars_only=False))"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"If you want to wrap `nameof`"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {
"execution": {
"iopub.execute_input": "2021-08-13T18:11:04.803768Z",
"iopub.status.busy": "2021-08-13T18:11:04.803314Z",
"iopub.status.idle": "2021-08-13T18:11:04.811178Z",
"shell.execute_reply": "2021-08-13T18:11:04.810839Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"'x'"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def nameof2(var, *more_vars):\n",
" return nameof(var, *more_vars, frame=2)\n",
"\n",
"nameof2(x)"
]
},
{
"attachments": {},
"cell_type": "markdown",
Expand All @@ -1134,7 +1022,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 22,
"metadata": {
"execution": {
"iopub.execute_input": "2021-08-13T18:11:04.816768Z",
Expand Down Expand Up @@ -1180,7 +1068,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 23,
"metadata": {
"execution": {
"iopub.execute_input": "2021-08-13T18:11:04.833103Z",
Expand Down Expand Up @@ -1240,7 +1128,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 24,
"metadata": {
"execution": {
"iopub.execute_input": "2021-08-13T18:11:04.854380Z",
Expand Down Expand Up @@ -1288,7 +1176,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 25,
"metadata": {
"execution": {
"iopub.execute_input": "2021-08-13T18:11:04.865673Z",
Expand Down Expand Up @@ -1333,7 +1221,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 26,
"metadata": {
"execution": {
"iopub.execute_input": "2021-08-13T18:11:04.881609Z",
Expand Down Expand Up @@ -1386,7 +1274,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 27,
"metadata": {
"execution": {
"iopub.execute_input": "2021-08-13T18:11:04.895641Z",
Expand All @@ -1402,7 +1290,7 @@
"'f'"
]
},
"execution_count": 30,
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -1426,7 +1314,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 28,
"metadata": {
"execution": {
"iopub.execute_input": "2021-08-13T18:11:04.907363Z",
Expand All @@ -1442,7 +1330,7 @@
"'foo'"
]
},
"execution_count": 31,
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -1466,7 +1354,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 29,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1495,7 +1383,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 30,
"metadata": {
"execution": {
"iopub.execute_input": "2021-08-13T18:11:04.919563Z",
Expand Down Expand Up @@ -1544,7 +1432,7 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 31,
"metadata": {},
"outputs": [
{
Expand All @@ -1553,7 +1441,7 @@
"['1', '2']"
]
},
"execution_count": 34,
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -1576,7 +1464,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.5 ('base')",
"display_name": "varname-wNAL0Xj7-py3.12",
"language": "python",
"name": "python3"
},
Expand All @@ -1590,12 +1478,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
},
"vscode": {
"interpreter": {
"hash": "9ed5c94d10bf621c6841991b7e31ffd0f3c8de8ec4167710459737a50edc58e4"
}
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit ef769b8

Please sign in to comment.