fix various flake8 whitespace errors

pull/9667/head
Eli Schwartz 3 years ago committed by Nirbheek Chauhan
parent 18abf2cebb
commit 5f5ebc7262
  1. 2
      mesonbuild/_typing.py
  2. 2
      mesonbuild/backend/ninjabackend.py
  3. 2
      mesonbuild/backend/xcodebackend.py
  4. 14
      mesonbuild/compilers/cuda.py
  5. 2
      mesonbuild/compilers/detect.py
  6. 2
      mesonbuild/compilers/mixins/visualstudio.py
  7. 2
      mesonbuild/coredata.py
  8. 6
      mesonbuild/interpreter/interpreter.py
  9. 1
      mesonbuild/interpreter/primitives/array.py
  10. 1
      mesonbuild/interpreter/primitives/integer.py
  11. 1
      mesonbuild/interpreterbase/baseobjects.py
  12. 2
      mesonbuild/interpreterbase/decorators.py
  13. 2
      mesonbuild/linkers/linkers.py
  14. 2
      mesonbuild/mcompile.py
  15. 12
      mesonbuild/mesonlib/universal.py
  16. 2
      mesonbuild/minstall.py
  17. 2
      mesonbuild/modules/gnome.py
  18. 2
      mesonbuild/modules/python.py
  19. 2
      mesonbuild/scripts/clangtidy.py
  20. 1
      mesonbuild/wrap/wrap.py

@ -55,7 +55,7 @@ class ImmutableListProtocol(Protocol[T]):
def __iter__(self) -> typing.Iterator[T]: ... def __iter__(self) -> typing.Iterator[T]: ...
@typing.overload @typing.overload
def __getitem__(self, index: int) -> T:... def __getitem__(self, index: int) -> T: ...
@typing.overload @typing.overload
def __getitem__(self, index: slice) -> typing.List[T]: ... def __getitem__(self, index: slice) -> typing.List[T]: ...

@ -1627,7 +1627,7 @@ class NinjaBackend(backends.Backend):
for gen in target.get_generated_sources(): for gen in target.get_generated_sources():
for ssrc in gen.get_outputs(): for ssrc in gen.get_outputs():
if isinstance(gen, GeneratedList): if isinstance(gen, GeneratedList):
ssrc = os.path.join(self.get_target_private_dir(target) , ssrc) ssrc = os.path.join(self.get_target_private_dir(target), ssrc)
else: else:
ssrc = os.path.join(gen.get_subdir(), ssrc) ssrc = os.path.join(gen.get_subdir(), ssrc)
if ssrc.endswith('.pyx'): if ssrc.endswith('.pyx'):

@ -256,7 +256,7 @@ class XCodeBackend(backends.Backend):
obj_path = f'{project}.build/{buildtype}/{tname}.build/Objects-normal/{arch}/{stem}.o' obj_path = f'{project}.build/{buildtype}/{tname}.build/Objects-normal/{arch}/{stem}.o'
return obj_path return obj_path
def get_extracted_obj_paths(self, target: build.BuildTarget, outputs: T.List[str])-> T.List[str]: def get_extracted_obj_paths(self, target: build.BuildTarget, outputs: T.List[str]) -> T.List[str]:
return outputs return outputs
def generate(self): def generate(self):

@ -171,7 +171,7 @@ class CudaCompiler(Compiler):
'--qpp-config': '-qpp-config', # 4.2.8.19 '--qpp-config': '-qpp-config', # 4.2.8.19
} }
# Reverse map -short to --long options. # Reverse map -short to --long options.
_FLAG_SHORT2LONG_WITHARGS = {v:k for k,v in _FLAG_LONG2SHORT_WITHARGS.items()} _FLAG_SHORT2LONG_WITHARGS = {v: k for k, v in _FLAG_LONG2SHORT_WITHARGS.items()}
def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice,
is_cross: bool, exe_wrapper: T.Optional['ExternalProgram'], is_cross: bool, exe_wrapper: T.Optional['ExternalProgram'],
@ -186,7 +186,7 @@ class CudaCompiler(Compiler):
self.warn_args = {level: self._to_host_flags(flags) for level, flags in host_compiler.warn_args.items()} self.warn_args = {level: self._to_host_flags(flags) for level, flags in host_compiler.warn_args.items()}
@classmethod @classmethod
def _shield_nvcc_list_arg(cls, arg: str, listmode: bool=True) -> str: def _shield_nvcc_list_arg(cls, arg: str, listmode: bool = True) -> str:
r""" r"""
Shield an argument against both splitting by NVCC's list-argument Shield an argument against both splitting by NVCC's list-argument
parse logic, and interpretation by any shell. parse logic, and interpretation by any shell.
@ -390,11 +390,11 @@ class CudaCompiler(Compiler):
val = next(flagit) # -o something val = next(flagit) # -o something
except StopIteration: except StopIteration:
pass pass
elif flag.split('=',1)[0] in self._FLAG_LONG2SHORT_WITHARGS or \ elif flag.split('=', 1)[0] in self._FLAG_LONG2SHORT_WITHARGS or \
flag.split('=',1)[0] in self._FLAG_SHORT2LONG_WITHARGS: flag.split('=', 1)[0] in self._FLAG_SHORT2LONG_WITHARGS:
# This is either -o or a multi-letter flag, and it is receiving its # This is either -o or a multi-letter flag, and it is receiving its
# value after an = sign. # value after an = sign.
flag, val = flag.split('=',1) # -o=something flag, val = flag.split('=', 1) # -o=something
# Some dependencies (e.g., BoostDependency) add unspaced "-isystem/usr/include" arguments # Some dependencies (e.g., BoostDependency) add unspaced "-isystem/usr/include" arguments
elif flag.startswith('-isystem'): elif flag.startswith('-isystem'):
val = flag[8:].strip() val = flag[8:].strip()
@ -427,9 +427,9 @@ class CudaCompiler(Compiler):
assert val is not None # Should only trip if there is a missing argument. assert val is not None # Should only trip if there is a missing argument.
# Take care of the various NVCC-supported flags that need special handling. # Take care of the various NVCC-supported flags that need special handling.
flag = self._FLAG_LONG2SHORT_WITHARGS.get(flag,flag) flag = self._FLAG_LONG2SHORT_WITHARGS.get(flag, flag)
if flag in {'-include','-isystem','-I','-L','-l'}: if flag in {'-include', '-isystem', '-I', '-L', '-l'}:
# These flags are known to GCC, but list-valued in NVCC. They potentially # These flags are known to GCC, but list-valued in NVCC. They potentially
# require double-quoting to prevent NVCC interpreting the flags as lists # require double-quoting to prevent NVCC interpreting the flags as lists
# when GCC would not have done so. # when GCC would not have done so.

@ -211,7 +211,7 @@ def compiler_from_language(env: 'Environment', lang: str, for_machine: MachineCh
} }
return lang_map[lang](env, for_machine) if lang in lang_map else None return lang_map[lang](env, for_machine) if lang in lang_map else None
def detect_compiler_for(env: 'Environment', lang: str, for_machine: MachineChoice)-> T.Optional[Compiler]: def detect_compiler_for(env: 'Environment', lang: str, for_machine: MachineChoice) -> T.Optional[Compiler]:
comp = compiler_from_language(env, lang, for_machine) comp = compiler_from_language(env, lang, for_machine)
if comp is not None: if comp is not None:
assert comp.for_machine == for_machine assert comp.for_machine == for_machine

@ -161,7 +161,7 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
return ['/c'] return ['/c']
def get_no_optimization_args(self) -> T.List[str]: def get_no_optimization_args(self) -> T.List[str]:
return ['/Od','/Oi-'] return ['/Od', '/Oi-']
def sanitizer_compile_args(self, value: str) -> T.List[str]: def sanitizer_compile_args(self, value: str) -> T.List[str]:
if value == 'none': if value == 'none':

@ -673,7 +673,7 @@ class CoreData:
self.deps.build.clear() self.deps.build.clear()
def get_nondefault_buildtype_args(self): def get_nondefault_buildtype_args(self):
result= [] result = []
value = self.options[OptionKey('buildtype')].value value = self.options[OptionKey('buildtype')].value
if value == 'plain': if value == 'plain':
opt = '0' opt = '0'

@ -619,7 +619,7 @@ class Interpreter(InterpreterBase, HoldableObject):
@FeatureNewKwargs('declare_dependency', '0.54.0', ['variables']) @FeatureNewKwargs('declare_dependency', '0.54.0', ['variables'])
@permittedKwargs({'include_directories', 'link_with', 'sources', 'dependencies', @permittedKwargs({'include_directories', 'link_with', 'sources', 'dependencies',
'compile_args', 'link_args', 'link_whole', 'version', 'compile_args', 'link_args', 'link_whole', 'version',
'variables' }) 'variables'})
@noPosargs @noPosargs
def func_declare_dependency(self, node, args, kwargs): def func_declare_dependency(self, node, args, kwargs):
version = kwargs.get('version', self.project_version) version = kwargs.get('version', self.project_version)
@ -815,7 +815,7 @@ external dependencies (including libraries) must go to "dependencies".''')
m = ['\nExecuting subproject', mlog.bold(stack)] m = ['\nExecuting subproject', mlog.bold(stack)]
if method != 'meson': if method != 'meson':
m += ['method', mlog.bold(method)] m += ['method', mlog.bold(method)]
mlog.log(*m,'\n', nested=False) mlog.log(*m, '\n', nested=False)
try: try:
if method == 'meson': if method == 'meson':
@ -1459,7 +1459,7 @@ external dependencies (including libraries) must go to "dependencies".''')
def find_program_fallback(self, fallback, args, required, extra_info): def find_program_fallback(self, fallback, args, required, extra_info):
mlog.log('Fallback to subproject', mlog.bold(fallback), 'which provides program', mlog.log('Fallback to subproject', mlog.bold(fallback), 'which provides program',
mlog.bold(' '.join(args))) mlog.bold(' '.join(args)))
sp_kwargs = { 'required': required } sp_kwargs = {'required': required}
self.do_subproject(fallback, 'meson', sp_kwargs) self.do_subproject(fallback, 'meson', sp_kwargs)
return self.program_from_overrides(args, extra_info) return self.program_from_overrides(args, extra_info)

@ -34,7 +34,6 @@ class ArrayHolder(ObjectHolder[T.List[TYPE_var]], IterableObject):
'get': self.get_method, 'get': self.get_method,
}) })
self.trivial_operators.update({ self.trivial_operators.update({
MesonOperator.EQUALS: (list, lambda x: self.held_object == x), MesonOperator.EQUALS: (list, lambda x: self.held_object == x),
MesonOperator.NOT_EQUALS: (list, lambda x: self.held_object != x), MesonOperator.NOT_EQUALS: (list, lambda x: self.held_object != x),

@ -80,4 +80,3 @@ class IntegerHolder(ObjectHolder[int]):
if other == 0: if other == 0:
raise InvalidArguments('Tried to divide by 0') raise InvalidArguments('Tried to divide by 0')
return self.held_object % other return self.held_object % other

@ -42,6 +42,7 @@ TYPE_key_resolver = T.Callable[[mparser.BaseNode], str]
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from typing_extensions import Protocol from typing_extensions import Protocol
__T = T.TypeVar('__T', bound=TYPE_var, contravariant=True) __T = T.TypeVar('__T', bound=TYPE_var, contravariant=True)
class OperatorCall(Protocol[__T]): class OperatorCall(Protocol[__T]):
def __call__(self, other: __T) -> TYPE_var: ... def __call__(self, other: __T) -> TYPE_var: ...

@ -297,7 +297,7 @@ class ContainerTypeInfo:
""" """
def __init__(self, container: T.Type, contains: T.Union[T.Type, T.Tuple[T.Type, ...]], *, def __init__(self, container: T.Type, contains: T.Union[T.Type, T.Tuple[T.Type, ...]], *,
pairs: bool = False, allow_empty: bool = True) : pairs: bool = False, allow_empty: bool = True):
self.container = container self.container = container
self.contains = contains self.contains = contains
self.pairs = pairs self.pairs = pairs

@ -1380,7 +1380,7 @@ class AIXDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):
if len(sys_path) == 0: if len(sys_path) == 0:
# get_compiler_system_dirs doesn't support our compiler. # get_compiler_system_dirs doesn't support our compiler.
# Use the default system library path # Use the default system library path
all_paths.update(['/usr/lib','/lib']) all_paths.update(['/usr/lib', '/lib'])
else: else:
# Include the compiler's default library paths, but filter out paths that don't exist # Include the compiler's default library paths, but filter out paths that don't exist
for p in sys_path: for p in sys_path:

@ -38,7 +38,7 @@ def array_arg(value: str) -> T.List[str]:
return UserArrayOption(None, value, allow_dups=True, user_input=True).value return UserArrayOption(None, value, allow_dups=True, user_input=True).value
def validate_builddir(builddir: Path) -> None: def validate_builddir(builddir: Path) -> None:
if not (builddir / 'meson-private' / 'coredata.dat' ).is_file(): if not (builddir / 'meson-private' / 'coredata.dat').is_file():
raise MesonException(f'Current directory is not a meson build directory: `{builddir}`.\n' raise MesonException(f'Current directory is not a meson build directory: `{builddir}`.\n'
'Please specify a valid build dir or change the working directory to it.\n' 'Please specify a valid build dir or change the working directory to it.\n'
'It is also possible that the build directory was generated with an old\n' 'It is also possible that the build directory was generated with an old\n'

@ -1132,7 +1132,7 @@ def do_replacement(regex: T.Pattern[str], line: str, variable_format: str,
def do_define(regex: T.Pattern[str], line: str, confdata: 'ConfigurationData', variable_format: str) -> str: def do_define(regex: T.Pattern[str], line: str, confdata: 'ConfigurationData', variable_format: str) -> str:
def get_cmake_define(line: str, confdata: 'ConfigurationData') -> str: def get_cmake_define(line: str, confdata: 'ConfigurationData') -> str:
arr = line.split() arr = line.split()
define_value=[] define_value = []
for token in arr[2:]: for token in arr[2:]:
try: try:
(v, desc) = confdata.get(token) (v, desc) = confdata.get(token)
@ -1179,13 +1179,13 @@ def get_variable_regex(variable_format: str = 'meson') -> T.Pattern[str]:
raise MesonException(f'Format "{variable_format}" not handled') raise MesonException(f'Format "{variable_format}" not handled')
return regex return regex
def do_conf_str (src: str, data: list, confdata: 'ConfigurationData', variable_format: str, def do_conf_str(src: str, data: list, confdata: 'ConfigurationData', variable_format: str,
encoding: str = 'utf-8') -> T.Tuple[T.List[str],T.Set[str], bool]: encoding: str = 'utf-8') -> T.Tuple[T.List[str], T.Set[str], bool]:
def line_is_valid(line : str, variable_format: str) -> bool: def line_is_valid(line: str, variable_format: str) -> bool:
if variable_format == 'meson': if variable_format == 'meson':
if '#cmakedefine' in line: if '#cmakedefine' in line:
return False return False
else: #cmake format else: # cmake format
if '#mesondefine' in line: if '#mesondefine' in line:
return False return False
return True return True
@ -1206,7 +1206,7 @@ def do_conf_str (src: str, data: list, confdata: 'ConfigurationData', variable_f
confdata_useless = False confdata_useless = False
line = do_define(regex, line, confdata, variable_format) line = do_define(regex, line, confdata, variable_format)
else: else:
if not line_is_valid(line,variable_format): if not line_is_valid(line, variable_format):
raise MesonException(f'Format error in {src}: saw "{line.strip()}" when format set to "{variable_format}"') raise MesonException(f'Format error in {src}: saw "{line.strip()}" when format set to "{variable_format}"')
line, missing = do_replacement(regex, line, variable_format, confdata) line, missing = do_replacement(regex, line, variable_format, confdata)
missing_variables.update(missing) missing_variables.update(missing)

@ -238,7 +238,7 @@ def restore_selinux_contexts() -> None:
return return
proc, out, err = Popen_safe(['restorecon', '-F', '-f-', '-0'], ('\0'.join(f for f in selinux_updates) + '\0')) proc, out, err = Popen_safe(['restorecon', '-F', '-f-', '-0'], ('\0'.join(f for f in selinux_updates) + '\0'))
if proc.returncode != 0 : if proc.returncode != 0:
print('Failed to restore SELinux context of installed files...', print('Failed to restore SELinux context of installed files...',
'Standard output:', out, 'Standard output:', out,
'Standard error:', err, sep='\n') 'Standard error:', err, sep='\n')

@ -162,7 +162,7 @@ class GnomeModule(ExtensionModule):
if not found: if not found:
prog = self._get_native_binary(state, 'gtk-update-icon-cache', 'gtk+-3.0', 'gtk_update_icon_cache') prog = self._get_native_binary(state, 'gtk-update-icon-cache', 'gtk+-3.0', 'gtk_update_icon_cache')
icondir = os.path.join(datadir_abs, 'icons', 'hicolor') icondir = os.path.join(datadir_abs, 'icons', 'hicolor')
script = state.backend.get_executable_serialisation([prog, '-q', '-t' ,'-f', icondir]) script = state.backend.get_executable_serialisation([prog, '-q', '-t', '-f', icondir])
script.skip_if_destdir = True script.skip_if_destdir = True
rv.append(script) rv.append(script)
if kwargs['update_desktop_database'] and not self.install_update_desktop_database: if kwargs['update_desktop_database'] and not self.install_update_desktop_database:

@ -338,7 +338,7 @@ if T.TYPE_CHECKING:
link_libpython: bool link_libpython: bool
paths: T.Dict[str, str] paths: T.Dict[str, str]
platform: str platform: str
suffix : str suffix: str
variables: T.Dict[str, str] variables: T.Dict[str, str]
version: str version: str

@ -46,7 +46,7 @@ def clangtidy(srcdir_name: str, builddir_name: str) -> int:
run_clang_tidy = rct run_clang_tidy = rct
break break
if run_clang_tidy: if run_clang_tidy:
return subprocess.run([run_clang_tidy, '-p', builddir_name, '^(?!' + re.escape(builddir_name + os.path.sep) +').*$']).returncode return subprocess.run([run_clang_tidy, '-p', builddir_name, '^(?!' + re.escape(builddir_name + os.path.sep) + ').*$']).returncode
else: else:
print('Could not find run-clang-tidy, running checks manually.') print('Could not find run-clang-tidy, running checks manually.')
return manual_clangtidy(srcdir_name, builddir_name) return manual_clangtidy(srcdir_name, builddir_name)

@ -151,7 +151,6 @@ class PackageDefinition:
if f'{what}_filename' in self.values and f'{what}_url' not in self.values: if f'{what}_filename' in self.values and f'{what}_url' not in self.values:
FeatureNew(f'Local wrap patch files without {what}_url', '0.55.0').use(self.subproject) FeatureNew(f'Local wrap patch files without {what}_url', '0.55.0').use(self.subproject)
def parse_wrap_section(self, config: configparser.ConfigParser) -> None: def parse_wrap_section(self, config: configparser.ConfigParser) -> None:
if len(config.sections()) < 1: if len(config.sections()) < 1:
raise WrapException(f'Missing sections in {self.basename}') raise WrapException(f'Missing sections in {self.basename}')

Loading…
Cancel
Save