Skip to content

Commit

Permalink
Bump linters and CI to 3.10
Browse files Browse the repository at this point in the history
Signed-off-by: Bernát Gábor <gaborjbernat@gmail.com>
  • Loading branch information
gaborbernat committed Dec 29, 2021
1 parent 87c1d95 commit 53ea140
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 140 deletions.
129 changes: 68 additions & 61 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,116 +2,123 @@ name: check
on:
push:
pull_request:
schedule:
- cron: "0 8 * * *"

concurrency:
group: check-${{ github.ref }}
cancel-in-progress: true

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- uses: pre-commit/action@v2.0.0

test:
name: test ${{ matrix.py }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
name: test ${{ matrix.py }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
os:
- Ubuntu
- Windows
- macOS
py:
- 3.10.0-rc.2
- 3.9
- 3.8
- 3.7
- 3.6
- "3.10"
- "3.9"
- "3.8"
- "3.7"
steps:
- name: Setup python for tox
- name: setup python for tox
uses: actions/setup-python@v2
with:
python-version: 3.10.0-rc.2
- name: Install tox
python-version: "3.10"
- name: install tox
run: python -m pip install tox
- uses: actions/checkout@v2
- name: Setup python for test ${{ matrix.py }}
- name: setup python for test ${{ matrix.py }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.py }}
- name: Pick environment to run
- name: pick environment to run
run: |
import platform; import os; import sys; import codecs
cpy = platform.python_implementation() == "CPython"
base =("{}{}{}" if cpy else "{}{}").format("py" if cpy else "pypy", *sys.version_info[0:2])
env = "TOXENV={}\n".format(base)
print("Picked:\n{}for{}".format(env, sys.version))
with codecs.open(os.environ["GITHUB_ENV"], "a", "utf-8") as file_handler:
file_handler.write(env)
import os
with open(os.environ['GITHUB_ENV'], 'a') as file_handler:
file_handler.write('TOXENV=py${{matrix.py}}'.replace('.', ''))
shell: python
- name: Setup test suite
- name: setup test suite
run: tox -vv --notest
- name: Run test suite
- name: run test suite
run: tox --skip-pkg-install
env:
PYTEST_ADDOPTS: "-vv --durations=20"
CI_RUN: "yes"
DIFF_AGAINST: HEAD
- name: rename coverage report file
run: |
import os; os.rename('.tox/coverage.{}.xml'.format(os.environ['TOXENV']), '.tox/coverage.xml')
shell: python
- uses: codecov/codecov-action@v1
- name: Upload coverage data
uses: actions/upload-artifact@v2
with:
file: ./.tox/coverage.xml
flags: tests
name: ${{ matrix.py }} - ${{ matrix.os }}
name: coverage-data
path: ".tox/.coverage.*"

coverage:
name: Combine coverage
runs-on: ubuntu-20.04
needs: test
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install tox
run: python -m pip install tox
- name: Setup coverage tool
run: tox -e coverage --notest
- name: Install package builder
run: python -m pip install build
- name: Build package
run: pyproject-build --wheel .
- name: Download coverage data
uses: actions/download-artifact@v2
with:
name: coverage-data
path: .tox
- name: Combine and report coverage
run: tox -e coverage
- name: Upload HTML report
uses: actions/upload-artifact@v2
with:
name: html-report
path: .tox/htmlcov
check:
name: check ${{ matrix.tox_env }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
name: tox env ${{ matrix.tox_env }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
os:
- Ubuntu
tox_env:
- merge
- type
- package_readme
- merge
- dev
- readme
steps:
- uses: actions/checkout@v2
- name: Setup Python 3.10.0-rc.2
- name: setup Python 3.10
uses: actions/setup-python@v2
with:
python-version: 3.10.0-rc.2
- name: Install tox
python-version: "3.10"
- name: install tox
run: python -m pip install tox
- name: Run check for ${{ matrix.tox_env }}
- name: run check for ${{ matrix.tox_env }}
run: python -m tox -e ${{ matrix.tox_env }}
env:
UPGRADE_ADVISORY: "yes"

publish:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [check, test, pre-commit]
runs-on: ubuntu-latest
needs: [check, coverage]
runs-on: ubuntu-20.04
steps:
- name: Setup python to build package
- name: setup python to build package
uses: actions/setup-python@v2
with:
python-version: 3.10.0-rc.2
- name: Install build
python-version: "3.10"
- name: install build
run: python -m pip install build
- uses: actions/checkout@v2
- name: Build package
- name: build package
run: python -m build --sdist --wheel . -o dist
- name: Publish to PyPI
- name: publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
skip_existing: true
Expand Down
50 changes: 37 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,58 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-ast
- id: check-builtin-literals
- id: check-docstring-first
- id: check-merge-conflict
- id: check-yaml
- id: check-toml
- id: debug-statements
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies: [ "flake8-bugbear", "flake8-pyi" ]
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v2.29.0
rev: v2.30.0
hooks:
- id: pyupgrade
args: [ "--py36-plus" ]
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
hooks:
- id: isort
- repo: https://github.com/python/black
- repo: https://github.com/psf/black
rev: 21.9b0
hooks:
- id: black
args: [ --safe ]
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.17.0
- repo: https://github.com/asottile/blacken-docs
rev: v1.11.0
hooks:
- id: setup-cfg-fmt
args: ['--max-py-version', '3.10']
- id: blacken-docs
additional_dependencies: [ black==21.9b0 ]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: rst-backticks
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: "0.5.1"
hooks:
- id: tox-ini-fmt
args: [ "-p", "fix" ]
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.17.0
hooks:
- id: setup-cfg-fmt
args: [ --min-py3-version, "3.7", "--max-py-version", "3.10" ]
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==21.9.1
- flake8-comprehensions==3.6.1
- flake8-pytest-style==1.5
- flake8-spellcheck==0.24
- flake8-unused-arguments==0.0.6
- flake8-noqa==1.1.0
- flake8-eradicate==1.1.0
- pep8-naming==0.12.1
42 changes: 27 additions & 15 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ classifiers =
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Expand All @@ -35,7 +34,7 @@ install_requires =
click>=7
pathspec>=0.5.9,<1
typed-ast>=1.3
python_requires = >=3.6
python_requires = >=3.7
package_dir =
=src
zip_safe = False
Expand All @@ -48,9 +47,10 @@ console_scripts =
retype=retype.__main__:main

[options.extras_require]
testing =
test =
covdefaults>=2
pytest>=6
pytest-cov>=2.5.1
pytest-cov>=3

[flake8]
ignore =
Expand All @@ -60,24 +60,36 @@ ignore =
E225,
E302,
E203,
E800,
E741,
max-line-length = 88
max-complexity = 32
select = B,C,E,F,T4,W,B9
noqa-require-code = true

[coverage:run]
branch = true
plugins = covdefaults
parallel = true

[coverage:paths]
src =
src
.tox/*/lib/python*/site-packages
.tox/pypy*/site-packages
.tox\*\Lib\site-packages\
*/src
*\src
other =
.
*/retype
*\retype

[coverage:report]
skip_covered = True
show_missing = True
fail_under = 88

[coverage:paths]
source =
src/retype
.tox/*/lib/python*/site-packages/retype
.tox/pypy*/site-packages/retype
.tox\*\Lib\site-packages\retype
*/src/retype
*\src\retype
[coverage:html]
show_contexts = true
skip_covered = false

[coverage:covdefaults]
subtract_omit = */.tox/*
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Handle the package management of the module"""
from __future__ import annotations

from setuptools import setup

setup()
3 changes: 2 additions & 1 deletion src/retype/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
"""Re-apply type annotations from .pyi stubs to your codebase."""
from __future__ import annotations

import os
import re
Expand Down Expand Up @@ -37,7 +38,7 @@ def retype_path(
extra_ignore = []
for folder in [pyi_dir, targets]:
try:
extra_ignore.append("/{}".format(folder.relative_to(src)))
extra_ignore.append(f"/{folder.relative_to(src)}")
except ValueError:
pass
for file in walk_not_git_ignored(
Expand Down
2 changes: 2 additions & 0 deletions src/retype/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import sys
from functools import partial
from pathlib import Path
Expand Down
3 changes: 3 additions & 0 deletions src/retype/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from __future__ import annotations


class ReApplyFlags:

__slots__ = ("replace_any", "incremental")
Expand Down
2 changes: 2 additions & 0 deletions src/retype/retype_hgext.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import io
import token
import tokenize
Expand Down
2 changes: 2 additions & 0 deletions tests/test_discovery.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from collections import namedtuple
from pathlib import Path

Expand Down
2 changes: 2 additions & 0 deletions tests/test_entry_points.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import subprocess
import sys
from pathlib import Path
Expand Down
Loading

0 comments on commit 53ea140

Please sign in to comment.