Skip to content

Commit

Permalink
flake8: Clean up complained-about unused imports
Browse files Browse the repository at this point in the history
This also adds a "# noqa: F401" comment on an unused "import lzma",
which we are using it in a try/except block that is being used to
check if the lzma module is importable; of course it is unused.

v2: This turned out to be a little tricky.

    mesonbuild/modules/__init__.py had the "unused" import:

        from ..interpreterbase import permittedKwargs, noKwargs

    However, that meant that the various modules could do things like:

        from . import noKwargs # "." is "mesonbuild.modules"

    Which breaks when you remove __init__.py's "unused" import.  I
    could have tagged that import with "# noqa: F401", but instead I
    chose to have each of the module import directly from
    "..interpreterbase" instead of ".".
  • Loading branch information
LukeShu committed Sep 21, 2017
1 parent bb25260 commit 4dbbb48
Show file tree
Hide file tree
Showing 14 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion mesonbuild/backend/ninjabackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os, pickle, re, shlex, shutil, subprocess, sys
import os, pickle, re, shlex, subprocess, sys
from collections import OrderedDict

from . import backends
Expand Down
1 change: 0 additions & 1 deletion mesonbuild/backend/vs2010backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from .. import dependencies
from .. import mlog
from .. import compilers
from ..build import BuildTarget
from ..compilers import CompilerArgs
from ..mesonlib import MesonException, File
from ..environment import Environment
Expand Down
1 change: 0 additions & 1 deletion mesonbuild/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from .. import dependencies
from .. import mlog
from ..mesonlib import MesonException
from ..interpreterbase import permittedKwargs, noKwargs

class permittedSnippetKwargs:

Expand Down
3 changes: 1 addition & 2 deletions mesonbuild/modules/gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from .. import build
import os
import sys
import copy
import subprocess
from . import ModuleReturnValue
Expand All @@ -30,7 +29,7 @@
from . import GResourceTarget, GResourceHeaderTarget, GirTarget, TypelibTarget, VapiTarget
from . import find_program, get_include_args
from . import ExtensionModule
from . import noKwargs, permittedKwargs
from ..interpreterbase import noKwargs, permittedKwargs

# gresource compilation is broken due to the way
# the resource compiler and Ninja clash about it
Expand Down
3 changes: 1 addition & 2 deletions mesonbuild/modules/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import shutil

from os import path
from .. import coredata, mesonlib, build
from ..mesonlib import MesonException
from . import ModuleReturnValue
from . import ExtensionModule
from . import permittedKwargs
from ..interpreterbase import permittedKwargs

PRESET_ARGS = {
'glib': [
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/modules/modtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from . import ModuleReturnValue
from . import ExtensionModule
from . import noKwargs
from ..interpreterbase import noKwargs

class TestModule(ExtensionModule):

Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/modules/pkgconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from .. import mlog
from . import ModuleReturnValue
from . import ExtensionModule
from . import permittedKwargs
from ..interpreterbase import permittedKwargs


class PkgConfigModule(ExtensionModule):
Expand Down
3 changes: 2 additions & 1 deletion mesonbuild/modules/python3.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

from . import ExtensionModule
from mesonbuild.modules import ModuleReturnValue
from . import noKwargs, permittedSnippetKwargs
from . import permittedSnippetKwargs
from ..interpreterbase import noKwargs
from ..interpreter import shlib_kwargs

mod_kwargs = set()
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/modules/qt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from . import ExtensionModule
import xml.etree.ElementTree as ET
from . import ModuleReturnValue
from . import permittedKwargs
from ..interpreterbase import permittedKwargs

class Qt4Module(ExtensionModule):
tools_detected = False
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/modules/qt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from . import ExtensionModule
import xml.etree.ElementTree as ET
from . import ModuleReturnValue
from . import permittedKwargs
from ..interpreterbase import permittedKwargs

class Qt5Module(ExtensionModule):
tools_detected = False
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/modules/rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from . import GirTarget, TypelibTarget
from . import ModuleReturnValue
from . import ExtensionModule
from . import noKwargs
from ..interpreterbase import noKwargs

import os

Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/modules/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from . import get_include_args
from . import ModuleReturnValue
from . import ExtensionModule
from . import permittedKwargs
from ..interpreterbase import permittedKwargs

class WindowsModule(ExtensionModule):

Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/wrap/wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def download(self, p, packagename):
def extract_package(self, package):
if sys.version_info < (3, 5):
try:
import lzma
import lzma # noqa: F401
del lzma
except ImportError:
pass
Expand Down
2 changes: 1 addition & 1 deletion mesonrewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# - move targets
# - reindent?

from mesonbuild import mesonmain, mlog
from mesonbuild import mesonmain
import sys

if __name__ == '__main__':
Expand Down

0 comments on commit 4dbbb48

Please sign in to comment.