Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #573 from pelmers/flakes-lint
Browse files Browse the repository at this point in the history
Add flake8 linting to the project, fix all linting errors.
  • Loading branch information
pelmers committed Jun 24, 2016
2 parents bcecadc + 0c707f4 commit 382011b
Show file tree
Hide file tree
Showing 42 changed files with 84 additions and 166 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ before_install:
- make docker_es

script:
- docker-compose -f tooling/docker/docker-compose.yml run -e DXR_PROD=1 dev make test
- docker-compose -f tooling/docker/docker-compose.yml run -e DXR_PROD=1 dev make lint test

notifications:
email: false
Expand Down
3 changes: 0 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand Down
21 changes: 8 additions & 13 deletions dxr/app.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
from cStringIO import StringIO
from datetime import datetime
from functools import partial
from itertools import chain, imap, izip
from itertools import chain, izip
from logging import StreamHandler
import os
from os import chdir
from os.path import join, basename, split, dirname, relpath
from os.path import join, basename, split, dirname
from sys import stderr
from time import time
from mimetypes import guess_type
from urllib import quote_plus

from flask import (Blueprint, Flask, send_from_directory, current_app,
send_file, request, redirect, jsonify, render_template,
url_for)
from funcy import merge, imap
from flask import (Blueprint, Flask, current_app, send_file, request, redirect,
jsonify, render_template, url_for)
from funcy import merge
from pyelasticsearch import ElasticSearch
from werkzeug.exceptions import NotFound

from dxr.config import Config
from dxr.es import (filtered_query, frozen_config, frozen_configs,
es_alias_or_not_found)
from dxr.exceptions import BadTerm
Expand All @@ -28,7 +23,7 @@
from dxr.plugins import plugins_named
from dxr.query import Query, filter_menu_items
from dxr.utils import (non_negative_int, decode_es_datetime, DXR_BLUEPRINT,
format_number, append_update, append_by_line, build_offset_map)
format_number, append_by_line, build_offset_map)
from dxr.vcs import file_contents_at_rev

# Look in the 'dxr' package for static files, etc.:
Expand Down Expand Up @@ -192,9 +187,9 @@ def _search_json(query, tree, query_text, offset, limit, config):
return jsonify({'redirect': url_for('.browse', _anchor=line, **params)})
# Convert to dicts for ease of manipulation in JS:
results = [{'icon': icon,
'path': path,
'path': file_path,
'lines': [{'line_number': nb, 'line': l} for nb, l in lines]}
for icon, path, lines in count_and_results['results']]
for icon, file_path, lines in count_and_results['results']]
except BadTerm as exc:
return jsonify({'error_html': exc.reason, 'error_level': 'warning'}), 400

Expand Down
9 changes: 4 additions & 5 deletions dxr/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@
from concurrent.futures import as_completed, ProcessPoolExecutor
from click import progressbar
from flask import current_app
from funcy import ichunks, first, suppress
from pyelasticsearch import (ElasticSearch, ElasticHttpNotFoundError,
IndexAlreadyExistsError, bulk_chunks, Timeout,
ConnectionError)
from funcy import ichunks, first
from pyelasticsearch import (ElasticSearch, IndexAlreadyExistsError,
bulk_chunks, Timeout, ConnectionError)

from dxr.app import make_app, dictify_links
from dxr.config import FORMAT
from dxr.es import UNINDEXED_STRING, UNANALYZED_STRING, TREE, create_index_and_wait
from dxr.exceptions import BuildError
from dxr.filters import LINE, FILE
from dxr.lines import es_lines, finished_tags
from dxr.mime import decode_data, is_binary_image
from dxr.mime import decode_data
from dxr.utils import (open_log, deep_update, append_update,
append_update_by_line, append_by_line, bucket)
from dxr.vcs import VcsCache
Expand Down
2 changes: 1 addition & 1 deletion dxr/cli/delete.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from click import ClickException, command, echo, option
from pyelasticsearch import ElasticSearch, ElasticHttpNotFoundError

from dxr.cli.utils import tree_objects, config_option, tree_names_argument
from dxr.cli.utils import config_option, tree_names_argument
from dxr.config import FORMAT
from dxr.es import TREE

Expand Down
4 changes: 2 additions & 2 deletions dxr/cli/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
from contextlib import contextmanager
import os
from os import O_CREAT, O_EXCL, remove
from os.path import join, exists, realpath
from os.path import join, realpath
from pipes import quote
from shutil import rmtree
from subprocess import check_output
from tempfile import mkdtemp, gettempdir
from time import sleep, strftime

from click import command, echo, option, Path
from click import command, option, Path
from flask import current_app
import requests

Expand Down
6 changes: 3 additions & 3 deletions dxr/cli/list.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from click import ClickException, command, echo, secho
from click import command, echo, secho
from itertools import izip
from pyelasticsearch import ElasticSearch
from tabulate import tabulate

from dxr.cli.utils import config_option, tree_names_argument
from dxr.cli.utils import config_option
from dxr.config import FORMAT
from dxr.es import TREE, sources

Expand Down Expand Up @@ -58,4 +58,4 @@ def alias_to_index_map(es, aliases):
# Doesn't handle aliases pointing to more than one index, because
# that shouldn't happen. The last one will win for now.
aliases[alias] = index
return aliases
return aliases
2 changes: 1 addition & 1 deletion dxr/cli/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from os.path import abspath, dirname

from click import ClickException, group, option, Path, argument
from click import ClickException, option, Path, argument

from dxr.config import Config

Expand Down
5 changes: 2 additions & 3 deletions dxr/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
from datetime import datetime
from multiprocessing import cpu_count
from ordereddict import OrderedDict
from operator import attrgetter
from os import getcwd
from os.path import abspath, join
from os.path import abspath

from configobj import ConfigObj
from funcy import merge
from more_itertools import first
from pkg_resources import resource_string
from schema import Schema, Optional, Use, And, Schema, SchemaError
from schema import Optional, Use, And, Schema, SchemaError

from dxr.exceptions import ConfigError
from dxr.plugins import all_plugins_but_core, core_plugin
Expand Down
2 changes: 0 additions & 2 deletions dxr/indexers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Base classes and convenience functions for writing indexers and skimmers"""

import cgi
from collections import namedtuple
from itertools import imap
from operator import itemgetter
from os.path import join, islink
from warnings import warn
Expand Down
4 changes: 2 additions & 2 deletions dxr/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ def closer(self):
class Region(object):
"""A <span> tag with a CSS class, wrapped around a run of text"""

sort_order = 2 # Sort Regions innermost, as it doesn't matter if we split
# them.
# Sort Regions innermost, as it doesn't matter if we split them.
sort_order = 2
__slots__ = ['css_class']

def __init__(self, css_class):
Expand Down
1 change: 0 additions & 1 deletion dxr/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from functools import partial
from inspect import isclass, isfunction
from os.path import join

from ordereddict import OrderedDict
from pkg_resources import iter_entry_points
Expand Down
2 changes: 1 addition & 1 deletion dxr/plugins/buglink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def refs(self):
for m in self.plugin_config.regex.finditer(self.contents):
bug = m.group(1)
yield (m.start(0),
m.end(0),
m.end(0),
# We could make this more storage-efficient if we gave Refs
# access to the plugin config at request time.
BugRef(self.tree,
Expand Down
5 changes: 1 addition & 4 deletions dxr/plugins/clang/indexers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
from operator import itemgetter
import os
from os import listdir
import sys

from funcy import (merge, imap, group_by, is_mapping, repeat,
constantly, icat, autocurry)
from funcy import merge, imap, autocurry

from dxr.filters import LINE
from dxr.indexers import (FileToIndex as FileToIndexBase,
TreeToIndex as TreeToIndexBase,
QUALIFIED_LINE_NEEDLE, unsparsify, FuncSig)
from dxr.lines import Ref
from dxr.plugins.clang.condense import condense_file, condense_global
from dxr.plugins.clang.menus import (FunctionRef, VariableRef, TypeRef,
NamespaceRef, NamespaceAliasRef, MacroRef, IncludeRef, TypedefRef)
Expand Down
1 change: 0 additions & 1 deletion dxr/plugins/clang/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from os.path import basename

from dxr.app import DXR_BLUEPRINT
from dxr.lines import Ref
from dxr.utils import browse_file_url, search_url

Expand Down
1 change: 0 additions & 1 deletion dxr/plugins/clang/tests/test_clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from nose.tools import eq_

from dxr.indexers import Extent, Position
from dxr.plugins.clang.condense import condense, process_call, process_function


Expand Down
5 changes: 0 additions & 5 deletions dxr/plugins/clang/tests/test_direct.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import os.path

from dxr.query import Query
from dxr.plugins.clang.tests import CSingleFileTestCase, MINIMAL_MAIN

from nose.tools import eq_


class TypeAndMethodTests(CSingleFileTestCase):
source = """
Expand Down
1 change: 0 additions & 1 deletion dxr/plugins/clang/tests/test_menus/test_menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"""
from dxr.testing import DxrInstanceTestCase, menu_on, menu_item_not_on
import nose.tools


class MenuTests(DxrInstanceTestCase):
Expand Down
1 change: 0 additions & 1 deletion dxr/plugins/clang/tests/test_overrides/test_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from dxr.testing import DxrInstanceTestCase
from dxr.plugins.clang.tests import CSingleFileTestCase, MINIMAL_MAIN
import nose.tools


class ParallelOverrideTests(CSingleFileTestCase):
Expand Down
2 changes: 0 additions & 2 deletions dxr/plugins/clang/tests/test_warnings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Tests for searches about warnings"""

import commands
import re
from dxr.plugins.clang.tests import CSingleFileTestCase, MINIMAL_MAIN


Expand Down
4 changes: 2 additions & 2 deletions dxr/plugins/clang/tests/test_wildcards.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class WildcardTests(CSingleFileTestCase):
int get_foo() {
return 0;
}
int get_bar() {
return 0;
}
int getX() {
return 0;
}
Expand Down
9 changes: 5 additions & 4 deletions dxr/plugins/extmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"""

from fnmatch import fnmatchcase
from os.path import relpath, join, basename, splitext, isfile
import os
from os.path import join, basename, splitext, isfile
from collections import namedtuple

from dxr.indexers import (FileToIndex as FileToIndexBase,
Expand Down Expand Up @@ -52,10 +53,10 @@ def dual_exts_for(ext):

def is_indexed(path):
if any(fnmatchcase(basename(path), e)
for e in self.tree.ignore_filenames):
for e in self.tree.ignore_filenames):
return False
if any(fnmatchcase("/" + path.replace(os.sep, "/"), e)
for e in self.tree.ignore_paths):
if any(fnmatchcase('/' + path.replace(os.sep, '/'), e)
for e in self.tree.ignore_paths):
return False
return True

Expand Down
1 change: 0 additions & 1 deletion dxr/plugins/python/indexers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
TreeToIndex as TreeToIndexBase,
QUALIFIED_FILE_NEEDLE, QUALIFIED_LINE_NEEDLE,
with_start_and_end)
from dxr.lines import Ref
from dxr.plugins.python.analysis import TreeAnalysis
from dxr.plugins.python.menus import ClassRef
from dxr.plugins.python.utils import (ClassFunctionVisitorMixin,
Expand Down
Binary file modified dxr/plugins/python/tests/test_types/code/some_bytes.py
Binary file not shown.

0 comments on commit 382011b

Please sign in to comment.