Skip to content

Commit

Permalink
split arguments in trace_fn() (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky authored Sep 23, 2024
1 parent 74b82f4 commit f1c0507
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mathics_scanner/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from abc import ABCMeta, abstractmethod
from typing import List
from typing import Callable, List, Optional


class LineFeeder(metaclass=ABCMeta):
Expand Down Expand Up @@ -52,7 +52,7 @@ def message(self, sym: str, tag: str, *args) -> None:
message = [sym, tag] + list(args)
self.messages.append(message)

def syntax_message(self, sym: str, tag: str, *args):
def syntax_message(self, sym: str, tag: str, *args) -> list:
"""
Append a message concerning syntax errors to the message queue.
"""
Expand Down Expand Up @@ -132,7 +132,7 @@ def empty(self) -> bool:
class FileLineFeeder(LineFeeder):
"A feeder that feeds lines from an open ``File`` object"

def __init__(self, fileobject, trace_fn=None):
def __init__(self, fileobject, trace_fn: Optional[Callable] = None):
"""
:param fileobject: The source of the feeder (a string).
:param filename: A string that describes the source of the feeder,
Expand All @@ -150,7 +150,7 @@ def feed(self) -> str:
result = self.fileobject.readline()
self.lineno += 1
if self.trace_fn:
self.trace_fn("%5d: %s" % (self.lineno, result), end="")
self.trace_fn(self.lineno, result)
if result:
self.lineno += 1
else:
Expand Down

0 comments on commit f1c0507

Please sign in to comment.