diff --git a/setup.py b/setup.py index f46ff1be..f86fad89 100755 --- a/setup.py +++ b/setup.py @@ -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='me@kennethreitz.org', diff --git a/src/tablib/__init__.py b/src/tablib/__init__.py index 1d9d5056..6e10d783 100644 --- a/src/tablib/__init__.py +++ b/src/tablib/__init__.py @@ -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, diff --git a/src/tablib/core.py b/src/tablib/core.py index ef3c26e2..73cc8e69 100644 --- a/src/tablib/core.py +++ b/src/tablib/core.py @@ -12,7 +12,6 @@ from copy import copy from operator import itemgetter -from tablib import formats from tablib.exceptions import ( HeadersNeeded, InvalidDatasetIndex, @@ -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)) diff --git a/src/tablib/formats/_ods.py b/src/tablib/formats/_ods.py index e1bf1042..5c52b96a 100644 --- a/src/tablib/formats/_ods.py +++ b/src/tablib/formats/_ods.py @@ -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()) diff --git a/src/tablib/formats/_rst.py b/src/tablib/formats/_rst.py index 793bce9d..6dce91f6 100644 --- a/src/tablib/formats/_rst.py +++ b/src/tablib/formats/_rst.py @@ -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): """ @@ -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): """ diff --git a/src/tablib/formats/_xls.py b/src/tablib/formats/_xls.py index 0b13d279..7a8ec632 100644 --- a/src/tablib/formats/_xls.py +++ b/src/tablib/formats/_xls.py @@ -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.""" diff --git a/tests/test_tablib.py b/tests/test_tablib.py index e71105e6..b20b6693 100755 --- a/tests/test_tablib.py +++ b/tests/test_tablib.py @@ -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') @@ -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') + )