pylint: enable global-statement

This does force a number of uses of `# pylint: disable` comments, but it
also finds a couple of useless global uses and one place (in the
previous commit) that an easy refactor removes the use of global. Global
is a code smell, so forcing adding a comment to disable helps force
developers to really consider if what they're doing is a good idea.
pull/10842/head
Dylan Baker 2 years ago committed by Xavier Claessens
parent 3ef332e89a
commit f5283dd63f
  1. 1
      .pylintrc
  2. 2
      mesonbuild/mesonlib/universal.py
  3. 4
      mesonbuild/mintro.py
  4. 16
      mesonbuild/mlog.py
  5. 2
      mesonbuild/scripts/depfixer.py
  6. 3
      mesonbuild/scripts/meson_exe.py
  7. 2
      mesonbuild/scripts/symbolextractor.py
  8. 2
      mesonbuild/wrap/wrap.py

@ -23,7 +23,6 @@ disable=
duplicate-value,
exec-used,
fixme,
global-statement,
implicit-str-concat,
import-error,
import-outside-toplevel,

@ -229,7 +229,7 @@ def verbose_git(cmd: T.List[str], workingdir: T.Union[str, bytes, os.PathLike],
return p.returncode == 0
def set_meson_command(mainfile: str) -> None:
global _meson_command
global _meson_command # pylint: disable=global-statement
# On UNIX-like systems `meson` is a Python script
# On Windows `meson` and `meson.exe` are wrapper exes
if not mainfile.endswith('.py'):

@ -504,7 +504,6 @@ def run(options: argparse.Namespace) -> int:
updated_introspection_files = [] # type: T.List[str]
def write_intro_info(intro_info: T.Sequence[T.Tuple[str, T.Union[dict, T.List[T.Any]]]], info_dir: str) -> None:
global updated_introspection_files
for kind, data in intro_info:
out_file = os.path.join(info_dir, f'intro-{kind}.json')
tmp_file = os.path.join(info_dir, 'tmp_dump.json')
@ -512,7 +511,7 @@ def write_intro_info(intro_info: T.Sequence[T.Tuple[str, T.Union[dict, T.List[T.
json.dump(data, fp)
fp.flush() # Not sure if this is needed
os.replace(tmp_file, out_file)
updated_introspection_files += [kind]
updated_introspection_files.append(kind)
def generate_introspection_file(builddata: build.Build, backend: backends.Backend) -> None:
coredata = builddata.environment.get_coredata()
@ -543,7 +542,6 @@ def split_version_string(version: str) -> T.Dict[str, T.Union[str, int]]:
}
def write_meson_info_file(builddata: build.Build, errors: list, build_files_updated: bool = False) -> None:
global updated_introspection_files
info_dir = builddata.environment.info_dir
info_file = get_meson_info_file(info_dir)
intro_types = get_meson_introspection_types()

@ -85,33 +85,33 @@ log_warnings_counter = 0 # type: int
log_pager: T.Optional['subprocess.Popen'] = None
def disable() -> None:
global log_disable_stdout
global log_disable_stdout # pylint: disable=global-statement
log_disable_stdout = True
def enable() -> None:
global log_disable_stdout
global log_disable_stdout # pylint: disable=global-statement
log_disable_stdout = False
def set_quiet() -> None:
global log_errors_only
global log_errors_only # pylint: disable=global-statement
log_errors_only = True
def set_verbose() -> None:
global log_errors_only
global log_errors_only # pylint: disable=global-statement
log_errors_only = False
def initialize(logdir: str, fatal_warnings: bool = False) -> None:
global log_dir, log_file, log_fatal_warnings
global log_dir, log_file, log_fatal_warnings # pylint: disable=global-statement
log_dir = logdir
log_file = open(os.path.join(logdir, log_fname), 'w', encoding='utf-8')
log_fatal_warnings = fatal_warnings
def set_timestamp_start(start: float) -> None:
global log_timestamp_start
global log_timestamp_start # pylint: disable=global-statement
log_timestamp_start = start
def shutdown() -> T.Optional[str]:
global log_file
global log_file # pylint: disable=global-statement
if log_file is not None:
path = log_file.name
exception_around_goer = log_file
@ -333,7 +333,7 @@ def _log_error(severity: str, *rargs: TV_Loggable,
log(*args, once=once, **kwargs)
global log_warnings_counter
global log_warnings_counter # pylint: disable=global-statement
log_warnings_counter += 1
if log_fatal_warnings and fatal:

@ -470,7 +470,7 @@ def fix_jar(fname: str) -> None:
subprocess.check_call(['jar', 'ufm', fname, 'META-INF/MANIFEST.MF'])
def fix_rpath(fname: str, rpath_dirs_to_remove: T.Set[bytes], new_rpath: T.Union[str, bytes], final_path: str, install_name_mappings: T.Dict[str, str], verbose: bool = True) -> None:
global INSTALL_NAME_TOOL
global INSTALL_NAME_TOOL # pylint: disable=global-statement
# Static libraries, import libraries, debug information, headers, etc
# never have rpaths
# DLLs and EXE currently do not need runtime path fixing

@ -23,8 +23,6 @@ import locale
from .. import mesonlib
from ..backend.backends import ExecutableSerialisation
options = None
def buildparser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description='Custom executable wrapper for Meson. Do not run on your own, mmm\'kay?')
parser.add_argument('--unpickle')
@ -102,7 +100,6 @@ def run_exe(exe: ExecutableSerialisation, extra_env: T.Optional[T.Dict[str, str]
return 0
def run(args: T.List[str]) -> int:
global options
parser = buildparser()
options, cmd_args = parser.parse_known_args(args)
# argparse supports double dash to separate options and positional arguments,

@ -315,7 +315,7 @@ def gen_symbols(libfilename: str, impfilename: str, outfilename: str, cross_host
dummy_syms(outfilename)
def run(args: T.List[str]) -> int:
global TOOL_WARNING_FILE
global TOOL_WARNING_FILE # pylint: disable=global-statement
options = parser.parse_args(args)
if len(options.args) != 4:
print('symbolextractor.py <shared library file> <import library> <output file>')

@ -93,7 +93,7 @@ def open_wrapdburl(urlstring: str, allow_insecure: bool = False, have_opt: bool
raise WrapException(f'SSL module not available in {sys.executable}: Cannot contact the WrapDB.{insecure_msg}')
else:
# following code is only for those without Python SSL
global SSL_WARNING_PRINTED
global SSL_WARNING_PRINTED # pylint: disable=global-statement
if not SSL_WARNING_PRINTED:
mlog.warning(f'SSL module not available in {sys.executable}: WrapDB traffic not authenticated.')
SSL_WARNING_PRINTED = True

Loading…
Cancel
Save