diff --git a/python/src/runner.py b/python/src/runner.py index 38c8c3ed..0b089255 100644 --- a/python/src/runner.py +++ b/python/src/runner.py @@ -1,4 +1,3 @@ -from __future__ import annotations as anns import sys import os import os.path @@ -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) diff --git a/python/test-data/fileWithRecursiveTypes.py b/python/test-data/fileWithRecursiveTypes.py index 0423bdd8..cd7bfd59 100644 --- a/python/test-data/fileWithRecursiveTypes.py +++ b/python/test-data/fileWithRecursiveTypes.py @@ -1,3 +1,5 @@ +from __future__ import annotations + class C: def foo(self: C, d: D) -> C: return C diff --git a/python/test-data/testClassRecursion.py b/python/test-data/testClassRecursion.py index 669a0c1d..3da4a824 100644 --- a/python/test-data/testClassRecursion.py +++ b/python/test-data/testClassRecursion.py @@ -1,3 +1,4 @@ +from __future__ import annotations from wypp import * class C: diff --git a/python/test-data/testHintParentheses1.err b/python/test-data/testHintParentheses1.err index 89a9616e..ed624e35 100644 --- a/python/test-data/testHintParentheses1.err +++ b/python/test-data/testHintParentheses1.err @@ -1,5 +1,5 @@ Traceback (most recent call last): - File "test-data/testHintParentheses1.py", line 4, in + File "test-data/testHintParentheses1.py", line 5, in def foo(l: list(int)) -> int: WyppAttributeError: Type annotation of function 'foo' could not be resolved: 'type' object is not iterable @@ -7,4 +7,4 @@ WyppAttributeError: Type annotation of function 'foo' could not be resolved: 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 diff --git a/python/test-data/testHintParentheses1.py b/python/test-data/testHintParentheses1.py index 9a7d23a1..6efd9b26 100644 --- a/python/test-data/testHintParentheses1.py +++ b/python/test-data/testHintParentheses1.py @@ -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) \ No newline at end of file +check(foo([1,2,3]), 3) diff --git a/python/test-data/testHintParentheses3.err b/python/test-data/testHintParentheses3.err index 6fb631a3..5ac7b6ba 100644 --- a/python/test-data/testHintParentheses3.err +++ b/python/test-data/testHintParentheses3.err @@ -1,5 +1,5 @@ Traceback (most recent call last): - File "test-data/testHintParentheses3.py", line 5, in + File "test-data/testHintParentheses3.py", line 6, in 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]? @@ -7,4 +7,4 @@ 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 diff --git a/python/test-data/testHintParentheses3.py b/python/test-data/testHintParentheses3.py index 7b77a0d3..225f0b11 100644 --- a/python/test-data/testHintParentheses3.py +++ b/python/test-data/testHintParentheses3.py @@ -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 \ No newline at end of file + pass diff --git a/python/test-data/testIterator3.py b/python/test-data/testIterator3.py index dab7283e..cc6ddc2e 100644 --- a/python/test-data/testIterator3.py +++ b/python/test-data/testIterator3.py @@ -1,3 +1,4 @@ +from __future__ import annotations from typing import Iterable def myRange(n: int) -> Iterator[int]: diff --git a/python/test-data/testRecordSetTypeForwardRef.err b/python/test-data/testRecordSetTypeForwardRef.err index 567c564c..f1494801 100644 --- a/python/test-data/testRecordSetTypeForwardRef.err +++ b/python/test-data/testRecordSetTypeForwardRef.err @@ -1,12 +1,12 @@ Traceback (most recent call last): - File "test-data/testRecordSetTypeForwardRef.py", line 14, in + File "test-data/testRecordSetTypeForwardRef.py", line 15, in 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" diff --git a/python/test-data/testRecordSetTypeForwardRef.err-3.12 b/python/test-data/testRecordSetTypeForwardRef.err-3.12 index 361ff706..3068bc74 100644 --- a/python/test-data/testRecordSetTypeForwardRef.err-3.12 +++ b/python/test-data/testRecordSetTypeForwardRef.err-3.12 @@ -1,12 +1,12 @@ Traceback (most recent call last): - File "test-data/testRecordSetTypeForwardRef.py", line 14, in + File "test-data/testRecordSetTypeForwardRef.py", line 15, in 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" diff --git a/python/test-data/testRecordSetTypeForwardRef.py b/python/test-data/testRecordSetTypeForwardRef.py index fbb14740..ba2dae0f 100644 --- a/python/test-data/testRecordSetTypeForwardRef.py +++ b/python/test-data/testRecordSetTypeForwardRef.py @@ -1,3 +1,4 @@ +from __future__ import annotations from wypp import * @record(mutable=True) diff --git a/python/test-data/testTypesProtos6.err b/python/test-data/testTypesProtos6.err index 3b36b009..20a107ce 100644 --- a/python/test-data/testTypesProtos6.err +++ b/python/test-data/testTypesProtos6.err @@ -1,23 +1,23 @@ Traceback (most recent call last): - File "test-data/testTypesProtos6.py", line 56, in + File "test-data/testTypesProtos6.py", line 57, in 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. @@ -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): diff --git a/python/test-data/testTypesProtos6.py b/python/test-data/testTypesProtos6.py index 1f8d3c5b..ac235260 100644 --- a/python/test-data/testTypesProtos6.py +++ b/python/test-data/testTypesProtos6.py @@ -1,3 +1,4 @@ +from __future__ import annotations from wypp import * class FileSystemEntry: diff --git a/python/test-data/testTypesProtos7.err b/python/test-data/testTypesProtos7.err index 4cd52639..a15b77bc 100644 --- a/python/test-data/testTypesProtos7.err +++ b/python/test-data/testTypesProtos7.err @@ -1,23 +1,23 @@ Traceback (most recent call last): - File "test-data/testTypesProtos7.py", line 75, in + File "test-data/testTypesProtos7.py", line 76, in 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. @@ -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): diff --git a/python/test-data/testTypesProtos7.py b/python/test-data/testTypesProtos7.py index 679032e7..c80e0259 100644 --- a/python/test-data/testTypesProtos7.py +++ b/python/test-data/testTypesProtos7.py @@ -1,3 +1,4 @@ +from __future__ import annotations from abc import ABC, abstractmethod from wypp import * diff --git a/python/test-data/wrong-caused-by.err b/python/test-data/wrong-caused-by.err index 808b81c6..6b363385 100644 --- a/python/test-data/wrong-caused-by.err +++ b/python/test-data/wrong-caused-by.err @@ -1,5 +1,5 @@ Traceback (most recent call last): - File "test-data/wrong-caused-by.py", line 30, in + File "test-data/wrong-caused-by.py", line 31, in mainStreetM.turnIntoStreet(redCarM) WyppTypeError: got value of wrong type given: CarM(licensePlate='OG PY 123', color='rot') @@ -7,6 +7,6 @@ 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) diff --git a/python/test-data/wrong-caused-by.py b/python/test-data/wrong-caused-by.py index d7ca90e2..343c16f8 100644 --- a/python/test-data/wrong-caused-by.py +++ b/python/test-data/wrong-caused-by.py @@ -1,3 +1,4 @@ +from __future__ import annotations from wypp import * @record(mutable=True)