Skip to content

Commit 690b5b4

Browse files
committed
Minor
1 parent 626f8ee commit 690b5b4

3 files changed

Lines changed: 12 additions & 14 deletions

File tree

‎language_tool/__init__.py‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
USE_URLOPEN_RESOURCE_WARNING_FIX = (3, 1) < sys.version_info < (3, 4)
4848

4949
if 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
5252
else:
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":
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import absolute_import
22

33
try:
4-
from xml.etree.cElementTree import *
4+
from xml.etree.cElementTree import * #@UnusedWildImport
55
except ImportError:
6-
from xml.etree.ElementTree import *
6+
from xml.etree.ElementTree import * #@UnusedWildImport

‎language_tool/backports/subprocess.py‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
"""
33

44
from __future__ import absolute_import
5-
6-
from subprocess import *
7-
5+
from subprocess import PIPE, Popen #@UnusedImport
6+
from subprocess import * #@UnusedWildImport
87

98
try:
10-
TimeoutExpired
9+
TimeoutExpired #@UndefinedVariable
1110
except NameError:
12-
import time
11+
import time #@Reimport
1312

1413
class SubprocessError(Exception):
1514
"""Exception classes used by this module.
@@ -58,7 +57,7 @@ def Popen_wait(self, timeout=None):
5857
time.sleep(0.01)
5958
return self.returncode
6059

61-
def Popen_communicate(self, input=None, timeout=None):
60+
def Popen_communicate(self, input=None, timeout=None): #@ReservedAssignment
6261
"""Interact with process.
6362
"""
6463
if timeout is not None:

0 commit comments

Comments
 (0)