33import warnings
44from typing import Any , Dict , List , Optional , Tuple , Union
55
6- from antlr4 import ParserRuleContext , TerminalNode , Token
7- from antlr4 .error .ErrorListener import ErrorListener
8- from antlr4 .tree .Tree import TerminalNodeImpl
6+ from omegaconf .vendor .antlr4 import ( # type: ignore[attr-defined]
7+ ParserRuleContext ,
8+ TerminalNode ,
9+ Token ,
10+ )
11+ from omegaconf .vendor .antlr4 .error .ErrorListener import ErrorListener
12+ from omegaconf .vendor .antlr4 .tree .Tree import TerminalNodeImpl
913
1014from hydra ._internal .grammar .functions import FunctionCall , Functions
1115from hydra ._internal .grammar .utils import _ESC_QUOTED_STR
@@ -162,7 +166,7 @@ def visitOverride(self, ctx: OverrideParser.OverrideContext) -> Override:
162166 if (
163167 override_type == OverrideType .DEL
164168 and isinstance (eq_node , TerminalNode )
165- and eq_node .symbol .type == Token .EOF
169+ and eq_node .symbol .type == Token .EOF # type: ignore[attr-defined]
166170 ):
167171 value = None
168172 value_type = None
@@ -244,26 +248,26 @@ def visitFunction(self, ctx: OverrideParser.FunctionContext) -> Any:
244248 ) from e
245249
246250 def _createPrimitive (
247- self , ctx : ParserRuleContext
251+ self , ctx : ParserRuleContext # type: ignore[valid-type]
248252 ) -> Optional [Union [QuotedString , int , bool , float , str ]]:
249253 ret : Optional [Union [int , bool , float , str ]]
250254 first_idx = 0
251- last_idx = ctx .getChildCount ()
255+ last_idx = ctx .getChildCount () # type: ignore[attr-defined]
252256 # skip first if whitespace
253- if self .is_ws (ctx .getChild (0 )):
257+ if self .is_ws (ctx .getChild (0 )): # type: ignore[attr-defined]
254258 if last_idx == 1 :
255259 # Only whitespaces => this is not allowed.
256260 raise HydraException (
257261 "Trying to parse a primitive that is all whitespaces"
258262 )
259263 first_idx = 1
260- if self .is_ws (ctx .getChild (- 1 )):
264+ if self .is_ws (ctx .getChild (- 1 )): # type: ignore[attr-defined]
261265 last_idx = last_idx - 1
262266 num = last_idx - first_idx
263267 if num > 1 :
264268 # Concatenate, while un-escaping as needed.
265269 tokens = []
266- for i , n in enumerate (ctx .getChildren ()):
270+ for i , n in enumerate (ctx .getChildren ()): # type: ignore[attr-defined]
267271 if n .symbol .type == OverrideLexer .WS and (
268272 i < first_idx or i >= last_idx
269273 ):
@@ -276,7 +280,7 @@ def _createPrimitive(
276280 )
277281 ret = "" .join (tokens )
278282 else :
279- node = ctx .getChild (first_idx )
283+ node = ctx .getChild (first_idx ) # type: ignore[attr-defined]
280284 if node .symbol .type == OverrideLexer .QUOTED_VALUE :
281285 text = node .getText ()
282286 qc = text [0 ]
@@ -360,7 +364,7 @@ def _unescape_quoted_string(self, text: str) -> str:
360364 return "" .join (tokens )
361365
362366
363- class HydraErrorListener (ErrorListener ): # type: ignore
367+ class HydraErrorListener (ErrorListener ):
364368 def syntaxError (
365369 self ,
366370 recognizer : Any ,
0 commit comments