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
Maintain original fn argument names when fn is def'ined (#1222)
Add support for a new metadata key `^:allow-unsafe-names` which can be applied to single arity functions to disable munging and generating globally safe parameter names. This enables support for using libraries such as FastAPI and others which depend on the raw Python parameter names of functions.
Copy file name to clipboardExpand all lines: docs/pyinterop.rst
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Basilisp features myriad options for interfacing with host Python code.
10
10
Name Munging
11
11
------------
12
12
13
-
Per Python's `PEP 8 naming conventions <https://www.python.org/dev/peps/pep-0008/#naming-conventions>`_, Python method and function names frequently use ``snake_case``.
13
+
Per Python's `PEP 8 naming conventions <https://www.python.org/dev/peps/pep-0008/#naming-conventions>`_, Python method and function and parameter names frequently use ``snake_case``.
14
14
Basilisp is certainly capable of reading ``snake_case`` names without any special affordance.
15
15
However, Basilisp code (like many Lisps) tends to prefer ``kebab-case`` for word separation.
16
16
@@ -22,6 +22,14 @@ When compiled, a ``kebab-case`` identifier always becomes a ``snake_case`` ident
22
22
23
23
The Basilisp compiler munges *all* unsafe Basilisp identifiers to safe Python identifiers, but other cases are unlikely to appear in standard Python interop usage.
24
24
25
+
.. note::
26
+
27
+
By default, the compiler munges function parameter names and makes them globally unique by appending a monotically increasing number suffix to support function inlining. To enable interop with Python libraries that rely on preserved parameter names, you can use the ```^:allow-unsafe-names`` metadata key to retain the (munged) parameter names. This flag only applies to single-arity Basilisp functions.
0 commit comments