Skip to content

Commit

Permalink
reorder/reformat imports
Browse files Browse the repository at this point in the history
  • Loading branch information
xflr6 committed Dec 25, 2020
1 parent 1eb4f00 commit d4bc782
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 43 deletions.
5 changes: 3 additions & 2 deletions csv23/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
unregister_dialect)

from ._common import ENCODING, DIALECT, ROWTYPE
from .dialects import unix_dialect
from .extras import NamedTupleReader, NamedTupleWriter
from .openers import open_reader, open_writer
from .readers import reader, DictReader
from .writers import writer, DictWriter
from .dialects import unix_dialect
from .extras import NamedTupleReader, NamedTupleWriter

from .shortcuts import read_csv, write_csv

__all__ = ['open_csv',
Expand Down
2 changes: 1 addition & 1 deletion csv23/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from __future__ import unicode_literals

import sys
import codecs
import locale
import sys

PY2 = (sys.version_info.major == 2)

Expand Down
2 changes: 1 addition & 1 deletion csv23/_workarounds.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# _workarounds.py

import io
import csv
import io
import warnings

from ._common import PY2
Expand Down
8 changes: 4 additions & 4 deletions csv23/openers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

from __future__ import unicode_literals

import io
import functools
import contextlib
import functools
import io

from ._common import PY2, ENCODING, DIALECT, ROWTYPE
from ._common import none_encoding, is_8bit_clean
from ._common import (PY2, ENCODING, DIALECT, ROWTYPE,
none_encoding, is_8bit_clean)
from ._dispatch import get_reader, get_writer

__all__ = ['open_reader', 'open_writer']
Expand Down
12 changes: 5 additions & 7 deletions csv23/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@

import csv

__all__ = [
'reader', 'DictReader',
'UnicodeTextReader', 'UnicodeBytesReader',
]

from ._common import PY2, ENCODING, DIALECT
from ._common import none_encoding, is_8bit_clean, csv_args
from ._common import (PY2, ENCODING, DIALECT,
none_encoding, is_8bit_clean, csv_args)
from ._dispatch import register_reader
from ._workarounds import warn_if_issue31590

__all__ = ['reader', 'DictReader',
'UnicodeTextReader', 'UnicodeBytesReader']


def reader(stream, dialect=DIALECT, encoding=False, **fmtparams):
r"""CSV reader yielding lists of :func:`py:unicode` strings (PY3: :class:`py3:str`).
Expand Down
3 changes: 1 addition & 2 deletions csv23/shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

from ._common import PY2

from . import (DIALECT,
ENCODING,
from . import (DIALECT, ENCODING,
reader as csv23_reader,
writer as csv23_writer)

Expand Down
12 changes: 5 additions & 7 deletions csv23/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from __future__ import unicode_literals

import io
import csv
import io

from ._common import PY2, ENCODING, DIALECT
from ._common import none_encoding, is_8bit_clean, csv_args
from ._common import (PY2, ENCODING, DIALECT,
none_encoding, is_8bit_clean, csv_args)
from ._dispatch import register_writer
from ._workarounds import has_issue12178

Expand All @@ -15,10 +15,8 @@
else:
from unittest import mock

__all__ = [
'writer', 'DictWriter',
'UnicodeTextWriter', 'UnicodeBytesWriter'
]
__all__ = ['writer', 'DictWriter',
'UnicodeTextWriter', 'UnicodeBytesWriter']


def writer(stream, dialect=DIALECT, encoding=False, **fmtparams):
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from __future__ import unicode_literals

import sys
import locale
import argparse
import locale
import sys

import pytest

Expand Down
4 changes: 3 additions & 1 deletion tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

from csv23 import open_csv, iterrows

LINE, ROW = 'Wonderful Spam,Lovely Spam\r\n', ['Wonderful Spam', 'Lovely Spam']
LINE = 'Wonderful Spam,Lovely Spam\r\n'

ROW = ['Wonderful Spam', 'Lovely Spam']


def test_open_csv(filepath, row=ROW):
Expand Down
6 changes: 2 additions & 4 deletions tests/test_rowtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@

from csv23.openers import open_reader, open_writer

PYTHONS = [
'Graham Chapman', 'John Cleese', 'Terry Gilliam',
'Eric Idle', 'Terry Jones', 'Michael Palin'
]
PYTHONS = ['Graham Chapman', 'John Cleese', 'Terry Gilliam',
'Eric Idle', 'Terry Jones', 'Michael Palin']

FIELDNAMES = ['first_name', 'last_name']

Expand Down
16 changes: 7 additions & 9 deletions tests/test_stdlib_csv.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# test_stdlib_csv.py - verify stdlib csv behaviour for workarounds

import io
import csv
import io

import pytest

Expand All @@ -25,14 +25,12 @@
(csv.QUOTE_NONE, None, '\\', False), # escapes: ,\r\n\\ issue31590
]

VALUES = [
'spam, eggs',
'spam\r eggs',
'spam\n eggs',
'spam "spam" eggs',
'"spam spam eggs"',
'spam\\eggs',
]
VALUES = ['spam, eggs',
'spam\r eggs',
'spam\n eggs',
'spam "spam" eggs',
'"spam spam eggs"',
'spam\\eggs']


@pytest.mark.parametrize(', '.join(FORMATS[0]), FORMATS[1:])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_stdlib_truncate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

from __future__ import unicode_literals

import importlib
import contextlib
import importlib

import pytest

Expand Down
4 changes: 2 additions & 2 deletions tests/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from __future__ import unicode_literals

import io
import csv
import io

import pytest

from csv23._common import is_8bit_clean
from csv23.openers import open_writer
from csv23.writers import writer, UnicodeTextWriter, UnicodeBytesWriter
from csv23._common import is_8bit_clean

if not pytest.csv23.PY2:
from csv23.writers import _UnicodeTextWriter
Expand Down

0 comments on commit d4bc782

Please sign in to comment.