Skip to content

Commit aedd563

Browse files
committed
bug fixes
1 parent 219c7c5 commit aedd563

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

python/code/wypp/drawingLib.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import time
22
import threading
33
import writeYourProgram as _w
4+
from typing import Literal, Sequence
5+
46
# Do not import tkinter at the top-level. Someone with no installation of tkinter should
57
# be able to user WYPP without drawing support.
68

@@ -14,9 +16,9 @@ class Point:
1416
x: float
1517
y: float
1618

17-
ShapeKind = _w.Literal['ellipsis', 'rectangle']
19+
type ShapeKind = Literal['ellipsis', 'rectangle']
1820

19-
Color = _w.Literal['red', 'green', 'blue', 'yellow', 'black', 'white']
21+
type Color = Literal['red', 'green', 'blue', 'yellow', 'black', 'white']
2022

2123
@_w.record
2224
class FixedShape:
@@ -58,7 +60,7 @@ def _drawCoordinateSystem(canvas, windowSize: Size):
5860
canvas.create_line(x, 0, x, windowSize.height, dash=(4,2))
5961
canvas.create_line(0, y, windowSize.width, y, dash=(4,2))
6062

61-
def drawFixedShapes(shapes: _w.Sequence[FixedShape],
63+
def drawFixedShapes(shapes: Sequence[FixedShape],
6264
withCoordinateSystem=False,
6365
stopAfter=None) -> None:
6466
try:

python/code/wypp/location.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ def getline(filename, lineno):
5252
if p in _cache:
5353
lines = _cache[p]
5454
else:
55-
with open(filename, 'rb') as f:
56-
byteLines = f.readlines()
55+
try:
56+
with open(filename, 'rb') as f:
57+
byteLines = f.readlines()
58+
except Exception:
59+
byteLines = []
5760
i = 0
5861
def nextLine() -> bytes:
5962
nonlocal i

python/tests/test_misc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import unittest
22
from writeYourProgram import *
3+
from typing import *
34

45
setDieOnCheckFailures(True)
56

python/tests/test_record.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import traceback
55
import dataclasses
66
import stacktrace
7+
from typing import Literal
78

89
initModule()
910

0 commit comments

Comments
 (0)