Skip to content

Commit

Permalink
Fix lint errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
ymoch committed Aug 18, 2018
1 parent 3e870fc commit a0dc835
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion csv2sql/core/prefetching.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import tempfile


class RewindableFileIterator(object):
class RewindableFileIterator:
"""A file iterator class that can be rewinded.
An instances of this class can create a temporary file
and should be closed by `close()` or using `with` statement.
Expand Down
13 changes: 4 additions & 9 deletions csv2sql/core/type_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ def _always_true(_):


def _create_any_predicate(args):
if len(args) != 0:
if args:
raise InterpretationError('Match predicate takes no argument.')

return _always_true


Expand Down Expand Up @@ -141,11 +140,7 @@ def interpret_predicate(obj):
'Predicate type`{0}` is invalid'.format(predicate_type))

args = obj.get('args', []) # `args` is an optional value.
if (
isinstance(args, str) or
isinstance(args, bytes) or
not hasattr(args, '__iter__')
):
if isinstance(args, (str, bytes)) or not hasattr(args, '__iter__'):
args = [args]

predicate = predicate_generator(args) # Can raise InterpretationError.
Expand All @@ -163,7 +158,7 @@ def interpret_patterns(obj):
return [_interpret_one_type_pattern(item) for item in obj]


class TypeInferrer(object):
class TypeInferrer:
"""Infers the type while reading items."""

def __init__(self, patterns, null_value=_DEFAULT_NULL_VALUE):
Expand Down Expand Up @@ -197,7 +192,7 @@ def type_name(self):
return self._current[0]


class _Inference(object):
class _Inference:
def __init__(self, index, patterns, null_value):
"""Initialize."""
self._index = int(index)
Expand Down
8 changes: 5 additions & 3 deletions csv2sql/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import yaml

import csv2sql.meta as meta
import csv2sql.meta
import csv2sql.queryengines.psql
from csv2sql.core.error import InterpretationError
from csv2sql.core.my_logging import get_logger
Expand Down Expand Up @@ -106,6 +106,8 @@ def _decide_patterns(args):
try:
with open(pattern_file_path) as pattern_file:
return yaml.load(pattern_file)
# pylint: disable=try-except-raise
# since this flow is correct.
except IOError:
raise
except TypeError as error:
Expand All @@ -131,7 +133,7 @@ def _parse_column_type(column_type):
return index, type_name


class _ArgsInterfaces(object):
class _ArgsInterfaces:
# pylint: disable=too-few-public-methods
# since this class is an namespace.
# readable.
Expand Down Expand Up @@ -221,7 +223,7 @@ def parse_args(arguments):
description='Convert CSV data into an SQL dump.')
parser.add_argument(
'-v', '--version', action='version',
version='%(prog)s {0}'.format(meta.__version__))
version='%(prog)s {0}'.format(csv2sql.meta.__version__))

subparsers = parser.add_subparsers(
title='target', description='What to dump.')
Expand Down
2 changes: 1 addition & 1 deletion csv2sql/queryengines/psql.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
_LINE_TERMINATOR = '\n'


class WriterWrapper(object):
class WriterWrapper:
"""CSV writer wrapper class to escape the special strings."""

def __init__(self, stream, *args, **kwargs):
Expand Down

0 comments on commit a0dc835

Please sign in to comment.