fix type issues

This commit is contained in:
Maximilian Keßler 2022-02-08 16:09:56 +01:00
parent ad39decb39
commit 91bcb64be5
2 changed files with 10 additions and 8 deletions

View file

@ -36,17 +36,19 @@ class Config:
@classmethod @classmethod
def from_json(cls, content: Union[Path, Dict]): def from_json(cls, content: Union[Path, Dict]):
if isinstance(content, Path): if isinstance(content, Path):
with open(content, 'r') as config: with open(content, 'r') as file:
content: Dict = json.load(config) json_content: Dict = json.load(file)
else:
json_content = content
config = cls() config = cls()
config.set_from_json(content) config.set_from_json(json_content)
return config return config
@classmethod @classmethod
def from_yaml(cls, path: Path): def from_yaml(cls, path: Path):
with open(path, 'r') as config: with open(path, 'r') as file:
path: Dict = yaml.safe_load(config) json_content: Dict = yaml.safe_load(file)
return cls.from_json(path) return cls.from_json(json_content)
def set_from_json(self, content: Optional[Dict]): def set_from_json(self, content: Optional[Dict]):
raise NotImplementedError raise NotImplementedError

View file

@ -56,8 +56,8 @@ class TexFormatter(PyTeXFormatter):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self._macros: List[Macro] = [] self._macros: List[Macro] = []
self._line_stream: LineStream = None self._line_stream: Optional[LineStream] = None
self._output_file: TextIO = None self._output_file: Optional[TextIO] = None
@property @property
def line_stream(self) -> LineStream: def line_stream(self) -> LineStream: