fix some type errors

This commit is contained in:
Maximilian Keßler 2022-02-08 16:39:20 +01:00
parent 237203b149
commit b69019d814
2 changed files with 10 additions and 3 deletions

View file

@ -40,7 +40,7 @@ class DictFormatter(PyTeXFormatter):
with open(self.input_file, newline='') as csvfile:
spamreader = csv.reader(csvfile, delimiter=',', quotechar='|')
next(spamreader) # Skip languages line
translations = {}
translations: Dict = {}
for language in self._languages:
translations[language] = {}
for line in spamreader:
@ -54,7 +54,7 @@ class DictFormatter(PyTeXFormatter):
build_dir.mkdir(parents=True, exist_ok=True)
self.make_header()
for language in self._languages:
lines = [self.header, '']
lines: List[str] = [self.make_header(), '']
lines += r'\ProvidesDictionary{{{dict_name}}}{{{language}}}'.format(
dict_name=self._dict_name,
language=language

View file

@ -85,11 +85,16 @@ class TexFormatter(PyTeXFormatter):
self.write_line(line)
def write_line(self, line: str):
if self._output_file is None:
raise NotImplementedError
self._output_file.write(line)
def open_output_stream(self):
raise NotImplementedError
def close_output_stream(self):
raise NotImplementedError
@property
def future_config(self) -> Optional[List[Tuple[str, Dict]]]:
raise NotImplementedError
@ -98,6 +103,8 @@ class TexFormatter(PyTeXFormatter):
pass
def format_header(self):
if self._output_file is None:
raise NotImplementedError
self._output_file.write(self.make_header())
def format_post_header(self) -> None:
@ -121,5 +128,5 @@ class TexFormatter(PyTeXFormatter):
self.format_header()
self.format_post_header()
self.format_document()
self._output_file.close()
self.close_output_stream()
return self.future_config