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.
pull/10278/head
Eli Schwartz 3 years ago
parent 906aec0df5
commit bb171c2dff
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 10
      mesonbuild/mesonmain.py
  2. 4
      mesonbuild/msubprojects.py
  3. 4
      mesonbuild/scripts/itstool.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):

@ -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:

@ -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')

Loading…
Cancel
Save