From b863f93602b26b352bb8dd9a4c280944098f069a Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Wed, 12 Aug 2020 11:59:29 +0200 Subject: switch to yapf --- .style.yapf | 6 ++++++ Makefile | 5 +++-- fuzzycat/status.py | 1 + fuzzycat/utils.py | 3 --- setup.py | 2 +- tests/test_utils.py | 21 +++++++++++++++++---- 6 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 .style.yapf diff --git a/.style.yapf b/.style.yapf new file mode 100644 index 0000000..e061956 --- /dev/null +++ b/.style.yapf @@ -0,0 +1,6 @@ +[style] + +based_on_style = pep8 +split_before_logical_operator = true +column_limit = 160 + diff --git a/Makefile b/Makefile index 5e2bab1..ab20988 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,9 @@ data/release_export_expanded.json.gz: ## Download release export .PHONY: style style: ## Apply import sorting and black source formatting on all files - isort -c --atomic . - find . -name "*.py" -exec black {} \; + isort --atomic . + yapf -p -i -r fuzzycat + yapf -p -i -r tests .PHONY: dist dist: ## Create source distribution and wheel diff --git a/fuzzycat/status.py b/fuzzycat/status.py index cbafd32..f87c4e6 100644 --- a/fuzzycat/status.py +++ b/fuzzycat/status.py @@ -1,5 +1,6 @@ from enum import Enum + class MatchStatus(Enum): """ When matching two entities, use these levels to express match strength. diff --git a/fuzzycat/utils.py b/fuzzycat/utils.py index 6692a20..3a4be99 100644 --- a/fuzzycat/utils.py +++ b/fuzzycat/utils.py @@ -5,7 +5,6 @@ import itertools import re import string from typing import Any, Callable, DefaultDict, Dict, List, Optional, Sequence - """ A couple of utilities, may be split up into separate modules. """ @@ -26,7 +25,6 @@ class StringPipeline: input and output """ - def __init__(self, fs: List[Callable[[str], str]]): self.fs = fs @@ -73,7 +71,6 @@ class StringAnnotator: * string_utils.py or similar * maybe adopt SpaCy or similar """ - def __init__(self, fs: List[Callable[[str], Dict[str, Any]]]): self.fs = fs diff --git a/setup.py b/setup.py index 4258244..dfbef87 100644 --- a/setup.py +++ b/setup.py @@ -24,5 +24,5 @@ with open("README.md", "r") as fh: zip_safe=False, entry_points={"console_scripts": ["fuzzycat=fuzzycat.main:main",],}, install_requires=[], - extras_require={"dev": ["black", "twine", "isort", "pytest"],}, + extras_require={"dev": ["yapf", "twine", "isort", "pytest"],}, ) diff --git a/tests/test_utils.py b/tests/test_utils.py index ed206dd..cc7fae0 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,6 +1,7 @@ # coding: utf-8 from typing import List, NamedTuple + import pytest from fuzzycat.utils import * @@ -105,10 +106,22 @@ def test_keys_with_values(): cases = ( Case({}, []), Case({"a": "v"}, ["a"]), - Case({"a": "", "b": "v"}, ["b"]), - Case({"a": None, "b": "v"}, ["b"]), - Case({"a": [], "b": "v"}, ["b"]), - Case({"a": 0, "b": "v"}, ["b"]), + Case({ + "a": "", + "b": "v" + }, ["b"]), + Case({ + "a": None, + "b": "v" + }, ["b"]), + Case({ + "a": [], + "b": "v" + }, ["b"]), + Case({ + "a": 0, + "b": "v" + }, ["b"]), ) for case in cases: result = keys_with_values(case.d) -- cgit v1.2.3