Skip to content

Commit d376227

Browse files
authored
Merge pull request #5 from ssbarnea/master
Enable flake8 linting and black autoformatting via pre-commit. Fix #3.
2 parents 1ec339c + d54eaf6 commit d376227

15 files changed

+1878
-1413
lines changed

.circleci/config.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ jobs:
3939
- ./venv
4040
key: v1-dependencies-{{ checksum ".circleci/requirements.txt" }}
4141

42+
- run:
43+
name: run linting
44+
command: |
45+
. venv/bin/activate
46+
tox -e lint
47+
4248
# run tests!
4349
- run:
4450
name: run tests
@@ -49,4 +55,3 @@ jobs:
4955
- store_artifacts:
5056
path: test-reports
5157
destination: test-reports
52-

.pre-commit-config.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
repos:
2+
- repo: https://github.com/python/black
3+
rev: 19.3b0
4+
hooks:
5+
- id: black
6+
args: [--safe]
7+
language_version: python3
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v2.2.3
10+
hooks:
11+
- id: trailing-whitespace
12+
- id: end-of-file-fixer
13+
- id: check-yaml
14+
- id: debug-statements
15+
- id: flake8
16+
language_version: python3

CHANGELOG

-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@
2929
- 0.4: Unicode support, Python3 support, ``rst`` tables.
3030
- 0.3: Initial PyPI release. Table formats: ``simple``, ``plain``,
3131
``grid``, ``pipe``, and ``orgtbl``.
32-

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -715,4 +715,3 @@ Maier, Andy MacKinlay, Thomas Roten, Jue Wang, Joe King, Samuel Phan,
715715
Nick Satterly, Daniel Robbins, Dmitry B, Lars Butler, Andreas Maier,
716716
Dick Marinus, Sébastien Celles, Yago González, Andrew Gaul, Wim Glenn,
717717
Jean Michel Rouly, Tim Gates, John Vandenberg.
718-

benchmark.py

+25-18
Original file line numberDiff line numberDiff line change
@@ -74,37 +74,44 @@ def run_tabulate(table, widechars=False):
7474
7575
"""
7676

77-
methods = [(u"join with tabs and newlines", "join_table(table)"),
78-
(u"csv to StringIO", "csv_table(table)"),
79-
(u"asciitable (%s)" % asciitable.__version__, "run_asciitable(table)"),
80-
(u"tabulate (%s)" % tabulate.__version__, "run_tabulate(table)"),
81-
(u"tabulate (%s, WIDE_CHARS_MODE)" % tabulate.__version__, "run_tabulate(table, widechars=True)"),
82-
(u"PrettyTable (%s)" % prettytable.__version__, "run_prettytable(table)"),
83-
(u"texttable (%s)" % texttable.__version__, "run_texttable(table)"),
84-
]
77+
methods = [
78+
("join with tabs and newlines", "join_table(table)"),
79+
("csv to StringIO", "csv_table(table)"),
80+
("asciitable (%s)" % asciitable.__version__, "run_asciitable(table)"),
81+
("tabulate (%s)" % tabulate.__version__, "run_tabulate(table)"),
82+
(
83+
"tabulate (%s, WIDE_CHARS_MODE)" % tabulate.__version__,
84+
"run_tabulate(table, widechars=True)",
85+
),
86+
("PrettyTable (%s)" % prettytable.__version__, "run_prettytable(table)"),
87+
("texttable (%s)" % texttable.__version__, "run_texttable(table)"),
88+
]
8589

8690

8791
if tabulate.wcwidth is None:
88-
del(methods[4])
92+
del methods[4]
8993

9094

9195
def benchmark(n):
9296
global methods
93-
if '--onlyself' in sys.argv[1:]:
94-
methods = [ m for m in methods if m[0].startswith("tabulate") ]
97+
if "--onlyself" in sys.argv[1:]:
98+
methods = [m for m in methods if m[0].startswith("tabulate")]
9599
else:
96100
methods = methods
97101

98-
results = [(desc, timeit(code, setup_code, number=n)/n * 1e6)
99-
for desc, code in methods]
102+
results = [
103+
(desc, timeit(code, setup_code, number=n) / n * 1e6) for desc, code in methods
104+
]
100105
mintime = min(map(lambda x: x[1], results))
101-
results = [(desc, t, t/mintime) for desc, t in
102-
sorted(results, key=lambda x: x[1])]
103-
table = tabulate.tabulate(results,
104-
[u"Table formatter", u"time, μs", u"rel. time"],
105-
u"rst", floatfmt=".1f")
106+
results = [
107+
(desc, t, t / mintime) for desc, t in sorted(results, key=lambda x: x[1])
108+
]
109+
table = tabulate.tabulate(
110+
results, ["Table formatter", "time, μs", "rel. time"], "rst", floatfmt=".1f"
111+
)
106112

107113
import platform
114+
108115
if platform.platform().startswith("Windows"):
109116
print(table)
110117
elif python_version_tuple()[0] < "3":

setup.py

+34-30
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
import re
1212

1313
# strip links from the descripton on the PyPI
14-
if python_version_tuple()[0] >= '3':
14+
if python_version_tuple()[0] >= "3":
1515
LONG_DESCRIPTION = open("README.md", "r", encoding="utf-8").read()
1616
else:
1717
LONG_DESCRIPTION = open("README.md", "r").read()
1818

1919
# strip Build Status from the PyPI package
2020
try:
21-
if python_version_tuple()[:2] >= ('2', '7'):
21+
if python_version_tuple()[:2] >= ("2", "7"):
2222
status_re = "^Build status\n(.*\n){7}"
2323
LONG_DESCRIPTION = re.sub(status_re, "", LONG_DESCRIPTION, flags=re.M)
2424
except TypeError:
@@ -28,35 +28,39 @@
2828
else:
2929
raise
3030

31-
install_options = os.environ.get("TABULATE_INSTALL","").split(",")
31+
install_options = os.environ.get("TABULATE_INSTALL", "").split(",")
3232
libonly_flags = set(["lib-only", "libonly", "no-cli", "without-cli"])
3333
if libonly_flags.intersection(install_options):
3434
console_scripts = []
3535
else:
36-
console_scripts = ['tabulate = tabulate:_main']
37-
38-
39-
setup(name='tabulate',
40-
version='0.8.6',
41-
description='Pretty-print tabular data',
42-
long_description=LONG_DESCRIPTION,
43-
long_description_content_type="text/markdown",
44-
author='Sergey Astanin',
45-
author_email='s.astanin@gmail.com',
46-
url='https://github.com/astanin/python-tabulate',
47-
license='MIT',
48-
classifiers= [ "Development Status :: 4 - Beta",
49-
"License :: OSI Approved :: MIT License",
50-
"Operating System :: OS Independent",
51-
"Programming Language :: Python :: 2",
52-
"Programming Language :: Python :: 2.7",
53-
"Programming Language :: Python :: 3.3",
54-
"Programming Language :: Python :: 3.4",
55-
"Programming Language :: Python :: 3",
56-
"Programming Language :: Python :: 3.5",
57-
"Programming Language :: Python :: 3.6",
58-
"Topic :: Software Development :: Libraries" ],
59-
py_modules = ['tabulate'],
60-
entry_points = {'console_scripts': console_scripts},
61-
extras_require = {'widechars': ['wcwidth']},
62-
test_suite = 'nose.collector')
36+
console_scripts = ["tabulate = tabulate:_main"]
37+
38+
39+
setup(
40+
name="tabulate",
41+
version="0.8.6",
42+
description="Pretty-print tabular data",
43+
long_description=LONG_DESCRIPTION,
44+
long_description_content_type="text/markdown",
45+
author="Sergey Astanin",
46+
author_email="s.astanin@gmail.com",
47+
url="https://github.com/astanin/python-tabulate",
48+
license="MIT",
49+
classifiers=[
50+
"Development Status :: 4 - Beta",
51+
"License :: OSI Approved :: MIT License",
52+
"Operating System :: OS Independent",
53+
"Programming Language :: Python :: 2",
54+
"Programming Language :: Python :: 2.7",
55+
"Programming Language :: Python :: 3.3",
56+
"Programming Language :: Python :: 3.4",
57+
"Programming Language :: Python :: 3",
58+
"Programming Language :: Python :: 3.5",
59+
"Programming Language :: Python :: 3.6",
60+
"Topic :: Software Development :: Libraries",
61+
],
62+
py_modules=["tabulate"],
63+
entry_points={"console_scripts": console_scripts},
64+
extras_require={"widechars": ["wcwidth"]},
65+
test_suite="nose.collector",
66+
)

0 commit comments

Comments
 (0)