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
def from_json(cls, content: Union[Path, Dict]):
if isinstance(content, Path):
with open(content, 'r') as config:
content: Dict = json.load(config)
with open(content, 'r') as file:
json_content: Dict = json.load(file)
else:
json_content = content
config = cls()
config.set_from_json(content)
config.set_from_json(json_content)
return config
@classmethod
def from_yaml(cls, path: Path):
with open(path, 'r') as config:
path: Dict = yaml.safe_load(config)
return cls.from_json(path)
with open(path, 'r') as file:
json_content: Dict = yaml.safe_load(file)
return cls.from_json(json_content)
def set_from_json(self, content: Optional[Dict]):
raise NotImplementedError

View file

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