Skip to content

Commit

Permalink
Modernize testing/linting configuration (#65)
Browse files Browse the repository at this point in the history
This simplifies and modernizes the configuration for various testing and
linting tools. Use pyproject.toml as the central location for all
configuration as much as possible.

Details:

- Move pytest config to pyproject.toml (modern location)
- Move mypy config to pyproject.toml (modern location)
- Move unit test files into already existing tests/ dir;
  use importable and recognized-by-default-by-pytest names.
- Remove seemingly unnecessary coveragerc file; it seemed mostly
  old and outdated copy/paste of boilerplate.
- Move tool config out of CI config files as much as possible (coverage
  report filenames etc) which is not only cleaner but also better for
  local development because it will use the same settings.
- make yamllint happy about all yaml/yml files
  • Loading branch information
wbolster authored Nov 1, 2021
1 parent 71afad2 commit f8f0bd2
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 58 deletions.
24 changes: 0 additions & 24 deletions .coveragerc

This file was deleted.

9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
on:
push:
branches:
Expand Down Expand Up @@ -45,12 +46,12 @@ jobs:

# Tests
- name: Run tests
run: pytest --cov-report term --cov-report xml:coverage.xml --ignore-glob=result/tests-pattern-matching.py
run: pytest --ignore=tests/test_pattern_matching.py
- name: Run tests (pattern matching)
run: pytest --cov-report term --cov-report xml:coverage.xml result/tests-pattern-matching.py
if: matrix.python == '3.10'
run: pytest tests/test_pattern_matching.py
- name: Run mypy
run: mypy result/result.py result/tests.py
run: mypy

# Packaging
- name: Build packages
Expand All @@ -61,6 +62,6 @@ jobs:
# Coverage
- name: Upload coverage to codecov.io
uses: codecov/codecov-action@v1
if: matrix.python == '3.8'
if: matrix.python == '3.9'
with:
token: ${{ secrets.CODECOV_TOKEN }}
3 changes: 2 additions & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
coverage:
precision: 2
round: nearest
Expand All @@ -10,4 +11,4 @@ coverage:
comment:
layout: "diff, flags, files"
behavior: default
require_changes: yes
require_changes: true
14 changes: 0 additions & 14 deletions mypy.ini

This file was deleted.

35 changes: 35 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.mypy]
python_version = "3.10"
files = [
"result",
"tests",
]
# Exclude files with pattern matching syntax until Mypy supports it;
# see https://github.com/python/mypy/issues/10201
exclude = "tests/test_pattern_matching.py"
disallow_untyped_calls = true
disallow_untyped_defs = true
ignore_missing_imports = true
no_implicit_optional = true
show_column_numbers = true
show_error_codes = true
show_error_context = true
show_none_errors = true
strict_optional = true
warn_redundant_casts = true
warn_return_any = true
warn_unused_ignores = true

[tool.pytest.ini_options]
addopts = [
"--flake8",
"--tb=short",
"--cov=.",
"--cov-report=term",
"--cov-report=xml",
]
testpaths = [
"result",
"tests",
]
21 changes: 6 additions & 15 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,11 @@ zip_safe = True
[options.package_data]
result = py.typed

[tool:pytest]
addopts = --flake8 --tb=short --cov=.
python_files = tests.py
norecursedirs = *.egg tmp* build .tox
flake8-ignore =
*.py E126 E127 E128 W504
setup.py ALL
*/tests/* ALL
*/docs/* ALL
*/build/* ALL
*/venv/* ALL
*/TOXENV/* ALL
result/tests-pattern-matching.py ALL # Note: Looks like pytest-flake8 doesn't support 3.10 yet
flake8-max-line-length = 99

[flake8]
# flake8 does not (yet?) support pyproject.toml; see
# https://github.com/PyCQA/flake8/issues/234
max-line-length = 99
exclude =
.direnv/
.tox/
venv/
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions tests/type-checking/test_result.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# reveal_type(res3) # N: Revealed type is "result.result.Err[builtins.int]"
- case: failure_lash
disable_cache: false
Expand Down

0 comments on commit f8f0bd2

Please sign in to comment.