diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2022-09-02 14:43:12 -0700 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2022-09-22 18:17:43 -0400 |
commit | f5283dd63fc40211a935330973a69aa8105aa920 (patch) | |
tree | c3ea862cb3d08ffcbe8ddaea9d70a42d6ee445de | |
parent | 3ef332e89a7050d0c03801099a0649e00c187278 (diff) | |
download | meson-f5283dd63fc40211a935330973a69aa8105aa920.zip meson-f5283dd63fc40211a935330973a69aa8105aa920.tar.gz meson-f5283dd63fc40211a935330973a69aa8105aa920.tar.bz2 |
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.
-rw-r--r-- | .pylintrc | 1 | ||||
-rw-r--r-- | mesonbuild/mesonlib/universal.py | 2 | ||||
-rw-r--r-- | mesonbuild/mintro.py | 4 | ||||
-rw-r--r-- | mesonbuild/mlog.py | 16 | ||||
-rw-r--r-- | mesonbuild/scripts/depfixer.py | 2 | ||||
-rw-r--r-- | mesonbuild/scripts/meson_exe.py | 3 | ||||
-rw-r--r-- | mesonbuild/scripts/symbolextractor.py | 2 | ||||
-rw-r--r-- | mesonbuild/wrap/wrap.py | 2 |
8 files changed, 13 insertions, 19 deletions
@@ -23,7 +23,6 @@ disable= duplicate-value, exec-used, fixme, - global-statement, implicit-str-concat, import-error, import-outside-toplevel, diff --git a/mesonbuild/mesonlib/universal.py b/mesonbuild/mesonlib/universal.py index 6f6daf4..f5a69a6 100644 --- a/mesonbuild/mesonlib/universal.py +++ b/mesonbuild/mesonlib/universal.py @@ -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'): diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index 154e603..2312674 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.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() diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index 1bdc1ca..452b693 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -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: diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py index e89efbb..e0090ac 100644 --- a/mesonbuild/scripts/depfixer.py +++ b/mesonbuild/scripts/depfixer.py @@ -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 diff --git a/mesonbuild/scripts/meson_exe.py b/mesonbuild/scripts/meson_exe.py index c8f2f3b..bb9d940 100644 --- a/mesonbuild/scripts/meson_exe.py +++ b/mesonbuild/scripts/meson_exe.py @@ -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, diff --git a/mesonbuild/scripts/symbolextractor.py b/mesonbuild/scripts/symbolextractor.py index 8992e94..565b467 100644 --- a/mesonbuild/scripts/symbolextractor.py +++ b/mesonbuild/scripts/symbolextractor.py @@ -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>') diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 25e96e6..3e2449f 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -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 |