From 1520f08b05652d5d3cb6790a5593bd3b53e8eb76 Mon Sep 17 00:00:00 2001 From: Celina Peralta Date: Sun, 23 Oct 2022 19:51:47 -0400 Subject: [PATCH] Fix pre-commit hook + linting jobs for OAPEN engine (#14) * sync upstream * isort, black, flake8 precommit hook * Ignore bin * reset bin * reset bin * try to fix black * remove bin! * update gh action --- .flake8 | 5 +++++ .github/workflows/engine.yml | 2 +- .isort.cfg | 9 +++++++++ .pre-commit-config.yaml | 28 ++++++++++++---------------- oapen-engine/.gitignore | 5 ++++- pyproject.toml | 22 ++++++++++++++++++++++ setup.cfg | 18 ------------------ 7 files changed, 53 insertions(+), 36 deletions(-) create mode 100644 .flake8 create mode 100644 .isort.cfg create mode 100644 pyproject.toml delete mode 100644 setup.cfg diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..9dc494b --- /dev/null +++ b/.flake8 @@ -0,0 +1,5 @@ +[flake8] +max-line-length = 88 +max-complexity = 18 +select = B,C,E,F,W,T4,B9 +ignore = E203, E266, E501, W503, F403, F401 \ No newline at end of file diff --git a/.github/workflows/engine.yml b/.github/workflows/engine.yml index 6f1ec60..bc402e0 100644 --- a/.github/workflows/engine.yml +++ b/.github/workflows/engine.yml @@ -22,7 +22,7 @@ jobs: pipenv install --deploy --dev pipenv run isort --profile black src/ pipenv run black --check src/ --exclude="lib/*" - pipenv run flake8 src/ --ignore="lib/* W" + pipenv run flake8 src/ --ignore="lib/*, W, E203, E266, E501, W503, F403, F401" pipenv run pytest \ No newline at end of file diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000..0db27e2 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,9 @@ +[settings] +multi_line_output=3 +include_trailing_comma=True +force_grid_wrap=0 +use_parentheses=True +line_length=88 +skip=[lib/, bin/] +profile=black +known_third_party = data,lib,model,nltk,pandas,psycopg2,requests diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4f982f1..975e2d9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,18 +1,14 @@ repos: - - repo: https://github.com/pycqa/isort - rev: 5.10.1 +- repo: https://github.com/pre-commit/mirrors-isort + rev: v5.10.1 hooks: - - id: isort - args: [--profile, black, --filter-files, oapen-engine/src] - name: isort (python) - - repo: https://github.com/psf/black - rev: stable - hooks: - - id: black - language_version: python3.10 - args: [oapen-engine/src] - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v1.2.3 - hooks: - - id: flake8 - args: [oapen-engine/src] \ No newline at end of file + - id: isort +- repo: https://github.com/ambv/black + rev: 22.10.0 + hooks: + - id: black + language_version: python3.10 +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: flake8 \ No newline at end of file diff --git a/oapen-engine/.gitignore b/oapen-engine/.gitignore index a239fc3..08f3f87 100644 --- a/oapen-engine/.gitignore +++ b/oapen-engine/.gitignore @@ -161,4 +161,7 @@ cython_debug/ database.ini lib/python3.7/ -lib/python3.10/ \ No newline at end of file +lib/python3.10/ +bin/ +.pytest_cache +lib/ \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e41e938 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,22 @@ +[tool.black] +line-length = 88 +include = '\.pyi?$' +exclude = ''' +/( + \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + | lib + | ./oapen-engine/lib + | __pycache__ + | bin + | ./oapen-engine/bin + | +)/ +''' \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 0ff30db..0000000 --- a/setup.cfg +++ /dev/null @@ -1,18 +0,0 @@ -[isort] -multi_line_output=3 -include_trailing_comma=True -force_grid_wrap=0 -use_parentheses=True -line_length=88 -skip=[lib/] -profile=black - -[flake8] -ignore = E203, E266, E501, W503, E501 -max-line-length = 88 -max-complexity = 18 -select = B,C,E,F,W,T4 -exclude=.git,lib,__pycache__ - -[tool:pytest] -testpaths=src/test \ No newline at end of file