Skip to content

Commit 8e8563e

Browse files
Merge pull request #1291 from VWS-Python/yapf-to-black
Switch from yapf to black
2 parents 6073380 + 41fcc7c commit 8e8563e

File tree

7 files changed

+45
-36
lines changed

7 files changed

+45
-36
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SPHINXOPTS := -W
77

88
.PHONY: lint
99
lint: \
10+
black \
1011
check-manifest \
1112
doc8 \
1213
flake8 \
@@ -21,12 +22,11 @@ lint: \
2122
vulture \
2223
pylint \
2324
pydocstyle \
24-
yapf
2525

2626
.PHONY: fix-lint
2727
fix-lint: \
2828
autoflake \
29-
fix-yapf \
29+
fix-black \
3030
fix-isort
3131

3232
.PHONY: docs

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# We use dev-requirements.txt instead of just declaring the requirements in
22
# the setup function because Read The Docs needs a requirements file.
3+
black==20.8b1
34
PyYAML==5.3.1
45
Pygments==2.6.1
56
Sphinx-Substitution-Extensions==2020.7.4.1
@@ -29,4 +30,3 @@ sphinxcontrib-spelling==5.3.0
2930
twine==3.2.0
3031
versioneer==0.18
3132
vulture==2.1
32-
yapf==0.30.0 # Automatic formatting for Python

lint.mk

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,13 @@
22

33
SHELL := /bin/bash -euxo pipefail
44

5-
.PHONY: yapf
6-
yapf:
7-
yapf \
8-
--diff \
9-
--recursive \
10-
--exclude .eggs \
11-
.
5+
.PHONY: black
6+
black:
7+
black --check .
128

13-
.PHONY: fix-yapf
14-
fix-yapf:
15-
yapf \
16-
--in-place \
17-
--recursive \
18-
--exclude .eggs \
19-
.
9+
.PHONY: fix-black
10+
fix-black:
11+
black .
2012

2113
.PHONY: mypy
2214
mypy:

pyproject.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
'too-many-arguments',
4646
'too-many-instance-attributes',
4747
'too-many-return-statements',
48+
'too-many-lines',
4849
'locally-disabled',
50+
# Let flake8 handle long lines
51+
'line-too-long',
4952
# Let flake8 handle unused imports
5053
'unused-import',
5154
# Let isort deal with sorting
@@ -54,9 +57,9 @@
5457
'missing-type-doc',
5558
'missing-returns-doc',
5659
'missing-return-type-doc',
57-
# Let YAPF deal with this
60+
# Let auto-formatters deal with this
5861
'bad-continuation',
59-
# Let YAPF deal with this
62+
# Let auto-formatters deal with this
6063
'bad-whitespace',
6164
# Too difficult to please
6265
'duplicate-code',
@@ -82,3 +85,8 @@
8285
# Tells whether to store unknown words to indicated private dictionary in
8386
# --spelling-private-dict-file option instead of raising a message.
8487
spelling-store-unknown-words = 'no'
88+
89+
[tool.black]
90+
91+
line-length = 79
92+
skip-string-normalization = true

setup.cfg

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ include_trailing_comma=true
9797
[coverage:run]
9898
branch = True
9999

100-
[yapf]
101-
DEDENT_CLOSING_BRACKETS = true
102-
BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF = true
103-
104100
[metadata]
105101
name = VWS Python
106102
description = Interact with the Vuforia Web Services (VWS) API.

src/vws/query.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ def query(
4646
self,
4747
image: io.BytesIO,
4848
max_num_results: int = 1,
49-
include_target_data:
50-
CloudRecoIncludeTargetData = CloudRecoIncludeTargetData.TOP,
49+
include_target_data: CloudRecoIncludeTargetData = (
50+
CloudRecoIncludeTargetData.TOP
51+
),
5152
) -> List[QueryResult]:
5253
"""
5354
Use the Vuforia Web Query API to make an Image Recognition Query.
@@ -89,8 +90,11 @@ def query(
8990
body = {
9091
'image': ('image.jpeg', image_content, 'image/jpeg'),
9192
'max_num_results': (None, int(max_num_results), 'text/plain'),
92-
'include_target_data':
93-
(None, include_target_data.value, 'text/plain'),
93+
'include_target_data': (
94+
None,
95+
include_target_data.value,
96+
'text/plain',
97+
),
9498
}
9599
date = rfc_1123_date()
96100
request_path = '/v1/query'

tests/test_vws.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -336,18 +336,23 @@ def test_default_seconds_between_requests(
336336
report = vws_client.get_database_summary_report()
337337
expected_requests = (
338338
# Add target request
339-
1 +
339+
1
340+
+
340341
# Database summary request
341-
1 +
342+
1
343+
+
342344
# Initial request
343-
1 +
345+
1
346+
+
344347
# Request after 0.2 seconds - not processed
345-
1 +
348+
1
349+
+
346350
# Request after 0.4 seconds - not processed
347351
# This assumes that there is less than 0.1 seconds taken
348352
# between the start of the target processing and the start of
349353
# waiting for the target to be processed.
350-
1 +
354+
1
355+
+
351356
# Request after 0.6 seconds - processed
352357
1
353358
)
@@ -386,16 +391,20 @@ def test_custom_seconds_between_requests(
386391
report = vws_client.get_database_summary_report()
387392
expected_requests = (
388393
# Add target request
389-
1 +
394+
1
395+
+
390396
# Database summary request
391-
1 +
397+
1
398+
+
392399
# Initial request
393-
1 +
400+
1
401+
+
394402
# Request after 0.3 seconds - not processed
395403
# This assumes that there is less than 0.2 seconds taken
396404
# between the start of the target processing and the start of
397405
# waiting for the target to be processed.
398-
1 +
406+
1
407+
+
399408
# Request after 0.6 seconds - processed
400409
1
401410
)

0 commit comments

Comments
 (0)