diff options
| author | jvoisin | 2022-11-21 19:58:53 +0100 |
|---|---|---|
| committer | jvoisin | 2022-11-21 19:58:53 +0100 |
| commit | 29057d6cdf10ce4aa245acf2b3cbb93ba822c646 (patch) | |
| tree | 269b70beb311126dc35c24ff2f016e03361abf7b | |
| parent | 180ea24e5a050393051ffc8df1fcff8373f59783 (diff) | |
Simplify a bit the typing annotations of ./mat2
| -rwxr-xr-x | mat2 | 11 |
1 files changed, 5 insertions, 6 deletions
| @@ -2,7 +2,6 @@ | |||
| 2 | 2 | ||
| 3 | import os | 3 | import os |
| 4 | import shutil | 4 | import shutil |
| 5 | from typing import List, Union, Set | ||
| 6 | import sys | 5 | import sys |
| 7 | import mimetypes | 6 | import mimetypes |
| 8 | import argparse | 7 | import argparse |
| @@ -36,7 +35,7 @@ def __check_file(filename: str, mode: int = os.R_OK) -> bool: | |||
| 36 | __print_without_chars("[-] %s is not a regular file." % filename) | 35 | __print_without_chars("[-] %s is not a regular file." % filename) |
| 37 | return False | 36 | return False |
| 38 | elif not os.access(filename, mode): | 37 | elif not os.access(filename, mode): |
| 39 | mode_str = [] # type: List[str] | 38 | mode_str = [] # type: list[str] |
| 40 | if mode & os.R_OK: | 39 | if mode & os.R_OK: |
| 41 | mode_str += 'readable' | 40 | mode_str += 'readable' |
| 42 | if mode & os.W_OK: | 41 | if mode & os.W_OK: |
| @@ -152,10 +151,10 @@ def clean_meta(filename: str, is_lightweight: bool, inplace: bool, sandbox: bool | |||
| 152 | 151 | ||
| 153 | def show_parsers(): | 152 | def show_parsers(): |
| 154 | print('[+] Supported formats:') | 153 | print('[+] Supported formats:') |
| 155 | formats = set() # Set[str] | 154 | formats = set() # set[str] |
| 156 | for parser in parser_factory._get_parsers(): # type: ignore | 155 | for parser in parser_factory._get_parsers(): # type: ignore |
| 157 | for mtype in parser.mimetypes: | 156 | for mtype in parser.mimetypes: |
| 158 | extensions = set() # Set[str] | 157 | extensions = set() # set[str] |
| 159 | for extension in mimetypes.guess_all_extensions(mtype): | 158 | for extension in mimetypes.guess_all_extensions(mtype): |
| 160 | if extension not in UNSUPPORTED_EXTENSIONS: | 159 | if extension not in UNSUPPORTED_EXTENSIONS: |
| 161 | extensions.add(extension) | 160 | extensions.add(extension) |
| @@ -167,8 +166,8 @@ def show_parsers(): | |||
| 167 | __print_without_chars('\n'.join(sorted(formats))) | 166 | __print_without_chars('\n'.join(sorted(formats))) |
| 168 | 167 | ||
| 169 | 168 | ||
| 170 | def __get_files_recursively(files: List[str]) -> List[str]: | 169 | def __get_files_recursively(files: list[str]) -> list[str]: |
| 171 | ret = set() # type: Set[str] | 170 | ret = set() # type: set[str] |
| 172 | for f in files: | 171 | for f in files: |
| 173 | if os.path.isdir(f): | 172 | if os.path.isdir(f): |
| 174 | for path, _, _files in os.walk(f): | 173 | for path, _, _files in os.walk(f): |
