|
| 1 | +# pyright: reportUnnecessaryTypeIgnoreComment=true |
| 2 | + |
1 | 3 | from decimal import Decimal
|
2 | 4 | from fractions import Fraction
|
3 | 5 | from typing import Any, NoReturn
|
|
54 | 56 | assert_type(Decimal("4.6") ** 7, Decimal)
|
55 | 57 |
|
56 | 58 | # These would ideally be more precise, but `Any` is acceptable
|
57 |
| -# They have to be `Any` due to the fact that type-checkers can't distinguish between positive and negative numbers for the second argument to `pow()` |
| 59 | +# They have to be `Any` due to the fact that type-checkers can't distinguish |
| 60 | +# between positive and negative numbers for the second argument to `pow()` |
58 | 61 | #
|
59 | 62 | # int for positive 2nd-arg, float otherwise
|
60 | 63 | assert_type(pow(4, 65), Any)
|
|
71 | 74 | assert_type(pow(4.7, 9.2, None), Any)
|
72 | 75 | # See #7046 -- float for a positive 1st arg, complex otherwise
|
73 | 76 | assert_type((-95) ** 8.42, Any)
|
| 77 | + |
| 78 | +# All of the following cases should fail a type-checker. |
| 79 | +# |
| 80 | +# mypy/pyright will emit errors if any of them do not fail: |
| 81 | +# - We use --warn-unused-ignores for mypy when checking this subdirectory; |
| 82 | +# - For pyright, we have reportUnnecessaryTypeIgnoreComment=true at the top of this file |
| 83 | +pow(1.9, 4, 6) # type: ignore[misc] |
| 84 | +pow(4, 7, 4.32) # type: ignore[misc] |
| 85 | +pow(6.2, 5.9, 73) # type: ignore[misc] |
| 86 | +pow(complex(6), 6.2, 7) # type: ignore[misc] |
| 87 | +pow(Fraction(), 5, 8) # type: ignore[call-overload] |
| 88 | +Decimal("8.7") ** 3.14 # type: ignore[operator] |
| 89 | + |
| 90 | +# TODO: This fails at runtime, but currently passes mypy and pyright: |
| 91 | +pow(Decimal("8.5"), 3.21) |
0 commit comments