4747USE_URLOPEN_RESOURCE_WARNING_FIX = (3 , 1 ) < sys .version_info < (3 , 4 )
4848
4949if os .name == "nt" :
50- startupinfo = subprocess .STARTUPINFO ()
51- startupinfo .dwFlags |= subprocess .STARTF_USESHOWWINDOW
50+ startupinfo = subprocess .STARTUPINFO () #@UndefinedVariable
51+ startupinfo .dwFlags |= subprocess .STARTF_USESHOWWINDOW #@UndefinedVariable
5252else :
5353 startupinfo = None
5454
@@ -78,18 +78,15 @@ class Match:
7878 _SLOTS = ("fromy" , "fromx" , "toy" , "tox" , "frompos" , "topos" ,
7979 "ruleId" , "subId" , "msg" , "replacements" ,
8080 "context" , "contextoffset" , "errorlength" )
81+ _frompos_cache , _topos_cache = None , None
8182
8283 def __init__ (self , attrib , text = None ):
8384 for k , v in attrib .items ():
8485 setattr (self , k , int (v ) if v .isdigit () else v )
8586 if not isinstance (self .replacements , list ):
8687 self .replacements = (self .replacements .split ("#" )
8788 if self .replacements else [])
88-
89- # Need to calculate `frompos` and `topos` attributes
90- # if using unpatched LanguageTool server.
9189 self ._lines = text
92- self ._frompos_cache , self ._topos_cache = None , None
9390
9491 def __repr__ (self ):
9592 def _ordered_dict_repr ():
@@ -106,6 +103,8 @@ def _ordered_dict_repr():
106103 return "{}({})" .format (self .__class__ .__name__ , _ordered_dict_repr ())
107104
108105 def __getattr__ (self , name ):
106+ # Fallback to calculated `frompos` and `topos` attributes
107+ # if using unpatched LanguageTool server.
109108 if name == "frompos" :
110109 return self ._frompos
111110 elif name == "topos" :
0 commit comments