Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
554e393
Add failing test cases
JukkaL Dec 18, 2022
96b2767
Fix accessing attribute that overrides a property
JukkaL Dec 18, 2022
f8f65cd
WIP partially enable test case
JukkaL Dec 18, 2022
c9f9ae8
Refactor mypyc.irbuild.prepare a little
JukkaL Dec 18, 2022
147ccde
More refactoring
JukkaL Dec 18, 2022
e507645
Prefer attributes over methods, if both are defined
JukkaL Dec 18, 2022
0243a1e
Generate method decl for implicit property getters
JukkaL Dec 18, 2022
15b7b30
Fix serialization of the "implicit" attribute
JukkaL Dec 18, 2022
8e638b0
Support simple use cases where an attribute overrides a property
JukkaL Dec 18, 2022
44075a9
Fix case where both attribute and property are inherited
JukkaL Dec 18, 2022
c756c36
Support settable properties
JukkaL Dec 30, 2022
de7e436
Black + isort
JukkaL Dec 30, 2022
d92905d
Merge test cases
JukkaL Dec 30, 2022
1fd4bc5
Merge more test cases
JukkaL Dec 30, 2022
d80842a
Fix edge case
JukkaL Dec 30, 2022
0274969
Test case fixes
JukkaL Dec 30, 2022
810c4e1
Add native int test cases
JukkaL Dec 30, 2022
b0ee424
Fix test case
JukkaL Jan 2, 2023
479ffcd
Minor refactoring
JukkaL Jan 2, 2023
039fe10
Fix self check
JukkaL Jan 2, 2023
1996b8a
Improve comments and minor cleanup
JukkaL Jan 2, 2023
f5d4560
Minor refactoring
JukkaL Jan 2, 2023
8fc012e
Make test cases compatible with CPython
JukkaL Jan 10, 2023
d948ce8
Merge branch 'master' into mypyc-property-inheritance
JukkaL Jan 10, 2023
158ee54
Merge remote-tracking branch 'origin/master' into mypyc-property-inhe…
JukkaL Jan 10, 2023
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
Add native int test cases
  • Loading branch information
JukkaL committed Dec 30, 2022
commit 810c4e1484d5012e61359b6e96df1a9eae1e88f9
68 changes: 66 additions & 2 deletions mypyc/test-data/run-i64.test
Original file line number Diff line number Diff line change
Expand Up @@ -1223,12 +1223,15 @@ def test_many_locals() -> None:
assert a32 == 55
assert a33 == 20

[case testI64GlueMethods]
[case testI64GlueMethodsAndInheritance]
from typing import Any
from typing_extensions import Final

MYPY = False
if MYPY:
from mypy_extensions import i64
from mypy_extensions import i64, trait

from testutil import assertRaises

MAGIC: Final = -113

Expand Down Expand Up @@ -1266,3 +1269,64 @@ def test_derived_switches_arg_to_have_default() -> None:
b: Base = Derived()
assert b.hoho(5) == 3
assert b.hoho(MAGIC) == MAGIC - 2

@trait
class T:
@property
def x(self) -> i64: ...
@property
def y(self) -> i64: ...

class C(T):
x: i64
y: i64 = 4

def test_read_only_property_in_trait_implemented_as_attribute() -> None:
c = C()
c.x = 5
assert c.x == 5
c.x = MAGIC
assert c.x == MAGIC
assert c.y == 4
c.y = 6
assert c.y == 6
t: T = C()
assert t.y == 4
t = c
assert t.x == MAGIC
c.x = 55
assert t.x == 55
assert t.y == 6
a: Any = c
assert a.x == 55
assert a.y == 6
a.x = 7
a.y = 8
assert a.x == 7
assert a.y == 8

class D(T):
xx: i64

@property
def x(self) -> i64:
return self.xx

@property
def y(self) -> i64:
raise TypeError

def test_read_only_property_in_trait_implemented_as_property() -> None:
d = D()
d.xx = 5
assert d.x == 5
d.xx = MAGIC
assert d.x == MAGIC
with assertRaises(TypeError):
d.y
t: T = d
assert t.x == MAGIC
d.xx = 6
assert t.x == 6
with assertRaises(TypeError):
t.y