diff --git a/scripts/__init__.py b/scripts/__init__.py index e69de29bb..9d5680938 100644 --- a/scripts/__init__.py +++ b/scripts/__init__.py @@ -0,0 +1 @@ +"""Various scripts used to develop/install qutebrowser.""" diff --git a/scripts/cleanup.py b/scripts/cleanup.py index 001ec0452..f74cc5b93 100644 --- a/scripts/cleanup.py +++ b/scripts/cleanup.py @@ -32,14 +32,16 @@ lint = ['build', 'dist', 'pkg/pkg', 'pkg/qutebrowser-*.pkg.tar.xz', 'pkg/src', 'setuptools-*.zip'] - def remove(path): + """Remove either a file or directory unless --dry-run is given.""" if os.path.isdir(path): print("rm -r '{}'".format(path)) - if not '--dry-run' in sys.argv: shutil.rmtree(path) + if not '--dry-run' in sys.argv: + shutil.rmtree(path) else: print("rm '{}'".format(path)) - if not '--dry-run' in sys.argv: os.remove(path) + if not '--dry-run' in sys.argv: + os.remove(path) for elem in lint: diff --git a/scripts/freeze.py b/scripts/freeze.py index 6f70c616a..0f2ef0d69 100644 --- a/scripts/freeze.py +++ b/scripts/freeze.py @@ -80,8 +80,8 @@ executable = Executable('qutebrowser/__main__.py', base=base, try: write_git_file() setup( - executables = [executable], - options = { + executables=[executable], + options={ 'build_exe': build_exe_options, 'bdist_msi': bdist_msi_options, }, diff --git a/scripts/run_checks.py b/scripts/run_checks.py index 328e95dcf..f3dd4b9e1 100755 --- a/scripts/run_checks.py +++ b/scripts/run_checks.py @@ -15,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +# pylint: disable=broad-except + """ Run different codecheckers over a codebase. Runs flake8, pylint, pep257, a CRLF/whitespace/conflict-checker and pyroma by @@ -71,6 +73,7 @@ if os.name == 'nt': # arrows in configdata.py options['exclude_pep257'].append('configdata.py') + def run(name, target, args=None): """Run a checker via distutils with optional args. @@ -122,18 +125,20 @@ def check_pep257(target, args=None): def check_unittest(): + """Run the unittest checker.""" print("==================== unittest ====================") suite = unittest.TestLoader().discover('.') result = unittest.TextTestRunner().run(suite) print() status['unittest'] = result.wasSuccessful() + def check_line(target): """Run _check_file over a filetree.""" print("------ line ------") ret = [] try: - for (dirpath, dirnames, filenames) in os.walk(target): + for (dirpath, _dirnames, filenames) in os.walk(target): for name in (e for e in filenames if e.endswith('.py')): fn = os.path.join(dirpath, name) ret.append(_check_file(fn)) @@ -170,6 +175,7 @@ def _get_args(checker): Return: A list of commandline arguments. """ + # pylint: disable=too-many-branches args = [] if checker == 'pylint': try: @@ -206,7 +212,7 @@ def _get_args(checker): except KeyError: pass try: - args += ['--match=(?!{}).*\.py'.format('|'.join( + args += [r'--match=(?!{}).*\.py'.format('|'.join( options['exclude'] + options['exclude_pep257']))] except KeyError: pass @@ -220,14 +226,14 @@ def _get_args(checker): check_unittest() -for target in options['targets']: - print("==================== {} ====================".format(target)) +for trg in options['targets']: + print("==================== {} ====================".format(trg)) if do_check_257: - check_pep257(target, _get_args('pep257')) - for checker in ['pylint', 'flake8', 'pyroma']: + check_pep257(trg, _get_args('pep257')) + for chk in ['pylint', 'flake8', 'pyroma']: # FIXME what the hell is the flake8 exit status? - run(checker, target, _get_args(checker)) - check_line(target, ) + run(chk, trg, _get_args(chk)) + check_line(trg, ) print("Exit status values:") for (k, v) in status.items(): diff --git a/scripts/run_profile.py b/scripts/run_profile.py index 988a8a1a6..bc567044a 100755 --- a/scripts/run_profile.py +++ b/scripts/run_profile.py @@ -10,7 +10,7 @@ from shutil import rmtree sys.path.insert(0, getcwd()) -from qutebrowser.app import QuteBrowser +from qutebrowser.app import QuteBrowser # pylint: disable=unused-import tempdir = mkdtemp() diff --git a/scripts/setupcommon.py b/scripts/setupcommon.py index 4f91bb02e..b1d66b311 100644 --- a/scripts/setupcommon.py +++ b/scripts/setupcommon.py @@ -16,7 +16,7 @@ # along with qutebrowser. If not, see . -"""Data used by setup.py and scripts/freeze.py""" +"""Data used by setup.py and scripts/freeze.py.""" import sys import os @@ -34,6 +34,7 @@ except NameError: def read_file(name): + """Get the string contained in the file named name.""" with open(name, encoding='utf-8') as f: return f.read() @@ -58,6 +59,7 @@ def _git_str(): def write_git_file(): + """Write the git-commit-id file with the current commit.""" gitstr = _git_str() if gitstr is None: gitstr = ''