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
In this example, the `TYPE_CHECKING` constant is set to `False` by default. When performing static type checking, you can set `TYPE_CHECKING` to `True` to include the type hints and imports. This allows you to use type hints and perform static type checking without requiring the `typing` module at runtime.
65
+
66
+
67
+
## Positional and keyword parameter types
68
+
69
+
Based on [PEP-570](https://peps.python.org/pep-0570/)
70
+
71
+
72
+
While MicroPython does not support the full range of Python's function parameter types at runtime ,
73
+
it does make sense to support some of them in static type checking.
74
+
75
+
In type stubs the following function signature is used to indicate the types of parameters:
- All parameters left of the `/` are treated as positional-only.
88
+
- If `/` is not specified in the function definition, that function does not accept any positional-only arguments.
89
+
- The logic around optional values for positional-only parameters remains the same as for positional-or-keyword parameters.
90
+
- Once a positional-only parameter is specified with a default, the following positional-only and positional-or-keyword parameters need to have defaults as well.
91
+
- Positional-only parameters which do not have default values are required positional-only parameters.
92
+
93
+
As guidance:
94
+
95
+
Use positional-only if names do not matter or have no meaning, and there are only a few arguments which will always be passed in the same order.
96
+
Use keyword-only when names have meaning and the function definition is more understandable by being explicit with names.
0 commit comments