From 0f10303592ce26e9acbdf32df3960167ff8c4a7c Mon Sep 17 00:00:00 2001 From: Jose Rodriguez Date: Sat, 21 Aug 2021 22:00:50 +0200 Subject: [PATCH 1/2] Make pos parameter optional in SymbolBLOCK.pop() --- src/symbols/block.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/symbols/block.py b/src/symbols/block.py index cca7383de..ee741ab1e 100644 --- a/src/symbols/block.py +++ b/src/symbols/block.py @@ -43,7 +43,7 @@ def __eq__(self, other): def __hash__(self): return id(self) - def pop(self, pos: int) -> Symbol: + def pop(self, pos: int = -1) -> Symbol: return self.children.pop(pos) def append(self, *args): From 4f24bdc4f6dff5ff7e7e8b3280566e23307ed2dd Mon Sep 17 00:00:00 2001 From: Jose Rodriguez Date: Sat, 21 Aug 2021 22:08:28 +0200 Subject: [PATCH 2/2] refact: remove unused method in Symbol() --- src/symbols/symbol_.py | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/symbols/symbol_.py b/src/symbols/symbol_.py index 0c5d9e011..7f5027b7e 100644 --- a/src/symbols/symbol_.py +++ b/src/symbols/symbol_.py @@ -9,7 +9,6 @@ # the GNU General License # ---------------------------------------------------------------------- -import re from collections import Counter from typing import Optional @@ -78,25 +77,6 @@ def t(self): return self._t - def copy_attr(self, other): - """ Copies all other attributes (not methods) - from the other object to this instance. - """ - if not isinstance(other, Symbol): - return # Nothing done if not a Symbol object - - tmp = re.compile('__.*__') - for attr in (x for x in dir(other) if not tmp.match(x)): - if ( - hasattr(self.__class__, attr) and - str(type(getattr(self.__class__, attr)) in ('property', 'function', 'instancemethod')) - ): - continue - - val = getattr(other, attr) - if isinstance(val, str) or str(val)[0] != '<': # Not a value - setattr(self, attr, val) - @property def is_needed(self) -> bool: return len(self.required_by) > 0