-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
101 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
from abc import ABC, abstractmethod | ||
from typing import Generic, TypeVar | ||
|
||
from streamable import stream | ||
|
||
V = TypeVar("V") | ||
|
||
|
||
class Visitor(Generic[V]): | ||
def visit_any(self, stream: stream.Stream) -> V: | ||
raise NotImplementedError() | ||
class Visitor(ABC, Generic[V]): | ||
# fmt: off | ||
@abstractmethod | ||
def visit_stream(self, stream: stream.Stream) -> V: ... | ||
# fmt: on | ||
|
||
def visit_catch_stream(self, stream: stream.CatchStream) -> V: | ||
return self.visit_any(stream) | ||
return self.visit_stream(stream) | ||
|
||
def visit_filter_stream(self, stream: stream.FilterStream) -> V: | ||
return self.visit_any(stream) | ||
return self.visit_stream(stream) | ||
|
||
def visit_flatten_stream(self, stream: stream.FlattenStream) -> V: | ||
return self.visit_any(stream) | ||
return self.visit_stream(stream) | ||
|
||
def visit_foreach_stream(self, stream: stream.ForeachStream) -> V: | ||
return self.visit_any(stream) | ||
return self.visit_stream(stream) | ||
|
||
def visit_group_stream(self, stream: stream.GroupStream) -> V: | ||
return self.visit_any(stream) | ||
return self.visit_stream(stream) | ||
|
||
def visit_limit_stream(self, stream: stream.LimitStream) -> V: | ||
return self.visit_any(stream) | ||
return self.visit_stream(stream) | ||
|
||
def visit_observe_stream(self, stream: stream.ObserveStream) -> V: | ||
return self.visit_any(stream) | ||
return self.visit_stream(stream) | ||
|
||
def visit_map_stream(self, stream: stream.MapStream) -> V: | ||
return self.visit_any(stream) | ||
return self.visit_stream(stream) | ||
|
||
def visit_slow_stream(self, stream: stream.SlowStream) -> V: | ||
return self.visit_any(stream) | ||
|
||
def visit_stream(self, stream: stream.Stream) -> V: | ||
return self.visit_any(stream) | ||
return self.visit_stream(stream) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.