Skip to content

Commit dfbf24c

Browse files
teskjeilevkivskyi
authored andcommitted
Fix the code sample on the "Duck type compatibility" docs page. (#5711)
This commit fixes two issues with said code sample: - The math import was missing. - The function argument didn't match the variable name used in the function body. Also made comment spacing consistent.
1 parent c47511f commit dfbf24c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/source/duck_type_compatibility.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ and also behaves as expected:
1616

1717
.. code-block:: python
1818
19-
def degrees_to_radians(x: float) -> float:
19+
import math
20+
21+
def degrees_to_radians(degrees: float) -> float:
2022
return math.pi * degrees / 180
2123
2224
n = 90 # Inferred type 'int'
23-
print(degrees_to_radians(n)) # Okay!
25+
print(degrees_to_radians(n)) # Okay!
2426
2527
You can also often use :ref:`protocol-types` to achieve a similar effect in
2628
a more principled and extensible fashion. Protocols don't apply to

0 commit comments

Comments
 (0)