Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split arguments in trace_fn() #81

Merged
merged 1 commit into from
Sep 23, 2024
Merged
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
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
Loading