From 6a34c0b8d5976bb35aecf3c794166e711b338f18 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 27 Oct 2021 15:19:23 -0700 Subject: update lint/fmt/test tools and configuration yapf => black isort config mypy configuration flake8 configuration --- .flake8 | 14 ++++++++++++++ .gitlab-ci.yml | 2 +- Makefile | 13 ++++++------- Pipfile | 11 +++++++---- pyproject.toml | 4 +--- setup.py | 7 ++++--- 6 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 .flake8 diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..c9a526e --- /dev/null +++ b/.flake8 @@ -0,0 +1,14 @@ +[flake8] +select = C,E,F,W,ANN +# ANN003 is annotation on, eg, **kwargs +# ANN101 is annotation on 'self' +# ANN204 is annotation on '__init__()' +# E265,E266 are restrictions on comments ('#') +# E501 is line-too-long, which we enforce with black +# W503,E203 are allowed by black +ignore = ANN003,ANN101,ANN204,E265,E266,E501,W503,E203 +per-file-ignores = + grobid_tei_xml/__init__.py: F401 + tests/*.py: F405,F403,E501 +exclude = .git,__pycache__,.venv +max-line-length = 96 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9217767..624edf8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,6 +12,6 @@ variables: test_python: script: - - make dep + - make deps - make test-readme - make lint diff --git a/Makefile b/Makefile index d766b30..190f8c7 100644 --- a/Makefile +++ b/Makefile @@ -9,21 +9,20 @@ help: ## Print info about all commands @echo @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[01;32m%-20s\033[0m %s\n", $$1, $$2}' -.PHONY: dep -dep: ## Install dependencies using pipenv +.PHONY: deps +deps: ## Install dependencies using pipenv pipenv install --dev .PHONY: lint lint: ## Run lints (eg, flake8, mypy) - @pipenv run flake8 grobid_tei_xml/ --exit-zero --max-line-length 96 --ignore ANN101 --per-file-ignores="grobid_tei_xml/__init__.py:F401" - @pipenv run flake8 tests/ --ignore F405,F403,E501 --exit-zero --max-line-length 96 - @pipenv run isort -q -c . + @pipenv run flake8 grobid_tei_xml/ tests/ + @pipenv run isort -q -c grobid_tei_xml/ tests/ || true @pipenv run mypy grobid_tei_xml/ tests/ .PHONY: fmt fmt: ## Run code formating on all source code - pipenv run isort --atomic grobid_tei_xml/*.py tests/*.py - pipenv run yapf -p -i -r grobid_tei_xml tests + pipenv run isort --atomic grobid_tei_xml/ tests/ + pipenv run black --line-length 96 grobid_tei_xml/ tests/ .PHONY: test test: ## Run all tests and lints diff --git a/Pipfile b/Pipfile index 3fd334e..8947189 100644 --- a/Pipfile +++ b/Pipfile @@ -11,14 +11,17 @@ name = "pypi" [dev-packages] flake8 = "*" flake8-annotations = "*" +isort = "*" mypy = "*" pytest = "*" -pytest-cov = "*" pytest-codeblocks = "*" -typing_extensions = "*" -yapf = "*" -isort = "*" +pytest-cov = "*" requests = "*" +typing_extensions = "*" + +# must lock black to an exact version because it is still "beta" +# see: https://github.com/psf/black/issues/517 +black = "==21.9b0" [requires] python_version = "3.8" diff --git a/pyproject.toml b/pyproject.toml index 7d35cd3..2cef007 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,8 +2,6 @@ requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta:__legacy__" -[tool.yapf] -COLUMN_LIMIT = 96 - [tool.isort] +profile = "black" line_length = 96 diff --git a/setup.py b/setup.py index 7b724f4..d9f1176 100644 --- a/setup.py +++ b/setup.py @@ -62,12 +62,13 @@ with open("README.md", "r") as fh: python_requires=">=3.7", install_requires=[], extras_require={"dev": [ - #"isort", + # black + "isort", "mypy", - "pylint", "pytest", + "pytest", + "pytest-codeblocks", "pytest-cov", - "yapf", ],}, cmdclass={ 'upload': UploadCommand, -- cgit v1.2.3