Skip to content

Commit 45e4ebc

Browse files
authored
Merge pull request #149 from skogsbaer/sw/no-auto-annotations-bug146
do not enable annotations automatically #146
2 parents 538f6fb + f75ee44 commit 45e4ebc

17 files changed

+52
-43
lines changed

python/src/runner.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import annotations as anns
21
import sys
32
import os
43
import os.path
@@ -320,7 +319,7 @@ def runCode(fileToRun, globals, args, useUntypy=True, extraDirs=None):
320319

321320
with RunSetup(localDir):
322321
codeTxt = readFile(fileToRun)
323-
flags = 0 | anns.compiler_flag
322+
flags = 0
324323
if useUntypy:
325324
verbose(f'finding modules imported by {fileToRun}')
326325
importedMods = findImportedModules([localDir] + extraDirs, fileToRun)

python/test-data/fileWithRecursiveTypes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
class C:
24
def foo(self: C, d: D) -> C:
35
return C

python/test-data/testClassRecursion.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import annotations
12
from wypp import *
23

34
class C:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Traceback (most recent call last):
2-
File "test-data/testHintParentheses1.py", line 4, in <module>
2+
File "test-data/testHintParentheses1.py", line 5, in <module>
33
def foo(l: list(int)) -> int:
44
WyppAttributeError: Type annotation of function 'foo' could not be resolved:
55
'type' object is not iterable
66

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

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

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

7-
check(foo([1,2,3]), 3)
8+
check(foo([1,2,3]), 3)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Traceback (most recent call last):
2-
File "test-data/testHintParentheses3.py", line 5, in <module>
2+
File "test-data/testHintParentheses3.py", line 6, in <module>
33
def foo() -> Union(list, str):
44
WyppAttributeError: Type annotation of function 'foo' could not be resolved:
55
Cannot call Union like a function. Did you mean Union[list, str]?
66

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

10-
declared at: test-data/testHintParentheses3.py:5
10+
declared at: test-data/testHintParentheses3.py:6
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from __future__ import annotations
12
from wypp import *
23
# See https://github.com/skogsbaer/write-your-python-program/issues/61
34

45
# Tests 'return'
56
def foo() -> Union(list, str):
6-
pass
7+
pass

python/test-data/testIterator3.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import annotations
12
from typing import Iterable
23

34
def myRange(n: int) -> Iterator[int]:
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Traceback (most recent call last):
2-
File "test-data/testRecordSetTypeForwardRef.py", line 14, in <module>
2+
File "test-data/testRecordSetTypeForwardRef.py", line 15, in <module>
33
m()
4-
File "test-data/testRecordSetTypeForwardRef.py", line 12, in m
4+
File "test-data/testRecordSetTypeForwardRef.py", line 13, in m
55
r.x = "hello"
66
WyppTypeError: got value of wrong type
77
given: 'hello'
88
expected: value of type A
99

10-
declared at: test-data/testRecordSetTypeForwardRef.py:4
11-
caused by: test-data/testRecordSetTypeForwardRef.py:12
10+
declared at: test-data/testRecordSetTypeForwardRef.py:5
11+
caused by: test-data/testRecordSetTypeForwardRef.py:13
1212
| r.x = "hello"
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Traceback (most recent call last):
2-
File "test-data/testRecordSetTypeForwardRef.py", line 14, in <module>
2+
File "test-data/testRecordSetTypeForwardRef.py", line 15, in <module>
33
m()
4-
File "test-data/testRecordSetTypeForwardRef.py", line 12, in m
4+
File "test-data/testRecordSetTypeForwardRef.py", line 13, in m
55
r.x = "hello"
66
WyppTypeError: got value of wrong type
77
given: 'hello'
88
expected: value of type A
99

10-
declared at: test-data/testRecordSetTypeForwardRef.py:3
11-
caused by: test-data/testRecordSetTypeForwardRef.py:12
10+
declared at: test-data/testRecordSetTypeForwardRef.py:4
11+
caused by: test-data/testRecordSetTypeForwardRef.py:13
1212
| r.x = "hello"

0 commit comments

Comments
 (0)