You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enforces positional-only arguments which can now only be passed positionally.
Passing a positional-only argument by keyword now raises an `InputsError`,
**unless** the signature provides for `**kwargs`, in which case the keyword input
is absorbed by `**kwargs` — consistent with standard Python behaviour.
Copy file name to clipboardExpand all lines: docs/tutorials/tutorial.ipynb
+10-5Lines changed: 10 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1714,6 +1714,7 @@
1714
1714
"* A keyword argument is passed that is not represented in the signature (unexpected keyword argument).\n",
1715
1715
"* More arguments are passed positionally than accommodated for by the signature (excess positional arguments).\n",
1716
1716
"* A parameter is passed both positionally and as a keyword argument (got multiple values).\n",
1717
+
"* A positional-only argument is passed as a keyword argument. (Note that if a keyword argument is passed with the same name as a positional-only argument then it will be considered _valid_ if the signature provides for **kwargs (and in this case it will be received by those **kwargs), whilst if the signature does not provide for **kwargs then the error will be included in the raised `InputsError`.)\n",
1717
1718
"\n",
1718
1719
"All signature errors are advised in the error message, together with any errors relating to invalid types."
1719
1720
]
@@ -1727,8 +1728,10 @@
1727
1728
"source": [
1728
1729
"@parse\n",
1729
1730
"def pf(\n",
1730
-
" a: int,\n",
1731
+
" a: int, # positional_only\n",
1732
+
" /,\n",
1731
1733
" b: int,\n",
1734
+
" c: int,\n",
1732
1735
" *,\n",
1733
1736
" kw_a: int,\n",
1734
1737
"):\n",
@@ -1742,7 +1745,7 @@
1742
1745
"metadata": {},
1743
1746
"outputs": [],
1744
1747
"source": [
1745
-
"pf(3, \"not an int\", 5, a=3, not_a_kwarg=3)"
1748
+
"pf(3, \"not an int\", 4, 5, a=3, c=2, not_a_kwarg=3)"
0 commit comments