8000 Proposed clarification of spec for int/float/complex promotion by JelleZijlstra · Pull Request #1748 · python/typing · GitHub
[go: up one dir, main page]

Skip to content

Proposed clarification of spec for int/float/complex promotion #1748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Extend test
  • Loading branch information
JelleZijlstra committed May 23, 2024
commit 6155dbdc1a4553a31a0340c096309f27e7e7ad90
4 changes: 2 additions & 2 deletions conformance/results/mypy/specialtypes_promotions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
conformant = "Pass"
output = """
specialtypes_promotions.py:15: error: "float" has no attribute "numerator" [attr-defined]
specialtypes_promotions.py:27: error: Incompatible return value type (got "complex", expected "float") [return-value]
specialtypes_promotions.py:17: error: "float" has no attribute "numerator" [attr-defined]
specialtypes_promotions.py:29: error: Incompatible return value type (got "complex", expected "float") [return-value]
"""
conformance_automated = "Pass"
errors_diff = """
Expand Down
2 changes: 1 addition & 1 deletion conformance/results/mypy/version.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "mypy 1.10.0"
test_duration = 1.2
test_duration = 6.2
4 changes: 2 additions & 2 deletions conformance/results/pyre/specialtypes_promotions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ notes = """
Does not reject use of attribute that is compatible only with float.
"""
output = """
specialtypes_promotions.py:27:8 Incompatible return type [7]: Expected `float` but got `complex`.
specialtypes_promotions.py:29:8 Incompatible return type [7]: Expected `float` but got `complex`.
"""
conformance_automated = "Fail"
errors_diff = """
Line 15: Expected 1 errors
Line 17: Expected 1 errors
"""
2 changes: 1 addition & 1 deletion conformance/results/pyre/version.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "pyre 0.9.21"
test_duration = 2.3
test_duration = 2.6
4 changes: 2 additions & 2 deletions conformance/results/pyright/specialtypes_promotions.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
conformant = "Pass"
output = """
specialtypes_promotions.py:15:7 - error: Cannot access attribute "numerator" for class "float"
specialtypes_promotions.py:17:7 - error: Cannot access attribute "numerator" for class "float"
  Attribute "numerator" is unknown (reportAttributeAccessIssue)
specialtypes_promotions.py:27:16 - error: Expression of type "complex" is incompatible with return type "float"
specialtypes_promotions.py:29:16 - error: Expression of type "complex" is incompatible with return type "float"
  "complex" is incompatible with "float" (reportReturnType)
"""
conformance_automated = "Pass"
Expand Down
2 changes: 1 addition & 1 deletion conformance/results/pyright/version.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "pyright 1.1.364"
test_duration = 1.3
test_duration = 1.8
4 changes: 2 additions & 2 deletions conformance/results/pytype/specialtypes_promotions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
conformant = "Pass"
output = """
File "specialtypes_promotions.py", line 15, in func1: No attribute 'numerator' on float [attribute-error]
File "specialtypes_promotions.py", line 27, in func2: bad return type [bad-return-type]
File "specialtypes_promotions.py", line 17, in func1: No attribute 'numerator' on float [attribute-error]
File "specialtypes_promotions.py", line 29, in func2: bad return type [bad-return-type]
"""
conformance_automated = "Pass"
errors_diff = """
Expand Down
2 changes: 1 addition & 1 deletion conformance/results/pytype/version.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "pytype 2024.04.11"
test_duration = 27.3
test_duration = 54.5
8 changes: 4 additions & 4 deletions conformance/results/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,16 @@ <h3>Python Type System Conformance Test Results</h3>
<div class="table_container"><table><tbody>
<tr><th class="col1">&nbsp;</th>
<th class='tc-header'><div class='tc-name'>mypy 1.10.0</div>
<div class='tc-time'>1.2sec</div>
<div class='tc-time'>6.2sec</div>
</th>
<th class='tc-header'><div class='tc-name'>pyright 1.1.364</div>
<div class='tc-time'>1.3sec</div>
<div class='tc-time'>1.8sec</div>
</th>
<th class='tc-header'><div class='tc-name'>pyre 0.9.21</div>
<div class='tc-time'>2.3sec</div>
<div class='tc-time'>2.6sec</div>
</th>
<th class='tc-header'><div class='tc-name'>pytype 2024.04.11</div>
<div class='tc-time'>27.3sec</div>
<div class='tc-time'>54.5sec</div>
</th>
</tr>
<tr><th class="column" colspan="5">
Expand Down
8 changes: 5 additions & 3 deletions conformance/tests/specialtypes_promotions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

# Specification: https://typing.readthedocs.io/en/latest/spec/special-types.html#special-cases-for-float-and-complex

v1: float = 1
v2: complex = 1.2
v2 = 1
v1: int = 1
v2: float = 1
v3: float = v1
v4: complex = 1.2
v4 = 1


def func1(f: float):
Expand Down
0