Skip to content
Snippets Groups Projects
Commit 3cb3f580 authored by Julien (jvoisin) Voisin's avatar Julien (jvoisin) Voisin
Browse files

Another typing pass

parent 39fb254e
No related branches found
No related tags found
1 merge request!103Another typing pass
Pipeline #127040 passed with warnings
......@@ -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.
......
......@@ -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:
......
......@@ -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.
......
......@@ -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__() + \
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment