diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-02-13 20:15:35 -0500 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-04-14 18:37:03 -0400 |
commit | bb171c2dffd64724803c9a43d7b01e80c3a96064 (patch) | |
tree | 247a84fba58b9e24c9f05c78cf9d8164f8f2d7a1 | |
parent | 906aec0df58c9b0fb411edca1934e7263e5d339f (diff) | |
download | meson-bb171c2dffd64724803c9a43d7b01e80c3a96064.zip meson-bb171c2dffd64724803c9a43d7b01e80c3a96064.tar.gz meson-bb171c2dffd64724803c9a43d7b01e80c3a96064.tar.bz2 |
pyupgrade --py37-plus
Some more old style code crept in again.
Additionally, pyupgrade learned to catch more if/elsed code based on the
python version, and delete it.
-rw-r--r-- | mesonbuild/mesonmain.py | 10 | ||||
-rwxr-xr-x | mesonbuild/msubprojects.py | 4 | ||||
-rw-r--r-- | mesonbuild/scripts/itstool.py | 4 |
3 files changed, 5 insertions, 13 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 5c24931..5e8cebd 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -22,7 +22,6 @@ import platform import importlib import traceback import argparse -import codecs import shutil from . import mesonlib @@ -207,14 +206,7 @@ def run_script_command(script_name, script_args): def ensure_stdout_accepts_unicode(): if sys.stdout.encoding and not sys.stdout.encoding.upper().startswith('UTF-'): - if sys.version_info >= (3, 7): - sys.stdout.reconfigure(errors='surrogateescape') - else: - sys.stdout = codecs.getwriter('utf-8')(sys.stdout.detach(), - errors='surrogateescape') - sys.stdout.encoding = 'UTF-8' - if not hasattr(sys.stdout, 'buffer'): - sys.stdout.buffer = sys.stdout.raw if hasattr(sys.stdout, 'raw') else sys.stdout + sys.stdout.reconfigure(errors='surrogateescape') def run(original_args, mainfile): if sys.version_info < (3, 7): diff --git a/mesonbuild/msubprojects.py b/mesonbuild/msubprojects.py index 4ce2358..455b6e7 100755 --- a/mesonbuild/msubprojects.py +++ b/mesonbuild/msubprojects.py @@ -52,10 +52,10 @@ ALL_TYPES_STRING = ', '.join(ALL_TYPES) def read_archive_files(path: Path, base_path: Path) -> T.Set[Path]: if path.suffix == '.zip': with zipfile.ZipFile(path, 'r') as zip_archive: - archive_files = set(base_path / i.filename for i in zip_archive.infolist()) + archive_files = {base_path / i.filename for i in zip_archive.infolist()} else: with tarfile.open(path) as tar_archive: # [ignore encoding] - archive_files = set(base_path / i.name for i in tar_archive) + archive_files = {base_path / i.name for i in tar_archive} return archive_files class Logger: diff --git a/mesonbuild/scripts/itstool.py b/mesonbuild/scripts/itstool.py index 72ac3e5..b23ad8a 100644 --- a/mesonbuild/scripts/itstool.py +++ b/mesonbuild/scripts/itstool.py @@ -40,10 +40,10 @@ def run_join(build_dir: str, itstool: str, its_files: T.List[str], mo_files: T.L locale_mo_files = [] for mo_file in mo_files: if not os.path.exists(mo_file): - print('Could not find mo file {}'.format(mo_file)) + print(f'Could not find mo file {mo_file}') return 1 if not mo_file.endswith('.mo'): - print('File is not a mo file: {}'.format(mo_file)) + print(f'File is not a mo file: {mo_file}') return 1 # determine locale of this mo file parts = mo_file.partition('LC_MESSAGES') |