From cd5dba5358e8a4f7a9d4a1ebf315db1f65c87180 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sat, 3 Mar 2018 15:56:33 +0000 Subject: Fix flake8 'imported but unused' reports $ flake8 | grep F401 ./meson.py:17:1: F401 'mesonbuild.mesonlib' imported but unused ./meson.py:18:1: F401 'locale' imported but unused ./run_unittests.py:24:1: F401 'sys' imported but unused ./mesonbuild/minit.py:2:1: F401 'pyclbr.Function' imported but unused ./mesonbuild/minit.py:18:1: F401 'os' imported but unused ./mesonbuild/backend/vs2010backend.py:15:1: F401 'sys' imported but unused ./mesonbuild/backend/xcodebackend.py:19:1: F401 'sys' imported but unused ./mesonbuild/dependencies/ui.py:20:1: F401 'shutil' imported but unused ./mesonbuild/modules/python3.py:15:1: F401 'sys' imported but unused ./mesonbuild/modules/unstable_icestorm.py:15:1: F401 '..compilers' imported but unused ./mesonbuild/modules/unstable_icestorm.py:15:1: F401 '..mlog' imported but unused ./test cases/common/98 gen extra/srcgen3.py:3:1: F401 'os' imported but unused --- meson.py | 4 ++-- mesonbuild/backend/vs2010backend.py | 2 +- mesonbuild/backend/xcodebackend.py | 2 +- mesonbuild/dependencies/ui.py | 1 - mesonbuild/minit.py | 3 +-- mesonbuild/modules/python3.py | 1 - mesonbuild/modules/unstable_icestorm.py | 2 +- run_unittests.py | 1 - test cases/common/98 gen extra/srcgen3.py | 1 - 9 files changed, 6 insertions(+), 11 deletions(-) diff --git a/meson.py b/meson.py index 13bc870e6..abbac6f4a 100755 --- a/meson.py +++ b/meson.py @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mesonbuild import mesonmain, mesonlib -import sys, os, locale +from mesonbuild import mesonmain +import sys, os def main(): # Always resolve the command path so Ninja can find it for regen, tests, etc. diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 057e7c9e9..7f4c2ef95 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os, sys +import os import pickle import xml.dom.minidom import xml.etree.ElementTree as ET diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py index 3ae31e4c5..fae58898a 100644 --- a/mesonbuild/backend/xcodebackend.py +++ b/mesonbuild/backend/xcodebackend.py @@ -16,7 +16,7 @@ from . import backends from .. import build from .. import dependencies from .. import mesonlib -import uuid, os, sys +import uuid, os from ..mesonlib import MesonException diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index 3e2d1707b..a84decfcf 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -17,7 +17,6 @@ import os import re -import shutil import subprocess from collections import OrderedDict diff --git a/mesonbuild/minit.py b/mesonbuild/minit.py index 98817cba4..62e2639ae 100644 --- a/mesonbuild/minit.py +++ b/mesonbuild/minit.py @@ -1,5 +1,4 @@ # Copyright 2017 The Meson development team -from pyclbr import Function # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +14,7 @@ from pyclbr import Function """Code that creates simple startup projects.""" -import os, sys, argparse, re +import sys, argparse, re from glob import glob lib_h_template = '''#pragma once diff --git a/mesonbuild/modules/python3.py b/mesonbuild/modules/python3.py index 989e839a9..9fd9f8098 100644 --- a/mesonbuild/modules/python3.py +++ b/mesonbuild/modules/python3.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys import sysconfig from .. import mesonlib, dependencies diff --git a/mesonbuild/modules/unstable_icestorm.py b/mesonbuild/modules/unstable_icestorm.py index 0b7b33959..761d583d9 100644 --- a/mesonbuild/modules/unstable_icestorm.py +++ b/mesonbuild/modules/unstable_icestorm.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .. import mesonlib, compilers, mlog +from .. import mesonlib from . import ExtensionModule diff --git a/run_unittests.py b/run_unittests.py index b69aaae2c..a6d28c850 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -21,7 +21,6 @@ import tempfile import textwrap import os import shutil -import sys import unittest from unittest import mock from configparser import ConfigParser diff --git a/test cases/common/98 gen extra/srcgen3.py b/test cases/common/98 gen extra/srcgen3.py index ad0a5cb09..b7371143a 100644 --- a/test cases/common/98 gen extra/srcgen3.py +++ b/test cases/common/98 gen extra/srcgen3.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -import os import sys import argparse -- cgit v1.2.3 From b8b23f4c50f0d702bc463dffd12c858a96a28961 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sat, 3 Mar 2018 16:03:41 +0000 Subject: Fix various flake8 whitespace reports $ flake8 | grep -E '(E203|E221|E226|E303|W291|W293)' ./run_unittests.py:1503:5: E303 too many blank lines (2) ./mesonbuild/interpreter.py:2342:64: E226 missing whitespace around arithmetic operator ./mesonbuild/minit.py:110:17: E221 multiple spaces before operator ./mesonbuild/minit.py:131:1: W293 blank line contains whitespace ./mesonbuild/minit.py:135:19: E221 multiple spaces before operator ./mesonbuild/minit.py:155:1: W293 blank line contains whitespace ./mesonbuild/minit.py:181:1: W293 blank line contains whitespace ./mesonbuild/minit.py:183:1: W293 blank line contains whitespace ./mesonbuild/minit.py:294:47: W291 trailing whitespace ./mesonbuild/minit.py:331:47: W291 trailing whitespace ./mesonbuild/modules/unstable_icestorm.py:49:1: W293 blank line contains whitespace ./mesonbuild/modules/unstable_icestorm.py:76:31: E203 whitespace before ':' ./mesonbuild/modules/unstable_icestorm.py:82:22: E203 whitespace before ':' --- mesonbuild/interpreter.py | 2 +- mesonbuild/minit.py | 16 ++++++++-------- mesonbuild/modules/unstable_icestorm.py | 6 +++--- run_unittests.py | 1 - 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index e3680acd0..7a76fad52 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2339,7 +2339,7 @@ root and issuing %s. cmds = [] command_templ = 'meson wrap promote ' for l in found: - cmds.append(command_templ + l[len(self.source_root)+1:]) + cmds.append(command_templ + l[len(self.source_root) + 1:]) final_message = message + '\n'.join(cmds) print(final_message) diff --git a/mesonbuild/minit.py b/mesonbuild/minit.py index 62e2639ae..bc2818cdf 100644 --- a/mesonbuild/minit.py +++ b/mesonbuild/minit.py @@ -106,7 +106,7 @@ pkg_mod.generate( ) ''' -hello_c_template = '''#include +hello_c_template = '''#include #define PROJECT_NAME "{project_name}" @@ -127,11 +127,11 @@ hello_c_meson_template = '''project('{project_name}', 'c', exe = executable('{exe_name}', '{source_name}', install : true) - + test('basic', exe) ''' -hello_cpp_template = '''#include +hello_cpp_template = '''#include #define PROJECT_NAME "{project_name}" @@ -151,7 +151,7 @@ hello_cpp_meson_template = '''project('{project_name}', 'cpp', exe = executable('{exe_name}', '{source_name}', install : true) - + test('basic', exe) ''' @@ -177,9 +177,9 @@ class {utoken}_PUBLIC {class_name} {{ public: {class_name}(); int get_number() const; - + private: - + int number; }}; @@ -290,7 +290,7 @@ def create_lib_c_sample(project_name, version): 'function_name': function_name, 'header_file': lib_h_name, 'source_file': lib_c_name, - 'test_source_file': test_c_name, + 'test_source_file': test_c_name, 'test_exe_name': lowercase_token, 'project_name': project_name, 'lib_name': lowercase_token, @@ -327,7 +327,7 @@ def create_lib_cpp_sample(project_name, version): 'namespace': namespace, 'header_file': lib_h_name, 'source_file': lib_c_name, - 'test_source_file': test_c_name, + 'test_source_file': test_c_name, 'test_exe_name': lowercase_token, 'project_name': project_name, 'lib_name': lowercase_token, diff --git a/mesonbuild/modules/unstable_icestorm.py b/mesonbuild/modules/unstable_icestorm.py index 761d583d9..c880bf561 100644 --- a/mesonbuild/modules/unstable_icestorm.py +++ b/mesonbuild/modules/unstable_icestorm.py @@ -46,7 +46,7 @@ class IceStormModule(ExtensionModule): all_sources = interpreter.source_strings_to_files(interpreter.flatten(arg_sources + kwarg_sources)) if 'constraint_file' not in kwargs: raise mesonlib.MesonException('Constraint file not specified.') - + constraint_file = interpreter.source_strings_to_files(kwargs['constraint_file']) if len(constraint_file) != 1: raise mesonlib.MesonException('Constraint file must contain one and only one entry.') @@ -73,13 +73,13 @@ class IceStormModule(ExtensionModule): 'input': asc_target, 'output': bin_fname, 'command': [self.icepack_bin, '@INPUT@', '@OUTPUT@'], - 'build_by_default' : True}) + 'build_by_default': True}) up_target = interpreter.func_run_target(None, [upload_name], { 'command': [self.iceprog_bin, bin_target]}) time_target = interpreter.func_run_target(None, [time_name], { - 'command' : [self.icetime_bin, bin_target]}) + 'command': [self.icetime_bin, bin_target]}) def initialize(): return IceStormModule() diff --git a/run_unittests.py b/run_unittests.py index a6d28c850..09f537d06 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -1498,7 +1498,6 @@ int main(int argc, char **argv) { cmd += ['-c', source, '-o', objectfile] + extra_args subprocess.check_call(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - def test_prebuilt_object(self): (compiler, _, object_suffix, _) = self.detect_prebuild_env() tdir = os.path.join(self.unit_test_dir, '14 prebuilt object') -- cgit v1.2.3 From 2f6ed470771858d96d435131e2624fb144464973 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sat, 3 Mar 2018 21:12:39 +0000 Subject: Fix various flake8 indentation reports $ flake8 | grep -E '(E123|E127|E128)' ./run_unittests.py:1358:37: E127 continuation line over-indented for visual indent ./run_unittests.py:1360:37: E127 continuation line over-indented for visual indent ./mesonbuild/minit.py:311:66: E128 continuation line under-indented for visual indent ./mesonbuild/minit.py:312:66: E128 continuation line under-indented for visual indent ./mesonbuild/minit.py:313:66: E128 continuation line under-indented for visual indent ./mesonbuild/compilers/cpp.py:115:63: E127 continuation line over-indented for visual indent ./msi/createmsi.py:156:13: E123 closing bracket does not match indentation of opening bracket's line ./msi/createmsi.py:188:13: E123 closing bracket does not match indentation of opening bracket's line --- mesonbuild/compilers/cpp.py | 2 +- mesonbuild/minit.py | 6 +++--- msi/createmsi.py | 4 ++-- run_unittests.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index c10f38edb..1fa6f1573 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -112,7 +112,7 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler): if self.gcc_type == GCC_MINGW: opts.update({ 'cpp_winlibs': coredata.UserArrayOption('cpp_winlibs', 'Standard Win libraries to link against', - gnu_winlibs), }) + gnu_winlibs), }) return opts def get_option_compile_args(self, options): diff --git a/mesonbuild/minit.py b/mesonbuild/minit.py index bc2818cdf..69dd5163e 100644 --- a/mesonbuild/minit.py +++ b/mesonbuild/minit.py @@ -308,9 +308,9 @@ def create_exe_cpp_sample(project_name, project_version): source_name = lowercase_token + '.cpp' open(source_name, 'w').write(hello_cpp_template.format(project_name=project_name)) open('meson.build', 'w').write(hello_cpp_meson_template.format(project_name=project_name, - exe_name=lowercase_token, - source_name=source_name, - version=project_version)) + exe_name=lowercase_token, + source_name=source_name, + version=project_version)) def create_lib_cpp_sample(project_name, version): lowercase_token = re.sub(r'[^a-z0-9]', '_', project_name.lower()) diff --git a/msi/createmsi.py b/msi/createmsi.py index ec0340d32..c709745b1 100755 --- a/msi/createmsi.py +++ b/msi/createmsi.py @@ -153,7 +153,7 @@ class PackageGenerator: 'SourceFile': self.redist_path, 'DiskId': '1', 'Language': '0', - }) + }) ET.SubElement(product, 'Property', { 'Id': 'WIXUI_INSTALLDIR', @@ -185,7 +185,7 @@ class PackageGenerator: 'AllowAdvertise': 'no', 'Display': 'hidden', 'Level': '1', - }) + }) ET.SubElement(vcredist_feature, 'MergeRef', {'Id': 'VCRedist'}) ET.ElementTree(self.root).write(self.main_xml, encoding='utf-8', xml_declaration=True) # ElementTree can not do prettyprinting so do it manually diff --git a/run_unittests.py b/run_unittests.py index 09f537d06..4eb5d4c23 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -1355,9 +1355,9 @@ class AllPlatformTests(BasePlatformTests): subprocess.check_call(['git', 'config', 'user.email', 'teh_coderz@example.com'], cwd=project_dir) subprocess.check_call(['git', 'add', 'meson.build', 'distexe.c'], cwd=project_dir, - stdout=subprocess.DEVNULL) + stdout=subprocess.DEVNULL) subprocess.check_call(['git', 'commit', '-a', '-m', 'I am a project'], cwd=project_dir, - stdout=subprocess.DEVNULL) + stdout=subprocess.DEVNULL) try: self.dist_impl(git_init) -- cgit v1.2.3 From 8958529a2596c73bdb3cb599ced5f2c440359b5a Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sat, 3 Mar 2018 21:20:00 +0000 Subject: Fix flake8 'variable assigned value but unused' reports $ flake8 | grep -E 'F841' ./run_unittests.py:1987:13: F841 local variable 'objc' is assigned to but never used ./run_unittests.py:1988:13: F841 local variable 'objcpp' is assigned to but never used ./mesonbuild/minit.py:272:5: F841 local variable 'uppercase_token' is assigned to but never used ./mesonbuild/minit.py:307:5: F841 local variable 'uppercase_token' is assigned to but never used ./mesonbuild/modules/unstable_icestorm.py:36:9: F841 local variable 'result' is assigned to but never used ./mesonbuild/modules/unstable_icestorm.py:78:9: F841 local variable 'up_target' is assigned to but never used ./mesonbuild/modules/unstable_icestorm.py:81:9: F841 local variable 'time_target' is assigned to but never used ./msi/createmsi.py:226:17: F841 local variable 'file_source' is assigned to but never used --- mesonbuild/minit.py | 2 -- mesonbuild/modules/unstable_icestorm.py | 5 ++--- msi/createmsi.py | 1 - run_unittests.py | 4 ++-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/mesonbuild/minit.py b/mesonbuild/minit.py index 69dd5163e..4459a057e 100644 --- a/mesonbuild/minit.py +++ b/mesonbuild/minit.py @@ -269,7 +269,6 @@ ninja -C builddir def create_exe_c_sample(project_name, project_version): lowercase_token = re.sub(r'[^a-z0-9]', '_', project_name.lower()) - uppercase_token = lowercase_token.upper() source_name = lowercase_token + '.c' open(source_name, 'w').write(hello_c_template.format(project_name=project_name)) open('meson.build', 'w').write(hello_c_meson_template.format(project_name=project_name, @@ -304,7 +303,6 @@ def create_lib_c_sample(project_name, version): def create_exe_cpp_sample(project_name, project_version): lowercase_token = re.sub(r'[^a-z0-9]', '_', project_name.lower()) - uppercase_token = lowercase_token.upper() source_name = lowercase_token + '.cpp' open(source_name, 'w').write(hello_cpp_template.format(project_name=project_name)) open('meson.build', 'w').write(hello_cpp_meson_template.format(project_name=project_name, diff --git a/mesonbuild/modules/unstable_icestorm.py b/mesonbuild/modules/unstable_icestorm.py index c880bf561..1f548b6d1 100644 --- a/mesonbuild/modules/unstable_icestorm.py +++ b/mesonbuild/modules/unstable_icestorm.py @@ -33,7 +33,6 @@ class IceStormModule(ExtensionModule): def project(self, interpreter, state, args, kwargs): if not self.yosys_bin: self.detect_binaries(interpreter) - result = [] if not len(args): raise mesonlib.MesonException('Project requires at least one argument, which is the project name.') proj_name = args[0] @@ -75,10 +74,10 @@ class IceStormModule(ExtensionModule): 'command': [self.icepack_bin, '@INPUT@', '@OUTPUT@'], 'build_by_default': True}) - up_target = interpreter.func_run_target(None, [upload_name], { + interpreter.func_run_target(None, [upload_name], { 'command': [self.iceprog_bin, bin_target]}) - time_target = interpreter.func_run_target(None, [time_name], { + interpreter.func_run_target(None, [time_name], { 'command': [self.icetime_bin, bin_target]}) def initialize(): diff --git a/msi/createmsi.py b/msi/createmsi.py index c709745b1..499f4b01c 100755 --- a/msi/createmsi.py +++ b/msi/createmsi.py @@ -223,7 +223,6 @@ class PackageGenerator: }) self.component_num += 1 for f in cur_node.files: - file_source = os.path.join(current_dir, f).replace('\\', '\\\\') file_id = os.path.join(current_dir, f).replace('\\', '_').replace('#', '_').replace('-', '_') ET.SubElement(comp_xml_node, 'File', { 'Id': file_id, diff --git a/run_unittests.py b/run_unittests.py index 4eb5d4c23..3e5da22f1 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -1984,8 +1984,8 @@ class FailureTests(BasePlatformTests): env = Environment('', self.builddir, self.meson_command, get_fake_options(self.prefix), []) try: - objc = env.detect_objc_compiler(False) - objcpp = env.detect_objcpp_compiler(False) + env.detect_objc_compiler(False) + env.detect_objcpp_compiler(False) except EnvironmentException: code = "add_languages('objc')\nadd_languages('objcpp')" self.assertMesonRaises(code, "Unknown compiler") -- cgit v1.2.3 From 390333a18dfa1d8ec8fefe25f638902700ddb82e Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sat, 3 Mar 2018 21:34:23 +0000 Subject: Fix remaining flake8 report $ flake8 ./mesonbuild/interpreterbase.py:411:13: F821 undefined name 'set_variable' This looks like an actual bug which would affect disabler use :) --- mesonbuild/interpreterbase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 0539b145c..170df2995 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -408,7 +408,7 @@ The result of this is undefined and will become a hard error in a future Meson r varname = node.var_name addition = self.evaluate_statement(node.value) if is_disabler(addition): - set_variable(varname, addition) + self.set_variable(varname, addition) return # Remember that all variables are immutable. We must always create a # full new variable and then assign it. -- cgit v1.2.3