Skip to content

Commit bf4c7a9

Browse files
committed
Linters are silly
1 parent d19403d commit bf4c7a9

File tree

3 files changed

+30
-19
lines changed

3 files changed

+30
-19
lines changed

mypy/main.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self) -> None:
2323
self.build_flags = [] # type: List[str]
2424
self.pyversion = 3
2525
self.custom_typing_module = None # type: str
26-
self.report_dirs = {} # type: Dict[str, str]
26+
self.report_dirs = {} # type: Dict[str, str]
2727
self.python_path = False
2828

2929

@@ -152,20 +152,22 @@ def process_options(args: List[str]) -> Tuple[str, str, str, Options]:
152152

153153
# Don't generate this from mypy.reports, not all are meant to be public.
154154
REPORTS = [
155-
'html',
156-
'old-html',
157-
'xslt-html',
158-
'xml',
159-
'txt',
160-
'xslt-txt',
155+
'html',
156+
'old-html',
157+
'xslt-html',
158+
'xml',
159+
'txt',
160+
'xslt-txt',
161161
]
162162

163+
163164
def is_report(arg: str) -> bool:
164165
if arg.startswith('--') and arg.endswith('-report'):
165166
report_type = arg[2:-7]
166167
return report_type in REPORTS
167168
return False
168169

170+
169171
def usage(msg: str = None) -> None:
170172
if msg:
171173
sys.stderr.write('%s\n' % msg)

mypy/report.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
from mypy import stats
1313

1414

15-
reporter_classes = {} # type: Dict[str, Callable[[Reports, str], AbstractReporter]]
15+
reporter_classes = {} # type: Dict[str, Callable[[Reports, str], AbstractReporter]]
1616

1717

1818
class Reports:
1919
def __init__(self, main_file: str, data_dir: str, report_dirs: Dict[str, str]) -> None:
2020
self.main_file = main_file
2121
self.data_dir = data_dir
22-
self.reporters = [] # type: List[AbstractReporter]
23-
self.named_reporters = {} # type: Dict[str, AbstractReporter]
22+
self.reporters = [] # type: List[AbstractReporter]
23+
self.named_reporters = {} # type: Dict[str, AbstractReporter]
2424

2525
for report_type, report_dir in sorted(report_dirs.items()):
2626
self.add_report(report_type, report_dir)
@@ -57,6 +57,7 @@ def on_file(self, tree: MypyFile, type_map: Dict[Node, Type]) -> None:
5757
def on_finish(self) -> None:
5858
pass
5959

60+
6061
class OldHtmlReporter(AbstractReporter):
6162
"""Old HTML reporter.
6263
@@ -71,6 +72,7 @@ def on_finish(self) -> None:
7172
stats.generate_html_index(self.output_dir)
7273
reporter_classes['old-html'] = OldHtmlReporter
7374

75+
7476
class FileInfo:
7577
def __init__(self, name: str, module: str) -> None:
7678
self.name = name
@@ -83,6 +85,7 @@ def total(self) -> int:
8385
def attrib(self) -> Dict[str, str]:
8486
return {name: str(val) for name, val in zip(stats.precision_names, self.counts)}
8587

88+
8689
class MemoryXmlReporter(AbstractReporter):
8790
"""Internal reporter that generates XML in memory.
8891
@@ -100,8 +103,8 @@ def __init__(self, reports: Reports, output_dir: str) -> None:
100103
self.css_html_path = os.path.join(reports.data_dir, 'xml', 'mypy-html.css')
101104
xsd_path = os.path.join(reports.data_dir, 'xml', 'mypy.xsd')
102105
self.schema = etree.XMLSchema(etree.parse(xsd_path))
103-
self.last_xml = None # type: etree._ElementTree
104-
self.files = [] # type: List[FileInfo]
106+
self.last_xml = None # type: etree._ElementTree
107+
self.files = [] # type: List[FileInfo]
105108

106109
def on_file(self, tree: MypyFile, type_map: Dict[Node, Type]) -> None:
107110
import lxml.etree as etree
@@ -133,7 +136,8 @@ def on_file(self, tree: MypyFile, type_map: Dict[Node, Type]) -> None:
133136
# Assumes a layout similar to what XmlReporter uses.
134137
xslt_path = os.path.relpath('mypy-html.xslt', path)
135138
xml_pi = etree.ProcessingInstruction('xml', 'version="1.0" encoding="utf-8"')
136-
transform_pi = etree.ProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="%s"' % cgi.escape(xslt_path, True))
139+
transform_pi = etree.ProcessingInstruction('xml-stylesheet',
140+
'type="text/xsl" href="%s"' % cgi.escape(xslt_path, True))
137141
root.addprevious(xml_pi)
138142
root.addprevious(transform_pi)
139143
self.schema.assertValid(doc)
@@ -145,7 +149,7 @@ def on_finish(self) -> None:
145149
import lxml.etree as etree
146150

147151
self.last_xml = None
148-
index_path = os.path.join(self.output_dir, 'index.xml')
152+
# index_path = os.path.join(self.output_dir, 'index.xml')
149153
output_files = sorted(self.files, key=lambda x: x.module)
150154

151155
root = etree.Element('mypy-report-index', name=self.main_file)
@@ -159,7 +163,8 @@ def on_finish(self) -> None:
159163
module=file_info.module)
160164
xslt_path = os.path.relpath('mypy-html.xslt', '.')
161165
xml_pi = etree.ProcessingInstruction('xml', 'version="1.0" encoding="utf-8"')
162-
transform_pi = etree.ProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="%s"' % cgi.escape(xslt_path, True))
166+
transform_pi = etree.ProcessingInstruction('xml-stylesheet',
167+
'type="text/xsl" href="%s"' % cgi.escape(xslt_path, True))
163168
root.addprevious(xml_pi)
164169
root.addprevious(transform_pi)
165170
self.schema.assertValid(doc)
@@ -168,6 +173,7 @@ def on_finish(self) -> None:
168173

169174
reporter_classes['memory-xml'] = MemoryXmlReporter
170175

176+
171177
class AbstractXmlReporter(AbstractReporter):
172178
"""Internal abstract class for reporters that work via XML."""
173179

@@ -178,6 +184,7 @@ def __init__(self, reports: Reports, output_dir: str) -> None:
178184
# The dependency will be called first.
179185
self.memory_xml = cast(MemoryXmlReporter, memory_reporter)
180186

187+
181188
class XmlReporter(AbstractXmlReporter):
182189
"""Public reporter that exports XML.
183190
@@ -211,6 +218,7 @@ def on_finish(self) -> None:
211218

212219
reporter_classes['xml'] = XmlReporter
213220

221+
214222
class XsltHtmlReporter(AbstractXmlReporter):
215223
"""Public reporter that exports HTML via XSLT.
216224
@@ -251,6 +259,7 @@ def on_finish(self) -> None:
251259

252260
reporter_classes['xslt-html'] = XsltHtmlReporter
253261

262+
254263
class XsltTxtReporter(AbstractXmlReporter):
255264
"""Public reporter that exports TXT via XSLT.
256265

mypy/stats.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
TYPE_ANY = 3
2525

2626
precision_names = [
27-
'empty',
28-
'precise',
29-
'imprecise',
30-
'any',
27+
'empty',
28+
'precise',
29+
'imprecise',
30+
'any',
3131
]
3232

3333

0 commit comments

Comments
 (0)