-
Notifications
You must be signed in to change notification settings - Fork 152
/
tox.ini
177 lines (147 loc) · 4.98 KB
/
tox.ini
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
################################################################################
# Tox Configuration
################################################################################
[constants]
source_locations =
py_trees
tests
# doc/examples
[tox]
envlist = py38, py310, format, check, mypy38, mypy310
################################################################################
# PyTest
################################################################################
[testenv]
require_locked_deps = true
require_poetry = true
locked_deps =
pytest
pytest-console-scripts
pytest-cov
commands =
pytest -s tests/
pytest --cov
[coverage:run]
# ensure conditional branches are explored (important)
# https://coverage.readthedocs.io/en/latest/branch.html#branch
branch = true
######################################################################
# Ufmt (black + isort)
######################################################################
[testenv:format]
description = Un-opinionated auto-formatting.
locked_deps =
ufmt
commands =
ufmt format {[constants]source_locations}
################################################################################
# Flake 8
################################################################################
[testenv:check]
skip_install = true
description = Formatting checks and linting (flake8 & ufmt check).
locked_deps =
darglint
flake8
flake8-docstrings
ufmt
commands =
flake8 {[constants]source_locations}
ufmt check {[constants]source_locations}
################################################################################
# Flake 8 Configuration
#
# Don't require docstrings, but parse them correctly if they are there.
#
# D100 Missing docstring in public module
# D101 Missing docstring in public class
# D102 Missing docstring in public method
# D103 Missing docstring in public function
# D105 Missing docstring in magic method
# D107 Missing docstring in __init__
#
# Jamming docstrings into a single line looks cluttered.
#
# D200 One-line docstring should fit on one line with quotes
#
# Weakly prefer breaking before a binary operator, so suppress that warning.
# See https://github.com/python/peps/commit/c59c4376ad233a62ca4b3a6060c81368bd21e85b
#
# W503 line break before binary operator
#
################################################################################
[flake8]
# Relax various checks in the tests dir
# - D*** documentation (docstrings)
# - S101 use of assert warning (bandit)
# - F401 unused import (from . import in __init__.py files)
per-file-ignores =
tests/*: D, S101,
py_trees/__init__.py: F401
# Match black line lengths
# max-line-length = 88
max-line-length = 120
# Avoid overly complex functions
# NB: this option by default is off, recommend complexity is 10
# https://en.wikipedia.org/wiki/Cyclomatic_complexity
max-complexity: 15
# darglint docstring matching implementation checks
# - short: one liners are not checked
# - long: one liners and descriptions without args/returns are not checked
strictness = long
docstring_style=sphinx
# Relax some of the more annoying checks
# - C901 have a couple of stubborn methods (TODO)
# - D105 magic method docstrings
# - D107 prefer to include init args in the class documentation
# - W503 deprecated PEP8, pay attention to 504 instead
# https://www.flake8rules.com/rules/W503.html
# - W504 line break after operator (TODO)
ignore = C901, D105, D107, W503
################################################################################
# Mypy
################################################################################
[testenv:mypy38]
skip_install = true
description = Static type checking against python 3.8.
locked_deps =
mypy
pytest
commands =
mypy --config-file {toxinidir}/tox.ini --python-version 3.8 {[constants]source_locations}
[testenv:mypy310]
skip_install = true
description = Static type checking against python 3.10.
commands =
mypy --config-file {toxinidir}/tox.ini --python-version 3.10 {[constants]source_locations}
locked_deps =
mypy
pytest
[mypy]
# With no options you get light coverage on some basics.
# In general, you'll want to go further. Even for new code, it's
# a great idea to enforce typehints on func args and returns as
# it immensively improves the readability and traceability of
# your code (and catches bugs!).
####################
# Good to have
####################
# Typehint all function args and returns
disallow_untyped_defs = True
# Unneeded # type: ignore comments.
warn_unused_ignores = True
# Complain if a function doesn't return anything when it should
warn_no_return = True
####################
# Stricter Options
####################
# Catch zombie code
warn_unreachable = True
# Type correctness between variables inside functions
check_untyped_defs = True
# Complain if a func isn't configured to return 'Any'
warn_return_any = True
# Check on casting operations
warn_redundant_casts = True
[mypy-pydot.*]
ignore_missing_imports = True