Skip to content

Commit b930655

Browse files
committed
Refact module dependency in symboltable
To reduce cyclic imports, let's use genera imports instead of from ... import.
1 parent 68cc93d commit b930655

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

src/api/symboltable.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111

1212
from collections import OrderedDict
1313

14+
import src.api.check as check
15+
1416
from .debug import __DEBUG__
17+
from . import global_
1518

16-
from .. import symbols
19+
from src import symbols
1720
from src.symbols.symbol_ import Symbol
1821

19-
from . import global_
2022
from .config import OPTIONS
2123

2224
from .errmsg import error as syntax_error
@@ -31,9 +33,6 @@
3133
from .constants import CLASS
3234
from .constants import TYPE
3335

34-
from .check import is_number
35-
from .check import check_is_declared_explicit
36-
3736

3837
# ----------------------------------------------------------------------
3938
# Symbol table. Each id level will push a new symbol table
@@ -405,7 +404,7 @@ def access_id(self, id_: str, lineno: int, scope=None, default_type=None, defaul
405404
default_type = symbols.TYPEREF(default_type, lineno, implicit=False)
406405
assert default_type is None or isinstance(default_type, symbols.TYPEREF)
407406

408-
if not check_is_declared_explicit(lineno, id_):
407+
if not check.check_is_declared_explicit(lineno, id_):
409408
return None
410409

411410
result = self.get_entry(id_, scope)
@@ -423,7 +422,7 @@ def access_id(self, id_: str, lineno: int, scope=None, default_type=None, defaul
423422
# update its type.
424423
if default_type is not None and result.type_ == self.basic_types[TYPE.auto]:
425424
result.type_ = default_type
426-
warning_implicit_type(lineno, id_, default_type)
425+
warning_implicit_type(lineno, id_, default_type.name)
427426

428427
return result
429428

@@ -585,7 +584,7 @@ def declare_variable(self, id_, lineno, type_, default_value=None):
585584
warning_implicit_type(lineno, id_, entry.type_.name)
586585

587586
if default_value is not None and entry.type_ != default_value.type_:
588-
if is_number(default_value):
587+
if check.is_number(default_value):
589588
default_value = symbols.TYPECAST.make_node(entry.type_, default_value,
590589
lineno)
591590
if default_value is None:

0 commit comments

Comments
 (0)