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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions python/fileTests
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ checkWithOutputAux yes 1 test-data/testLiteral1.py
checkWithOutputAux yes 0 test-data/testForwardTypeInRecord.py
checkWithOutputAux yes 0 test-data/testForwardTypeInRecord2.py
checkWithOutputAux yes 0 test-data/testUnionOfUnion.py
checkWithOutputAux yes 1 test-data/testRecordTypes.py

function is_min_version()
{
Expand Down
5 changes: 3 additions & 2 deletions python/src/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,15 @@ def __init__(self, mod, properlyImported):
if name and name[0] != '_':
d[name] = getattr(mod, name)

def prepareLib(onlyCheckRunnable):
def prepareLib(onlyCheckRunnable, enableTypeChecking):
libDefs = None
mod = INSTALLED_MODULE_NAME
verbose('Attempting to import ' + mod)
wypp = importlib.import_module(mod)
libDefs = Lib(wypp, True)
verbose('Successfully imported module ' + mod + ' from file ' + wypp.__file__)
libDefs.initModule(enableChecks=not onlyCheckRunnable,
enableTypeChecking=enableTypeChecking,
quiet=onlyCheckRunnable)
return libDefs

Expand Down Expand Up @@ -534,7 +535,7 @@ def main(globals, argList=None):
if not args.checkRunnable and (not args.quiet or args.verbose):
printWelcomeString(fileToRun, version, useUntypy=args.checkTypes)

libDefs = prepareLib(onlyCheckRunnable=args.checkRunnable)
libDefs = prepareLib(onlyCheckRunnable=args.checkRunnable, enableTypeChecking=args.checkTypes)

globals['__name__'] = '__wypp__'
sys.modules['__wypp__'] = sys.modules['__main__']
Expand Down
12 changes: 9 additions & 3 deletions python/src/writeYourProgram.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ def _setattr(obj, k, v):
def record(cls=None, mutable=False):
def wrap(cls):
newCls = dataclasses.dataclass(cls, frozen=not mutable)
return _patchDataClass(newCls, mutable)
if _typeCheckingEnabled:
return _patchDataClass(newCls, mutable)
else:
return newCls
# See if we're being called as @record or @record().
if cls is None:
# We're called with parens.
Expand All @@ -155,17 +158,20 @@ def wrap(cls):
_die = False

def setDieOnCheckFailures(b):
global _die
_die = b

def _dieOnCheckFailures():
return _die

_testCount = {'total': 0, 'failing': 0}
_checksEnabled = True
_typeCheckingEnabled = False

def initModule(enableChecks=True, quiet=False):
global _checksEnabled
def initModule(enableChecks=True, enableTypeChecking=True, quiet=False):
global _checksEnabled, _typeCheckingEnabled
_checksEnabled = enableChecks
_typeCheckingEnabled = enableTypeChecking
resetTestCount()

def resetTestCount():
Expand Down
12 changes: 12 additions & 0 deletions python/test-data/testRecordTypes.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Traceback (most recent call last):
File "test-data/testRecordTypes.py", line 8, in <module>
p = Point(1, '5')
WyppTypeError: got value of wrong type
given: '5'
expected: value of type int

context: record constructor Point(x: int, y: int) -> Self
^^^
declared at: test-data/testRecordTypes.py:4
caused by: test-data/testRecordTypes.py:8
| p = Point(1, '5')
12 changes: 12 additions & 0 deletions python/test-data/testRecordTypes.err-3.12
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Traceback (most recent call last):
File "test-data/testRecordTypes.py", line 8, in <module>
p = Point(1, '5')
WyppTypeError: got value of wrong type
given: '5'
expected: value of type int

context: record constructor Point(x: int, y: int) -> Self
^^^
declared at: test-data/testRecordTypes.py:3
caused by: test-data/testRecordTypes.py:8
| p = Point(1, '5')
Empty file.
8 changes: 8 additions & 0 deletions python/test-data/testRecordTypes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from wypp import *

@record
class Point:
x: int
y: int

p = Point(1, '5')
1 change: 1 addition & 0 deletions python/tests/testRecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import traceback
import dataclasses

initModule()
setDieOnCheckFailures(True)

@record
Expand Down
9 changes: 8 additions & 1 deletion src/programflow-visualization/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ export namespace Variables {
}

export const nextLineExecuteHighlightType = vscode.window.createTextEditorDecorationType({
backgroundColor: 'rgba(255, 255, 0, 0.25)', // Yellow
borderWidth: '1px',
borderStyle: 'solid',
isWholeLine: true,
borderColor: 'rgb(40, 40, 40)',
backgroundColor: 'rgba(248, 248, 181, 0.75)',
dark: {
borderColor: 'rgb(215, 215, 215)',
backgroundColor: 'rgba(75, 75, 24, 0.75)',
}
});
Loading