1
0
mirror of synced 2024-12-22 04:39:58 +01:00

Another typing pass

This commit is contained in:
jvoisin 2023-01-28 17:22:26 +01:00
parent 39fb254e01
commit 3cb3f58084
5 changed files with 10 additions and 10 deletions

View File

@ -128,7 +128,7 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser):
# pylint: disable=unused-argument
return member
def get_meta(self) -> dict[str, Union[str, Dict]]:
def get_meta(self) -> Dict[str, Union[str, Dict]]:
meta = dict() # type: Dict[str, Union[str, Dict]]
with self.archive_class(self.filename) as zin:
@ -170,7 +170,7 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser):
# Sort the items to process, to reduce fingerprinting,
# and keep them in the `items` variable.
items = list() # type: list[ArchiveMember]
items = list() # type: List[ArchiveMember]
for item in sorted(self._get_all_members(zin), key=self._get_member_name):
# Some fileformats do require to have the `mimetype` file
# as the first file in the archive.

View File

@ -78,7 +78,7 @@ def _get_bwrap_args(tempdir: str,
return args
def run(args: list[str],
def run(args: List[str],
input_filename: str,
output_filename: Optional[str] = None,
**kwargs) -> subprocess.CompletedProcess:

View File

@ -148,7 +148,7 @@ class MSOfficeParser(ZipParser):
return False
xml_data = zin.read('[Content_Types].xml')
self.content_types = dict() # type: dict[str, str]
self.content_types = dict() # type: Dict[str, str]
try:
tree = ET.fromstring(xml_data)
except ET.ParseError:
@ -429,7 +429,7 @@ class MSOfficeParser(ZipParser):
return True
def _specific_get_meta(self, full_path: str, file_path: str) -> dict[str, Any]:
def _specific_get_meta(self, full_path: str, file_path: str) -> Dict[str, Any]:
"""
Yes, I know that parsing xml with regexp ain't pretty,
be my guest and fix it if you want.
@ -509,7 +509,7 @@ class LibreOfficeParser(ZipParser):
return False
return True
def _specific_get_meta(self, full_path: str, file_path: str) -> dict[str, Any]:
def _specific_get_meta(self, full_path: str, file_path: str) -> Dict[str, Any]:
"""
Yes, I know that parsing xml with regexp ain't pretty,
be my guest and fix it if you want.

View File

@ -2,7 +2,7 @@ import glob
import os
import mimetypes
import importlib
from typing import TypeVar, Optional
from typing import TypeVar, Optional, List
from . import abstract, UNSUPPORTED_EXTENSIONS
@ -34,7 +34,7 @@ def __load_all_parsers():
__load_all_parsers()
def _get_parsers() -> list[T]:
def _get_parsers() -> List[T]:
""" Get all our parsers!"""
def __get_parsers(cls):
return cls.__subclasses__() + \

4
mat2
View File

@ -2,7 +2,7 @@
import os
import shutil
from typing import List, Union, Set
from typing import List, Set, Dict
import sys
import mimetypes
import argparse
@ -98,7 +98,7 @@ def show_meta(filename: str, sandbox: bool):
__print_meta(filename, p.get_meta())
def __print_meta(filename: str, metadata: dict, depth: int = 1):
def __print_meta(filename: str, metadata: Dict, depth: int = 1):
padding = " " * depth*2
if not metadata:
__print_without_chars(padding + "No metadata found in %s." % filename)