1616from typing import Optional
1717
1818from src .api import global_
19+ from src .api import config
1920
2021from src .api .constants import CLASS
21- from src .api .config import OPTIONS
2222
2323
2424# Exports only these functions. Others
@@ -39,14 +39,14 @@ def msg_output(msg: str) -> None:
3939 if msg in global_ .error_msg_cache :
4040 return
4141
42- OPTIONS .stderr .write ("%s\n " % msg )
42+ config . OPTIONS .stderr .write ("%s\n " % msg )
4343 global_ .error_msg_cache .add (msg )
4444
4545
4646def info (msg : str ) -> None :
47- if OPTIONS .debug_level < 1 :
47+ if config . OPTIONS .debug_level < 1 :
4848 return
49- OPTIONS .stderr .write ("info: %s\n " % msg )
49+ config . OPTIONS .stderr .write ("info: %s\n " % msg )
5050
5151
5252def error (lineno : int , msg : str , fname : Optional [str ] = None ) -> None :
@@ -55,13 +55,13 @@ def error(lineno: int, msg: str, fname: Optional[str] = None) -> None:
5555 if fname is None :
5656 fname = global_ .FILENAME
5757
58- if global_ .has_errors > OPTIONS .max_syntax_errors :
58+ if global_ .has_errors > config . OPTIONS .max_syntax_errors :
5959 msg = 'Too many errors. Giving up!'
6060
6161 msg = "%s:%i: error:%s %s" % (fname , lineno , ERROR_PREFIX , msg )
6262 msg_output (msg )
6363
64- if global_ .has_errors > OPTIONS .max_syntax_errors :
64+ if global_ .has_errors > config . OPTIONS .max_syntax_errors :
6565 sys .exit (1 )
6666
6767 global_ .has_errors += 1
@@ -71,7 +71,7 @@ def warning(lineno: int, msg: str, fname: Optional[str] = None) -> None:
7171 """ Generic warning error routine
7272 """
7373 global_ .has_warnings += 1
74- if global_ .has_warnings <= OPTIONS .expected_warnings :
74+ if global_ .has_warnings <= config . OPTIONS .expected_warnings :
7575 return
7676
7777 if fname is None :
@@ -107,7 +107,7 @@ def decorator(func: Callable) -> Callable:
107107 def wrapper (* args , ** kwargs ):
108108 global WARNING_PREFIX
109109 if global_ .ENABLED_WARNINGS .get (code , True ):
110- if not OPTIONS .hide_warning_codes :
110+ if not config . OPTIONS .hide_warning_codes :
111111 WARNING_PREFIX = f'warning: [W{ code } ]'
112112 func (* args , ** kwargs )
113113 WARNING_PREFIX = ''
@@ -122,7 +122,7 @@ def wrapper(*args, **kwargs):
122122def warning_implicit_type (lineno : int , id_ : str , type_ : str = None ):
123123 """ Warning: Using default implicit type 'x'
124124 """
125- if OPTIONS .strict :
125+ if config . OPTIONS .strict :
126126 syntax_error_undeclared_type (lineno , id_ )
127127 return
128128
@@ -164,7 +164,7 @@ def warning_empty_if(lineno: int):
164164def warning_not_used (lineno : int , id_ : str , kind : str = 'Variable' , fname : Optional [str ] = None ):
165165 """ Emits an optimization warning
166166 """
167- if OPTIONS .optimization_level > 0 :
167+ if config . OPTIONS .optimization_level > 0 :
168168 warning (lineno , "%s '%s' is never used" % (kind , id_ ), fname = fname )
169169
170170
0 commit comments