From ff4c5dd80c53e4c6b1a9f2f701e74f48615b5bc5 Mon Sep 17 00:00:00 2001 From: apalala Date: Tue, 28 Nov 2023 15:40:32 -0400 Subject: [PATCH] [lint] resolve warnings --- tatsu/util/_common.py | 7 +++++++ tatsu/util/parproc.py | 3 +-- tatsu/walkers.py | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tatsu/util/_common.py b/tatsu/util/_common.py index a0edc221..91689dc1 100644 --- a/tatsu/util/_common.py +++ b/tatsu/util/_common.py @@ -57,6 +57,13 @@ def _pubdict(self): } +def program_name(): + import __main__ as main + if package := main.__package__: + return package + return Path(main.__file__).name + + def is_posix(): return os.name == 'posix' diff --git a/tatsu/util/parproc.py b/tatsu/util/parproc.py index 3904cf88..773c4f0d 100644 --- a/tatsu/util/parproc.py +++ b/tatsu/util/parproc.py @@ -15,13 +15,12 @@ TimeRemainingColumn, ) - from tatsu.util.unicode_characters import ( U_CHECK_MARK, U_CROSSED_SWORDS, ) -from .util import identity, memory_use, program_name, try_read +from ..util import identity, memory_use, program_name, try_read __all__ = ['parallel_proc', 'processing_loop'] diff --git a/tatsu/walkers.py b/tatsu/walkers.py index e098f4a6..0406092e 100644 --- a/tatsu/walkers.py +++ b/tatsu/walkers.py @@ -47,6 +47,8 @@ def _walk_children(self, node: Node, *args, **kwargs): for child in node.children(): return self.walk(child, *args, **kwargs) + return None + def _find_walker(self, node: Node, prefix='walk_'): def pythonize_match(m): return '_' + m.group().lower()