From 9795323b8649b8615e55cad981d235e432afef02 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 26 Aug 2021 09:37:39 -0700 Subject: [PATCH] pylint: check for duplicate imports I ran into one of these from LGTM, and it would be nice if pylint could warn me as part of my local development process instead of waiting for the CI to tell me. --- .pylintrc | 1 + mesonbuild/build.py | 4 ++-- mesonbuild/cmake/executor.py | 1 - mesonbuild/compilers/cpp.py | 2 +- mesonbuild/compilers/d.py | 3 ++- mesonbuild/environment.py | 1 - mesonbuild/modules/qt.py | 3 +-- 7 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.pylintrc b/.pylintrc index e811d08cc..eae06672a 100644 --- a/.pylintrc +++ b/.pylintrc @@ -22,6 +22,7 @@ enable= mixed-indentation, no-value-for-parameter, redundant-keyword-arg, + reimported, singleton-comparison, superfluous-parens, too-many-function-args, diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 464b0961b..01d271997 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -33,7 +33,7 @@ from .mesonlib import ( extract_as_list, typeslistify, stringlistify, classify_unity_sources, get_filenames_templates_dict, substitute_values, has_path_sep, OptionKey, PerMachineDefaultable, - MesonBugException, FileOrString, + MesonBugException, ) from .compilers import ( Compiler, is_object, clink_langs, sort_clink, lang_suffixes, @@ -902,7 +902,7 @@ class BuildTarget(Target): if t in self.kwargs: self.kwargs[t] = listify(self.kwargs[t], flatten=True) - def extract_objects(self, srclist: T.List[FileOrString]) -> ExtractedObjects: + def extract_objects(self, srclist: T.List['FileOrString']) -> ExtractedObjects: obj_src: T.List['File'] = [] sources_set = set(self.sources) for src in srclist: diff --git a/mesonbuild/cmake/executor.py b/mesonbuild/cmake/executor.py index 7b06f2623..65ff7308d 100644 --- a/mesonbuild/cmake/executor.py +++ b/mesonbuild/cmake/executor.py @@ -28,7 +28,6 @@ from ..mesonlib import PerMachine, Popen_safe, version_compare, MachineChoice, i from ..programs import find_external_program, NonExistingExternalProgram if T.TYPE_CHECKING: - from ..environment import Environment from ..programs import ExternalProgram TYPE_result = T.Tuple[int, T.Optional[str], T.Optional[str]] diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 168ba7a40..ecc911d72 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -47,7 +47,7 @@ if T.TYPE_CHECKING: from ..environment import Environment from ..linkers import DynamicLinker from ..programs import ExternalProgram - from .mixins.clike import CLikeCompiler as CompilerMixinBase + CompilerMixinBase = CLikeCompiler else: CompilerMixinBase = object diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py index 19706c50c..18a5d6815 100644 --- a/mesonbuild/compilers/d.py +++ b/mesonbuild/compilers/d.py @@ -33,11 +33,12 @@ from .compilers import ( from .mixins.gnu import GnuCompiler if T.TYPE_CHECKING: - from .compilers import Compiler as CompilerMixinBase from ..programs import ExternalProgram from ..envconfig import MachineInfo from ..environment import Environment from ..linkers import DynamicLinker + + CompilerMixinBase = Compiler else: CompilerMixinBase = object diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index a50908711..2369439a0 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -49,7 +49,6 @@ from mesonbuild import envconfig if T.TYPE_CHECKING: from configparser import ConfigParser - from .dependencies import ExternalProgram from .wrap.wrap import Resolver build_filename = 'meson.build' diff --git a/mesonbuild/modules/qt.py b/mesonbuild/modules/qt.py index 19d9a6395..7dafad735 100644 --- a/mesonbuild/modules/qt.py +++ b/mesonbuild/modules/qt.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mesonbuild import coredata import os import shutil import typing as T @@ -21,10 +20,10 @@ import xml.etree.ElementTree as ET from . import ModuleReturnValue, ExtensionModule from .. import build +from .. import coredata from .. import mlog from ..dependencies import find_external_dependency, Dependency, ExternalLibrary from ..mesonlib import MesonException, File, FileOrString, version_compare, Popen_safe -from . import ModuleReturnValue, ExtensionModule from ..interpreter import extract_required_kwarg from ..interpreter.type_checking import NoneType from ..interpreterbase import ContainerTypeInfo, FeatureDeprecated, KwargInfo, noPosargs, FeatureNew, typed_kwargs