Skip to content

Commit b1465c3

Browse files
committed
Enable "pre-commit".
1 parent 45158cc commit b1465c3

File tree

7 files changed

+55
-33
lines changed

7 files changed

+55
-33
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
repos:
2+
- repo: https://gitlab.com/pycqa/flake8
3+
rev: 3.7.8
4+
hooks:
5+
- id: flake8
6+
exclude: examples
7+
- repo: https://github.com/pre-commit/mirrors-yapf
8+
rev: v0.23.0
9+
hooks:
10+
- id: yapf

docs/conf.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import colour_checker_detection as package
1818

19-
basename = re.sub('_(\w)', lambda x: x.group(1).upper(),
19+
basename = re.sub('_(\\w)', lambda x: x.group(1).upper(),
2020
package.__name__.title())
2121

2222
autosummary_generate = True
@@ -217,9 +217,8 @@
217217
# (source start file, target name, title,
218218
# author, documentclass [howto, manual, or own class]).
219219
latex_documents = [
220-
('index', '{0}.tex'.format(basename),
221-
u'{0} Documentation'.format(package.__application_name__),
222-
package.__author__, 'manual'),
220+
('index', '{0}.tex'.format(basename), u'{0} Documentation'.format(
221+
package.__application_name__), package.__author__, 'manual'),
223222
]
224223

225224
# The name of an image file (relative to this directory) to place at the top of
@@ -246,9 +245,8 @@
246245

247246
# One entry per manual page. List of tuples
248247
# (source start file, name, description, authors, manual section).
249-
man_pages = [('index', basename,
250-
u'{0} Documentation'.format(package.__application_name__),
251-
[package.__author__], 1)]
248+
man_pages = [('index', basename, u'{0} Documentation'.format(
249+
package.__application_name__), [package.__author__], 1)]
252250

253251
# If true, show URL addresses after external links.
254252
# man_show_urls = False
@@ -259,10 +257,9 @@
259257
# (source start file, target name, title, author,
260258
# dir menu entry, description, category)
261259
texinfo_documents = [
262-
('index', basename,
263-
u'{0} Documentation'.format(package.__application_name__),
264-
package.__author__, package.__application_name__, basename,
265-
'Miscellaneous'),
260+
('index', basename, u'{0} Documentation'.format(
261+
package.__application_name__), package.__author__,
262+
package.__application_name__, basename, 'Miscellaneous'),
266263
]
267264

268265
# Documents to append as an appendix to all manuals.
@@ -288,10 +285,10 @@
288285
# The basename for the epub file. It defaults to the project name.
289286
# epub_basename = basename
290287

291-
# The HTML theme for the epub output. Since the default themes are not optimized
292-
# for small screen space, using the same theme for HTML and epub output is
293-
# usually not wise. This defaults to 'epub', a theme designed to save visual
294-
# space.
288+
# The HTML theme for the epub output. Since the default themes are not
289+
# optimized for small screen space, using the same theme for HTML and epub
290+
# output is usually not wise. This defaults to 'epub', a theme designed to save
291+
# visual space.
295292
# epub_theme = 'epub'
296293

297294
# The language of the text. It defaults to the language option

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ invoke = { version = "*", optional = true } # Development dependency.
5353
mock = { version = "*", optional = true } # Development dependency.
5454
nose = { version = "*", optional = true } # Development dependency.
5555
numpy = { version = "*", optional = true }
56+
pre-commit = { version = "*", optional = true } # Development dependency.
5657
pytest = { version = "*", optional = true } # Development dependency.
5758
restructuredtext-lint = { version = "*", optional = true } # Development dependency.
5859
sphinx = { version = "*", optional = true } # Development dependency.
@@ -70,6 +71,7 @@ flake8 = "*"
7071
invoke = "*"
7172
mock = "*"
7273
nose = "*"
74+
pre-commit = "*"
7375
pytest = "*"
7476
restructuredtext-lint = "*"
7577
sphinx = "*"
@@ -88,6 +90,7 @@ development = [
8890
"invoke",
8991
"mock",
9092
"nose",
93+
"pre-commit",
9194
"pytest",
9295
"restructuredtext-lint",
9396
"sphinx",

requirements.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
alabaster==0.7.12
2+
aspy.yaml==1.3.0
23
atomicwrites==1.3.0
34
attrs==19.2.0
45
Babel==2.7.0
56
biblib-simple==0.1.1
67
bleach==3.1.0
78
certifi==2019.9.11
9+
cfgv==2.0.1
810
chardet==3.0.4
911
colour==0.3.13
1012
colour-demosaicing==0.1.4
@@ -15,6 +17,7 @@ docopt==0.6.2
1517
docutils==0.15.2
1618
entrypoints==0.3
1719
flake8==3.7.8
20+
identify==1.4.7
1821
idna==2.8
1922
imageio==2.5.0
2023
imagesize==1.1.0
@@ -26,6 +29,7 @@ MarkupSafe==1.1.1
2629
mccabe==0.6.1
2730
mock==3.0.5
2831
more-itertools==7.2.0
32+
nodeenv==1.3.3
2933
nose==1.3.7
3034
numpy==1.17.2
3135
opencv-python==4.1.1.26
@@ -34,15 +38,16 @@ packaging==19.2
3438
Pillow==6.2.0
3539
pkginfo==1.5.0.1
3640
pluggy==0.13.0
41+
pre-commit==1.18.3
3742
py==1.8.0
3843
pybtex==0.22.2
3944
pybtex-docutils==0.2.1
4045
pycodestyle==2.5.0
4146
pyflakes==2.1.1
4247
Pygments==2.4.2
4348
pyparsing==2.4.2
44-
pytest==5.2.0
45-
pytz==2019.2
49+
pytest==5.2.1
50+
pytz==2019.3
4651
PyYAML==5.1.2
4752
readme-renderer==24.0
4853
requests==2.22.0
@@ -64,6 +69,7 @@ toml==0.10.0
6469
tqdm==4.36.1
6570
twine==1.15.0
6671
urllib3==1.25.6
72+
virtualenv==16.7.5
6773
wcwidth==0.1.7
6874
webencodings==0.5.1
6975
yapf==0.23.0

tasks.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
from __future__ import unicode_literals
88

99
import sys
10-
if sys.version_info[:2] >= (3, 2):
10+
try:
1111
import biblib.bib
12+
except ImportError:
13+
pass
1214
import fnmatch
1315
import os
1416
import re
@@ -384,11 +386,11 @@ def tag(ctx):
384386

385387
with open(os.path.join(PYTHON_PACKAGE_NAME, '__init__.py')) as file_handle:
386388
file_content = file_handle.read()
387-
major_version = re.search("__major_version__\s+=\s+'(.*)'",
389+
major_version = re.search("__major_version__\\s+=\\s+'(.*)'",
388390
file_content).group(1)
389-
minor_version = re.search("__minor_version__\s+=\s+'(.*)'",
391+
minor_version = re.search("__minor_version__\\s+=\\s+'(.*)'",
390392
file_content).group(1)
391-
change_version = re.search("__change_version__\s+=\s+'(.*)'",
393+
change_version = re.search("__change_version__\\s+=\\s+'(.*)'",
392394
file_content).group(1)
393395

394396
version = '.'.join((major_version, minor_version, change_version))

utilities/export_todo.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@
3232
-----
3333
3434
| **Colour - Checker Detection** by Colour Developers
35-
| Copyright © 2018-2019 – Colour Developers – `colour-science@googlegroups.com <colour-science@googlegroups.com>`_
36-
| This software is released under terms of New BSD License: https://opensource.org/licenses/BSD-3-Clause
37-
| `https://github.com/colour-science/colour-checker-detection <https://github.com/colour-science/colour-checker-detection>`_
38-
"""[1:]
35+
| Copyright © 2018-2019 – Colour Developers – \
36+
`colour-science@googlegroups.com <colour-science@googlegroups.com>`_
37+
| This software is released under terms of New BSD License: \
38+
https://opensource.org/licenses/BSD-3-Clause
39+
| `https://github.com/colour-science/colour-checker-detection \
40+
<https://github.com/colour-science/colour-checker-detection>`_
41+
""" [1:]
3942

4043

4144
def extract_todo_items(root_directory):
@@ -105,8 +108,8 @@ def export_todo_items(todo_items, file_path):
105108
for module, todo_items in todo_items.items():
106109
todo_rst.append('- {0}\n'.format(module))
107110
for line_numer, todo_item in todo_items:
108-
todo_rst.append(
109-
' - Line {0} : {1}'.format(line_numer, todo_item))
111+
todo_rst.append(' - Line {0} : {1}'.format(
112+
line_numer, todo_item))
110113

111114
todo_rst.append('\n')
112115

utilities/unicode_to_ascii.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
reload(sys) # noqa
1212
sys.setdefaultencoding('utf-8')
1313

14-
import codecs
15-
import os
16-
import unicodedata
14+
import codecs # noqa
15+
import os # noqa
16+
import unicodedata # noqa
1717

1818
__copyright__ = 'Copyright (C) 2018-2019 - Colour Developers'
1919
__license__ = 'New BSD License - https://opensource.org/licenses/BSD-3-Clause'
@@ -46,9 +46,10 @@ def unicode_to_ascii(root_directory):
4646

4747
for root, dirnames, filenames in os.walk(root_directory):
4848
for filename in filenames:
49-
if (not filename.endswith('.tex') and not filename.endswith('.py')
50-
and not filename.endswith('.bib')
51-
and not filename.endswith('.rst')):
49+
if (not filename.endswith('.tex') and
50+
not filename.endswith('.py') and
51+
not filename.endswith('.bib') and
52+
not filename.endswith('.rst')):
5253
continue
5354

5455
if filename == 'unicode_to_ascii.py':

0 commit comments

Comments
 (0)