diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2021-03-04 17:02:31 -0500 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2021-03-04 17:11:26 -0500 |
commit | 4340bf34faca7eed8076ba4c388fbe15355f2183 (patch) | |
tree | 6082548a6cb79091d1059a73e7b3b9f59657f6d9 /mesonbuild/modules | |
parent | 76df995ba69ef5d790462856b3edbd42b28b906a (diff) | |
download | meson-4340bf34faca7eed8076ba4c388fbe15355f2183.zip meson-4340bf34faca7eed8076ba4c388fbe15355f2183.tar.gz meson-4340bf34faca7eed8076ba4c388fbe15355f2183.tar.bz2 |
various python neatness cleanups
All changes were created by running
"pyupgrade --py3-only --keep-percent-format"
and committing the results. I have not touched string formatting for
now.
- use set literals
- simplify .format() parameter naming
- remove __future__
- remove default "r" mode for open()
- use OSError rather than compatibility aliases
- remove stray parentheses in function(generator) scopes
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r-- | mesonbuild/modules/cmake.py | 4 | ||||
-rw-r--r-- | mesonbuild/modules/dlang.py | 2 | ||||
-rw-r--r-- | mesonbuild/modules/fs.py | 2 | ||||
-rw-r--r-- | mesonbuild/modules/keyval.py | 2 | ||||
-rw-r--r-- | mesonbuild/modules/python.py | 6 |
5 files changed, 8 insertions, 8 deletions
diff --git a/mesonbuild/modules/cmake.py b/mesonbuild/modules/cmake.py index dc45e71..18dc2f5 100644 --- a/mesonbuild/modules/cmake.py +++ b/mesonbuild/modules/cmake.py @@ -235,7 +235,7 @@ class CmakeModule(ExtensionModule): cmakebin = dependencies.ExternalProgram('cmake', silent=False) p, stdout, stderr = mesonlib.Popen_safe(cmakebin.get_command() + ['--system-information', '-G', 'Ninja'])[0:3] if p.returncode != 0: - mlog.log('error retrieving cmake information: returnCode={0} stdout={1} stderr={2}'.format(p.returncode, stdout, stderr)) + mlog.log('error retrieving cmake information: returnCode={} stdout={} stderr={}'.format(p.returncode, stdout, stderr)) return False match = re.search('\nCMAKE_ROOT \\"([^"]+)"\n', stdout.strip()) @@ -295,7 +295,7 @@ class CmakeModule(ExtensionModule): package_init += PACKAGE_INIT_SET_AND_CHECK try: - with open(infile, "r") as fin: + with open(infile) as fin: data = fin.readlines() except Exception as e: raise mesonlib.MesonException('Could not read input file %s: %s' % (infile, str(e))) diff --git a/mesonbuild/modules/dlang.py b/mesonbuild/modules/dlang.py index d4f62e4..55ff304 100644 --- a/mesonbuild/modules/dlang.py +++ b/mesonbuild/modules/dlang.py @@ -70,7 +70,7 @@ class DlangModule(ExtensionModule): config_path = os.path.join(args[1], 'dub.json') if os.path.exists(config_path): - with open(config_path, 'r', encoding='utf8') as ofile: + with open(config_path, encoding='utf8') as ofile: try: config = json.load(ofile) except ValueError: diff --git a/mesonbuild/modules/fs.py b/mesonbuild/modules/fs.py index 7de8cf7..fd1e99b 100644 --- a/mesonbuild/modules/fs.py +++ b/mesonbuild/modules/fs.py @@ -211,7 +211,7 @@ class FSModule(ExtensionModule): if path_is_in_root(Path(path), Path(build_dir), resolve=True): raise MesonException('path must not be in the build tree') try: - with open(path, 'r', encoding=encoding) as f: + with open(path, encoding=encoding) as f: data = f.read() except UnicodeDecodeError: raise MesonException(f'decoding failed for {path}') diff --git a/mesonbuild/modules/keyval.py b/mesonbuild/modules/keyval.py index 3da2992..8e1a89f 100644 --- a/mesonbuild/modules/keyval.py +++ b/mesonbuild/modules/keyval.py @@ -42,7 +42,7 @@ class KeyvalModule(ExtensionModule): except ValueError: continue result[name.strip()] = val.strip() - except IOError as e: + except OSError as e: raise mesonlib.MesonException('Failed to load {}: {}'.format(path_to_config, e)) return result diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index cfe2244..d05c72a 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -36,9 +36,9 @@ from ..dependencies.base import ( NonExistingExternalProgram, NotFoundDependency ) -mod_kwargs = set(['subdir']) +mod_kwargs = {'subdir'} mod_kwargs.update(known_shmod_kwargs) -mod_kwargs -= set(['name_prefix', 'name_suffix']) +mod_kwargs -= {'name_prefix', 'name_suffix'} class PythonDependency(ExternalDependency): @@ -544,7 +544,7 @@ class PythonModule(ExtensionModule): for mod in want_modules: p, out, err = mesonlib.Popen_safe( python.command + - ['-c', 'import {0}'.format(mod)]) + ['-c', 'import {}'.format(mod)]) if p.returncode != 0: missing_modules.append(mod) else: |