aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2021-03-04 17:02:31 -0500
committerEli Schwartz <eschwartz@archlinux.org>2021-03-04 17:11:26 -0500
commit4340bf34faca7eed8076ba4c388fbe15355f2183 (patch)
tree6082548a6cb79091d1059a73e7b3b9f59657f6d9 /mesonbuild/compilers/compilers.py
parent76df995ba69ef5d790462856b3edbd42b28b906a (diff)
downloadmeson-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/compilers/compilers.py')
-rw-r--r--mesonbuild/compilers/compilers.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index a37e4da..56c97f4 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -762,7 +762,7 @@ class Compiler(metaclass=abc.ABCMeta):
contents = code
elif isinstance(code, mesonlib.File):
srcname = code.fname
- with open(code.fname, 'r') as f:
+ with open(code.fname) as f:
contents = f.read()
# Construct the compiler command-line
@@ -1009,16 +1009,16 @@ class Compiler(metaclass=abc.ABCMeta):
return []
def get_crt_compile_args(self, crt_val: str, buildtype: str) -> T.List[str]:
- raise EnvironmentError('This compiler does not support Windows CRT selection')
+ raise OSError('This compiler does not support Windows CRT selection')
def get_crt_link_args(self, crt_val: str, buildtype: str) -> T.List[str]:
- raise EnvironmentError('This compiler does not support Windows CRT selection')
+ raise OSError('This compiler does not support Windows CRT selection')
def get_compile_only_args(self) -> T.List[str]:
return []
def get_preprocess_only_args(self) -> T.List[str]:
- raise EnvironmentError('This compiler does not have a preprocessor')
+ raise OSError('This compiler does not have a preprocessor')
def get_default_include_dirs(self) -> T.List[str]:
return []
@@ -1095,7 +1095,7 @@ class Compiler(metaclass=abc.ABCMeta):
return objfile + '.' + self.get_depfile_suffix()
def get_depfile_suffix(self) -> str:
- raise EnvironmentError('{} does not implement get_depfile_suffix'.format(self.id))
+ raise OSError('{} does not implement get_depfile_suffix'.format(self.id))
def get_no_stdinc_args(self) -> T.List[str]:
"""Arguments to turn off default inclusion of standard libraries."""
@@ -1112,13 +1112,13 @@ class Compiler(metaclass=abc.ABCMeta):
pass
def get_module_incdir_args(self) -> T.Tuple[str, ...]:
- raise EnvironmentError('{} does not implement get_module_incdir_args'.format(self.id))
+ raise OSError('{} does not implement get_module_incdir_args'.format(self.id))
def get_module_outdir_args(self, path: str) -> T.List[str]:
- raise EnvironmentError('{} does not implement get_module_outdir_args'.format(self.id))
+ raise OSError('{} does not implement get_module_outdir_args'.format(self.id))
def module_name_to_filename(self, module_name: str) -> str:
- raise EnvironmentError('{} does not implement module_name_to_filename'.format(self.id))
+ raise OSError('{} does not implement module_name_to_filename'.format(self.id))
def get_compiler_check_args(self, mode: CompileCheckMode) -> T.List[str]:
"""Arguments to pass the compiler and/or linker for checks.
@@ -1212,7 +1212,7 @@ class Compiler(metaclass=abc.ABCMeta):
def get_feature_args(self, kwargs: T.Dict[str, T.Any], build_to_src: str) -> T.List[str]:
"""Used by D for extra language features."""
# TODO: using a TypeDict here would improve this
- raise EnvironmentError('{} does not implement get_feature_args'.format(self.id))
+ raise OSError('{} does not implement get_feature_args'.format(self.id))
def get_prelink_args(self, prelink_name: str, obj_list: T.List[str]) -> T.List[str]:
raise EnvironmentException('{} does not know how to do prelinking.'.format(self.id))