From be25b79238df9031b9efc806fb2ede1d7445b4f7 Mon Sep 17 00:00:00 2001 From: Mikhail Korobov Date: Wed, 12 Jul 2023 18:15:19 +0500 Subject: [PATCH 1/3] cleanup tools configuration * move to pyproject.toml when possible * use pre-commit in tox, don't duplicate configuration * don't run mypy in pre-commit * update flake8, mypy and isort * update github actions --- .github/workflows/test.yml | 10 ++++---- .isort.cfg | 3 --- .pre-commit-config.yaml | 22 +++++++---------- pyproject.toml | 20 ++++++++++++++++ setup.cfg | 8 ------- tox.ini | 49 +++++--------------------------------- 6 files changed, 39 insertions(+), 73 deletions(-) delete mode 100644 .isort.cfg create mode 100644 pyproject.toml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ec49b3c6..de636bfb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,9 +37,9 @@ jobs: toxenv: provider steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -59,12 +59,12 @@ jobs: fail-fast: false matrix: python-version: ["3.11"] - tox-job: ["mypy", "flake8", "twine-check"] + tox-job: ["mypy", "linters", "twine-check"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index a29184f0..00000000 --- a/.isort.cfg +++ /dev/null @@ -1,3 +0,0 @@ -[settings] -profile = black -multi_line_output = 3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ef72dcf1..bb3e8181 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,23 +1,17 @@ repos: -- repo: https://github.com/pre-commit/mirrors-isort - rev: v5.7.0 +- repo: https://github.com/PyCQA/isort + rev: 5.12.0 hooks: - id: isort -- repo: https://github.com/ambv/black - rev: 22.3.0 +- repo: https://github.com/psf/black + rev: 23.7.0 hooks: - id: black language_version: python3.8 - additional_dependencies: - - click<8.1 - repo: https://github.com/pycqa/flake8 - rev: 3.8.4 - hooks: - - id: flake8 -- repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.991 + rev: 6.0.0 hooks: - - id: mypy + - id: flake8 additional_dependencies: - - types-setuptools - args: [--check-untyped-defs, --ignore-missing-imports, --no-warn-no-return] + - flake8-docstrings + - flake8-print diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..88c97f1d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,20 @@ +[tool.isort] +profile = "black" +multi_line_output = 3 + +[tool.mypy] +#check_untyped_defs = true +ignore_missing_imports = true +no_warn_no_return = true +files = [ + "scrapy_zyte_api", + "tests" +] + +[tool.pytest.ini_options] +junit_family = "xunit2" +testpaths = [ + "scrapy_zyte_api/", + "tests/" +] +minversion = "6.0" diff --git a/setup.cfg b/setup.cfg index 90325e8a..55c5316c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,11 +5,3 @@ max-complexity = 18 select = B,C,E,F,W,T4 per-file-ignores = tests/test_providers.py: E402 - -[mypy] -files=scrapy_zyte_api,tests -ignore_missing_imports=true - -[tool:pytest] -junit_family=xunit2 -testpaths=scrapy_zyte_api/ tests/ diff --git a/tox.ini b/tox.ini index 55052a02..c58f8795 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py37,py38,py39,py310,py311,mypy,isort,black,flake8 +envlist = py37,py38,py39,py310,py311,mypy,linters,twine-check [testenv] deps = @@ -82,51 +82,14 @@ extras = provider [testenv:mypy] deps = - mypy==0.991 + mypy==1.4.1 types-setuptools -commands = mypy --check-untyped-defs --ignore-missing-imports --no-warn-no-return scrapy_zyte_api tests +commands = mypy scrapy_zyte_api tests -[testenv:flake8] -deps = - flake8 - flake8-docstrings - flake8-print>=3.0.1 -commands = - flake8 \ - scrapy_zyte_api \ - setup.py \ - tests \ - {posargs} - -[testenv:black] -deps = - black -commands = - black \ - scrapy_zyte_api \ - setup.py \ - tests/ \ - {posargs} - -[testenv:black-check] -deps = - {[testenv:black]deps} -commands = - {[testenv:black]commands} --diff - -[testenv:isort] -deps = isort -commands = - isort \ - scrapy_zyte_api/ \ - setup.py \ - tests/ \ - {posargs} - -[testenv:isort-check] -deps = {[testenv:isort]deps} -commands = {[testenv:isort]commands} -c +[testenv:linters] +deps = -rrequirements-dev.txt +commands = pre-commit run --all-files --show-diff-on-failure [testenv:twine-check] deps = From edd2ed2eabc4381d240027f0c598c42a2de6efd2 Mon Sep 17 00:00:00 2001 From: Mikhail Korobov Date: Wed, 12 Jul 2023 18:23:18 +0500 Subject: [PATCH 2/3] fix black configuration --- .pre-commit-config.yaml | 1 - pyproject.toml | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bb3e8181..3cffcf53 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,6 @@ repos: rev: 23.7.0 hooks: - id: black - language_version: python3.8 - repo: https://github.com/pycqa/flake8 rev: 6.0.0 hooks: diff --git a/pyproject.toml b/pyproject.toml index 88c97f1d..9fac8d00 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,6 @@ +[tool.black] +target-version = ["py38", "py39", "py310", "py311"] + [tool.isort] profile = "black" multi_line_output = 3 From 8fd21389e61a9f8e45d005f24a519d4e1c47824d Mon Sep 17 00:00:00 2001 From: Mikhail Korobov Date: Wed, 12 Jul 2023 21:04:36 +0500 Subject: [PATCH 3/3] proper mypy config --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9fac8d00..75ae5cb1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ profile = "black" multi_line_output = 3 [tool.mypy] -#check_untyped_defs = true +check_untyped_defs = true ignore_missing_imports = true no_warn_no_return = true files = [