mnelab icon indicating copy to clipboard operation
mnelab copied to clipboard

Add syntax check to history

Open hofaflo opened this issue 2 years ago • 2 comments

During development, it would be convenient if the history was checked for syntax errors. This can be implemented with the built-in function compile. Here's a basic example for this function:

>>> compile("a = 1\n b=2", "history", "exec")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "history", line 2
    b=2
IndentationError: unexpected indent

hofaflo avatar Feb 18 '22 09:02 hofaflo

Could this be a test then?

cbrnr avatar Feb 18 '22 11:02 cbrnr

Not really, since it requires to perform actions which create history entries. The use case I had in mind was more like this: You're in the process of implementing a new feature. In the line that adds the history entry, you miss a closing parenthesis. Since it's inside a string, the typo isn't obvious in the text editor. Trying out the new feature in the GUI, the history entry is created and directly checked for syntactic correctness. Of course this will only help to catch a small group of errors, but it might be helpful nonetheless.

hofaflo avatar Feb 18 '22 20:02 hofaflo