Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions python/src/runner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import annotations as anns
import sys
import os
import os.path
Expand Down Expand Up @@ -320,7 +319,7 @@ def runCode(fileToRun, globals, args, useUntypy=True, extraDirs=None):

with RunSetup(localDir):
codeTxt = readFile(fileToRun)
flags = 0 | anns.compiler_flag
flags = 0
if useUntypy:
verbose(f'finding modules imported by {fileToRun}')
importedMods = findImportedModules([localDir] + extraDirs, fileToRun)
Expand Down
2 changes: 2 additions & 0 deletions python/test-data/fileWithRecursiveTypes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

class C:
def foo(self: C, d: D) -> C:
return C
Expand Down
1 change: 1 addition & 0 deletions python/test-data/testClassRecursion.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from wypp import *

class C:
Expand Down
4 changes: 2 additions & 2 deletions python/test-data/testHintParentheses1.err
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Traceback (most recent call last):
File "test-data/testHintParentheses1.py", line 4, in <module>
File "test-data/testHintParentheses1.py", line 5, in <module>
def foo(l: list(int)) -> int:
WyppAttributeError: Type annotation of function 'foo' could not be resolved:
'type' object is not iterable

def foo(l: list(int)) -> int:
return ^^^^^^^^^ - Did you mean: 'list[int]'?

declared at: test-data/testHintParentheses1.py:4
declared at: test-data/testHintParentheses1.py:5
3 changes: 2 additions & 1 deletion python/test-data/testHintParentheses1.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations
from wypp import *
# See https://github.com/skogsbaer/write-your-python-program/issues/61

def foo(l: list(int)) -> int:
return len(l)

check(foo([1,2,3]), 3)
check(foo([1,2,3]), 3)
4 changes: 2 additions & 2 deletions python/test-data/testHintParentheses3.err
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Traceback (most recent call last):
File "test-data/testHintParentheses3.py", line 5, in <module>
File "test-data/testHintParentheses3.py", line 6, in <module>
def foo() -> Union(list, str):
WyppAttributeError: Type annotation of function 'foo' could not be resolved:
Cannot call Union like a function. Did you mean Union[list, str]?

def foo() -> Union(list, str):
pass ^^^^^^^^^^^^^^^^ - Did you mean: 'Union[list, str]'?

declared at: test-data/testHintParentheses3.py:5
declared at: test-data/testHintParentheses3.py:6
3 changes: 2 additions & 1 deletion python/test-data/testHintParentheses3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations
from wypp import *
# See https://github.com/skogsbaer/write-your-python-program/issues/61

# Tests 'return'
def foo() -> Union(list, str):
pass
pass
1 change: 1 addition & 0 deletions python/test-data/testIterator3.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from typing import Iterable

def myRange(n: int) -> Iterator[int]:
Expand Down
8 changes: 4 additions & 4 deletions python/test-data/testRecordSetTypeForwardRef.err
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Traceback (most recent call last):
File "test-data/testRecordSetTypeForwardRef.py", line 14, in <module>
File "test-data/testRecordSetTypeForwardRef.py", line 15, in <module>
m()
File "test-data/testRecordSetTypeForwardRef.py", line 12, in m
File "test-data/testRecordSetTypeForwardRef.py", line 13, in m
r.x = "hello"
WyppTypeError: got value of wrong type
given: 'hello'
expected: value of type A

declared at: test-data/testRecordSetTypeForwardRef.py:4
caused by: test-data/testRecordSetTypeForwardRef.py:12
declared at: test-data/testRecordSetTypeForwardRef.py:5
caused by: test-data/testRecordSetTypeForwardRef.py:13
| r.x = "hello"
8 changes: 4 additions & 4 deletions python/test-data/testRecordSetTypeForwardRef.err-3.12
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Traceback (most recent call last):
File "test-data/testRecordSetTypeForwardRef.py", line 14, in <module>
File "test-data/testRecordSetTypeForwardRef.py", line 15, in <module>
m()
File "test-data/testRecordSetTypeForwardRef.py", line 12, in m
File "test-data/testRecordSetTypeForwardRef.py", line 13, in m
r.x = "hello"
WyppTypeError: got value of wrong type
given: 'hello'
expected: value of type A

declared at: test-data/testRecordSetTypeForwardRef.py:3
caused by: test-data/testRecordSetTypeForwardRef.py:12
declared at: test-data/testRecordSetTypeForwardRef.py:4
caused by: test-data/testRecordSetTypeForwardRef.py:13
| r.x = "hello"
1 change: 1 addition & 0 deletions python/test-data/testRecordSetTypeForwardRef.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from wypp import *

@record(mutable=True)
Expand Down
24 changes: 12 additions & 12 deletions python/test-data/testTypesProtos6.err
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
Traceback (most recent call last):
File "test-data/testTypesProtos6.py", line 56, in <module>
File "test-data/testTypesProtos6.py", line 57, in <module>
print(computeTotalSize(root))
File "test-data/testTypesProtos6.py", line 49, in computeTotalSize
File "test-data/testTypesProtos6.py", line 50, in computeTotalSize
fs.accept(visitor)
File "test-data/testTypesProtos6.py", line 18, in accept
File "test-data/testTypesProtos6.py", line 19, in accept
visitor.visitDirectory(self)
File "test-data/testTypesProtos6.py", line 40, in visitDirectory
File "test-data/testTypesProtos6.py", line 41, in visitDirectory
c.accept(self)
File "test-data/testTypesProtos6.py", line 27, in accept
File "test-data/testTypesProtos6.py", line 28, in accept
visitor.visitFile(self)
WyppTypeError: TotalSizeVisitor does not implement parent FileSystemVisitor
given: <__wypp__.TotalSizeVisitor object at 0x00>
expected: value of type FileSystemVisitor

declared at: test-data/testTypesProtos6.py:35
declared at: test-data/testTypesProtos6.py:32
caused by: test-data/testTypesProtos6.py:35
declared at: test-data/testTypesProtos6.py:36
declared at: test-data/testTypesProtos6.py:33
caused by: test-data/testTypesProtos6.py:36
| class TotalSizeVisitor(FileSystemVisitor):
caused by: test-data/testTypesProtos6.py:41
caused by: test-data/testTypesProtos6.py:42
| def visitFile(self, file: str):

Argument file of method visitFile violates the type declared by the parent FileSystemVisitor.
Expand All @@ -28,7 +28,7 @@ expected: value of type str

context: visitFile(self: Self, file: str) -> None
^^^
declared at: test-data/testTypesProtos6.py:41
declared at: test-data/testTypesProtos6.py:32
caused by: test-data/testTypesProtos6.py:41
declared at: test-data/testTypesProtos6.py:42
declared at: test-data/testTypesProtos6.py:33
caused by: test-data/testTypesProtos6.py:42
| def visitFile(self, file: str):
1 change: 1 addition & 0 deletions python/test-data/testTypesProtos6.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from wypp import *

class FileSystemEntry:
Expand Down
24 changes: 12 additions & 12 deletions python/test-data/testTypesProtos7.err
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
Traceback (most recent call last):
File "test-data/testTypesProtos7.py", line 75, in <module>
File "test-data/testTypesProtos7.py", line 76, in <module>
print(computeTotalSize(root))
File "test-data/testTypesProtos7.py", line 68, in computeTotalSize
File "test-data/testTypesProtos7.py", line 69, in computeTotalSize
fs.accept(visitor)
File "test-data/testTypesProtos7.py", line 35, in accept
File "test-data/testTypesProtos7.py", line 36, in accept
visitor.visitDirectory(self)
File "test-data/testTypesProtos7.py", line 59, in visitDirectory
File "test-data/testTypesProtos7.py", line 60, in visitDirectory
c.accept(self)
File "test-data/testTypesProtos7.py", line 46, in accept
File "test-data/testTypesProtos7.py", line 47, in accept
visitor.visitFile(self)
WyppTypeError: TotalSizeVisitor does not implement parent FileSystemVisitor
given: <__wypp__.TotalSizeVisitor object at 0x00>
expected: value of type FileSystemVisitor

declared at: test-data/testTypesProtos7.py:54
declared at: test-data/testTypesProtos7.py:51
caused by: test-data/testTypesProtos7.py:54
declared at: test-data/testTypesProtos7.py:55
declared at: test-data/testTypesProtos7.py:52
caused by: test-data/testTypesProtos7.py:55
| class TotalSizeVisitor(FileSystemVisitor):
caused by: test-data/testTypesProtos7.py:60
caused by: test-data/testTypesProtos7.py:61
| def visitFile(self, f: str):

Argument f of method visitFile violates the type declared for file in parent FileSystemVisitor.
Expand All @@ -27,7 +27,7 @@ given: File('notes.txt')
expected: value of type str

context: visitFile(self: Self, f: File) -> None
declared at: test-data/testTypesProtos7.py:60
declared at: test-data/testTypesProtos7.py:51
caused by: test-data/testTypesProtos7.py:60
declared at: test-data/testTypesProtos7.py:61
declared at: test-data/testTypesProtos7.py:52
caused by: test-data/testTypesProtos7.py:61
| def visitFile(self, f: str):
1 change: 1 addition & 0 deletions python/test-data/testTypesProtos7.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from abc import ABC, abstractmethod
from wypp import *

Expand Down
6 changes: 3 additions & 3 deletions python/test-data/wrong-caused-by.err
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Traceback (most recent call last):
File "test-data/wrong-caused-by.py", line 30, in <module>
File "test-data/wrong-caused-by.py", line 31, in <module>
mainStreetM.turnIntoStreet(redCarM)
WyppTypeError: got value of wrong type
given: CarM(licensePlate='OG PY 123', color='rot')
expected: value of type Car

context: turnIntoStreet(self: Self, car: Car) -> None
^^^
declared at: test-data/wrong-caused-by.py:9
caused by: test-data/wrong-caused-by.py:30
declared at: test-data/wrong-caused-by.py:10
caused by: test-data/wrong-caused-by.py:31
| mainStreetM.turnIntoStreet(redCarM)
1 change: 1 addition & 0 deletions python/test-data/wrong-caused-by.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from wypp import *

@record(mutable=True)
Expand Down
Loading