Skip to content

Commit

Permalink
Format tox.ini
Browse files Browse the repository at this point in the history
- Bump mypy
- Add context report for coverage.py

Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
  • Loading branch information
gaborbernat authored and erikseulean committed Oct 12, 2020
1 parent 2ab8501 commit da45e50
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 61 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ repos:
rev: v1.6.0
hooks:
- id: rst-backticks
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: "0.5.0"
hooks:
- id: tox-ini-fmt
args: ["-p", "fix_lint"]
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ build-backend = 'setuptools.build_meta'
[tool.black]
line-length = 80

[tool.isort]
profile = "black"
known_first_party = ["attrst_strict", "tests"]

[tool.setuptools_scm]
write_to = "src/attrs_strict/_version.py"
write_to_template = """
Expand Down
10 changes: 8 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ install_requires =
python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4
package_dir =
=src
tests_require =

[options.extras_require]
docs =
Sphinx>=3
test =
pytest>=4
pytest-cov>=2.6
mock;python_version<'3.3'
pytest >= 4
typing;python_version<'3.4'

[options.package_data]
* = *.pyi
Expand Down
4 changes: 2 additions & 2 deletions src/attrs_strict/_type_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from itertools import izip_longest as zip_longest # type: ignore

try:
from typing import ForwardRef # type: ignore # Not in stubs
from typing import ForwardRef
except ImportError:
from typing import _ForwardRef as ForwardRef # type: ignore # Not in stubs

Expand Down Expand Up @@ -179,7 +179,7 @@ def _handle_callable(attribute, callable_, expected_type):
param.annotation for param in _signature.parameters.values()
]
callable_args.append(_signature.return_annotation)
if not getattr(expected_type, "__args__", None): # type: ignore
if not getattr(expected_type, "__args__", None):
return # No annotations specified on type, matches all Callables

for callable_arg, expected_arg in zip_longest(
Expand Down
115 changes: 58 additions & 57 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,83 +1,81 @@
[tox]
envlist =
py27
py36
py37
py38
fix_lint
py39
pypy2
py38
py37
py36
py27
pypy3
pypy2
coverage
type
fix_lint
docs
package_description
minversion = 3.7
isolated_build = true
skip_missing_interpreters = true
minversion = 3.7

[testenv]
description = run the tests with pytest under {basepython}
setenv = PIP_DISABLE_VERSION_CHECK = 1
COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}}
{py,py27,pypy2}: PYTHONWARNINGS=ignore:DEPRECATION::pip._internal.cli.base_command
passenv = http_proxy https_proxy no_proxy SSL_CERT_FILE PYTEST_*
deps =
pytest
pytest-cov
py{27,py2}: mock
py{27,py2}: typing
commands = pytest \
--cov attrs_strict \
--cov-config "{toxinidir}/tox.ini" \
--junitxml {toxworkdir}/junit.{envname}.xml \
{posargs:tests}
passenv =
PYTEST_*
SSL_CERT_FILE
setenv =
COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}}
PIP_DISABLE_VERSION_CHECK = 1
{py,py27,pypy2}: PYTHONWARNINGS = ignore:DEPRECATION::pip._internal.cli.base_command
extras =
test
commands =
pytest \
--cov attrs_strict \
--cov-config "{toxinidir}/tox.ini" \
--cov-report html:"{toxworkdir}/{envname}/coverage" --cov-context=test \
--junitxml {toxworkdir}/junit.{envname}.xml \
{posargs:tests}
rsyncdirs = conftest.py

[testenv:fix_lint]
description = format the code base to adhere to our styles, and complain about what we cannot do automatically
passenv =
{[testenv]passenv}
PROGRAMDATA
skip_install = true
deps =
pre-commit>=2
commands =
pre-commit run --all-files --show-diff-on-failure
python -c 'import pathlib; print("hint: run \{\} install to add checks as pre-commit hook".format(pathlib.Path(r"{envdir}") / "bin" / "pre-commit"))'

[testenv:type]
description = try to merge our types against our source
deps =
mypy == 0.770
retype == 19.9.0
mypy==0.782
retype==20.10
commands =
retype -p src/attrs_strict src/attrs_strict -t {envtmpdir}
retype -p src/attrs_strict src/attrs_strict/_version.py -t {envtmpdir}
mypy {envtmpdir} --strict

[testenv:docs]
description = invoke sphinx-build to build the HTML docs
deps =
sphinx
commands = sphinx-build -d "{toxworkdir}/docs_doctree" "{toxinidir}/doc" "{toxworkdir}/docs_out" --color -W -bhtml {posargs}
python -c 'import pathlib; print("documentation available under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "docs_out" / "index.html"))'
extras =
docs
commands =
sphinx-build -d "{toxworkdir}/docs_doctree" "{toxinidir}/doc" "{toxworkdir}/docs_out" --color -W -bhtml {posargs}
python -c 'import pathlib; print("documentation available under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "docs_out" / "index.html"))'

[testenv:package_description]
description = check that the long description is valid
deps = twine >= 1.12.1
readme-renderer[md] >= 24.0
pep517
skip_install = true
commands = python -m pep517.build -s -b . -o {envtmpdir}
twine check {envtmpdir}/*

[testenv:fix_lint]
description = format the code base to adhere to our styles, and complain about what we cannot do automatically
passenv = {[testenv]passenv}
# without PROGRAMDATA cloning using git for Windows will fail with an
# `error setting certificate verify locations` error
PROGRAMDATA
deps = pre-commit >= 2
skip_install = True
commands = pre-commit run --all-files --show-diff-on-failure
python -c 'import pathlib; print("hint: run \{\} install to add checks as pre-commit hook".format(pathlib.Path(r"{envdir}") / "bin" / "pre-commit"))'

[isort]
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
line_length = 80
known_first_party = attrs_strict,tests
known_third_party = attr,pytest,setuptools
deps =
build>=0.0.4
readme-renderer[md]>=24
twine>=3
commands =
python -m build --sdist --wheel . -o {envtmpdir}
twine check {envtmpdir}/*

[flake8]
max-complexity = 22
Expand All @@ -90,6 +88,9 @@ max-line-length = 80
branch = true
parallel = true

[coverage:html]
show_contexts = true

[coverage:report]
skip_covered = True
show_missing = True
Expand All @@ -103,11 +104,11 @@ exclude_lines =
[coverage:paths]
source = src/attrs_strict
*/.tox/*/lib/python*/site-packages/attrs_strict
*/.tox/pypy*/site-packages/attrs_strict
*/.tox\*\Lib\site-packages\attrs_strict
*/attrs_strict
*\attrs_strict
*/.tox/*/lib/python*/site-packages/attrs_strict
*/.tox/pypy*/site-packages/attrs_strict
*/.tox\*\Lib\site-packages\attrs_strict
*/attrs_strict
*\attrs_strict
[pytest]
junit_family=xunit2
junit_family = xunit2

0 comments on commit da45e50

Please sign in to comment.