@@ -133,8 +133,7 @@ new code. An important guideline is that the code should be clear enough that
133
133
comments are generally not needed.
134
134
135
135
All code, including test code, must be compatible with all supported Python
136
- interpreters and versions. Most importantly this means that the code must
137
- support both Python 2 and Python 3.
136
+ interpreters and versions.
138
137
139
138
Line length
140
139
'''''''''''
@@ -174,6 +173,24 @@ internal code. When docstrings are added, they should follow `PEP-257
174
173
section below for more details about documentation syntax, generating
175
174
API docs, etc.
176
175
176
+ Type hints / Annotations
177
+ ''''''''''''''''''''''''
178
+
179
+ Keywords and functions / methods in the public api should be annotated with type hints.
180
+ These annotations should follow the Python `Typing Best Practices
181
+ <https://typing.python.org/en/latest/reference/best_practices.html> `_ with the
182
+ following exceptions / restrictions:
183
+
184
+ - Annotation features are restricted to the minimum Python version supported by
185
+ Robot Framework.
186
+ - This means that at this time, for example, `TypeAlias ` can not yet be used.
187
+ - Annotations should use the stringified format for annotations not natively
188
+ availabe by the minimum supported Python version. For example `'int | float' `
189
+ instead of `Union[int, float] ` or `'list[int]' ` instead of `List[int] `.
190
+ - Due to automatic type conversion by Robot Framework, `'int | float' ` should not be
191
+ annotated as `'float' ` since this would convert any `int ` argument to a `float `.
192
+ - No `-> None ` annotation on functions / method that do not return.
193
+
177
194
Documentation
178
195
~~~~~~~~~~~~~
179
196
0 commit comments