Skip to content

Commit

Permalink
Refs jazzband#401 - Fixed some flake8 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
claudep committed Jan 11, 2020
1 parent 660990b commit d372540
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use_scm_version=True,
setup_requires=['setuptools_scm'],
description='Format agnostic tabular data library (XLS, JSON, YAML, CSV)',
long_description=(open('README.md').read() + '\n\n' +
open('HISTORY.md').read()),
long_description=(
open('README.md').read() + '\n\n' + open('HISTORY.md').read()
),
long_description_content_type="text/markdown",
author='Kenneth Reitz',
author_email='[email protected]',
Expand Down
2 changes: 1 addition & 1 deletion src/tablib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
""" Tablib. """
from pkg_resources import DistributionNotFound, get_distribution
from tablib.core import (
from tablib.core import ( # noqa: F401
Databook,
Dataset,
InvalidDatasetType,
Expand Down
3 changes: 1 addition & 2 deletions src/tablib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from copy import copy
from operator import itemgetter

from tablib import formats
from tablib.exceptions import (
HeadersNeeded,
InvalidDatasetIndex,
Expand Down Expand Up @@ -416,7 +415,7 @@ def load(self, in_stream, format=None, **kwargs):
fmt = registry.get_format(format)
if not hasattr(fmt, 'import_set'):
raise UnsupportedFormat('Format {} cannot be imported.'.format(format))

if not import_set:
raise UnsupportedFormat('Format {} cannot be imported.'.format(format))

Expand Down
2 changes: 1 addition & 1 deletion src/tablib/formats/_ods.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def dset_sheet(cls, dataset, ws):
try:
col = str(col, errors='ignore')
except TypeError:
## col is already str
# col is already str
pass
ws.addElement(table.TableColumn())

Expand Down
2 changes: 0 additions & 2 deletions src/tablib/formats/_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def _row_to_lines(cls, values, widths, wrapper, sep='|', justify=JUSTIFY_LEFT):
lines = [''.join((lpad, pad.join(line), rpad)) for line in lines]
return lines


@classmethod
def _get_column_widths(cls, dataset, max_table_width=MAX_TABLE_WIDTH, pad_len=3):
"""
Expand Down Expand Up @@ -184,7 +183,6 @@ def export_set_as_grid_table(cls, dataset, column_widths=None):
lines.append(row_sep)
return '\n'.join(lines)


@classmethod
def _use_simple_table(cls, head0, col0, width0):
"""
Expand Down
1 change: 0 additions & 1 deletion src/tablib/formats/_xls.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def export_book(cls, databook):
wb.save(stream)
return stream.getvalue()


@classmethod
def import_set(cls, dset, in_stream, headers=True):
"""Returns databook from XLS stream."""
Expand Down
18 changes: 14 additions & 4 deletions tests/test_tablib.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ def test_add_column_with_header_and_data_exists(self):
def test_add_callable_column(self):
"""Verify adding column with values specified as callable."""

new_col = lambda x: x[0]
def new_col(x):
return x[0]

self.founders.append_col(new_col, header='first_again')

Expand Down Expand Up @@ -1313,10 +1314,19 @@ def test_rst_formatter_doctests(self):

class CliTests(BaseTestCase):
def test_cli_export_github(self):
self.assertEqual('|---|---|---|\n| a | b | c |', tablib.Dataset(['a','b','c']).export('cli', tablefmt='github'))
self.assertEqual(
'|---|---|---|\n| a | b | c |',
tablib.Dataset(['a', 'b', 'c']).export('cli', tablefmt='github')
)

def test_cli_export_simple(self):
self.assertEqual('- - -\na b c\n- - -', tablib.Dataset(['a','b','c']).export('cli', tablefmt='simple'))
self.assertEqual(
'- - -\na b c\n- - -',
tablib.Dataset(['a', 'b', 'c']).export('cli', tablefmt='simple')
)

def test_cli_export_grid(self):
self.assertEqual('+---+---+---+\n| a | b | c |\n+---+---+---+', tablib.Dataset(['a','b','c']).export('cli', tablefmt='grid'))
self.assertEqual(
'+---+---+---+\n| a | b | c |\n+---+---+---+',
tablib.Dataset(['a', 'b', 'c']).export('cli', tablefmt='grid')
)

0 comments on commit d372540

Please sign in to comment.