-
Notifications
You must be signed in to change notification settings - Fork 52
/
pyproject.toml
387 lines (359 loc) · 11.3 KB
/
pyproject.toml
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# Default tool config file. See also setup.cfg for tools that don't yet
# support pyproject.toml.
[tool.black]
line-length = 88
target-version = ['py311']
skip-string-normalization = true
include = '\.pyi?$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| __pycache__
| buck-out
| build
| dist
| node_modules
| funnel/assets
)/
'''
[tool.creosote]
venvs = [".venv"]
paths = ["funnel", "tests", "migrations/versions"]
deps-file = "requirements/base.in"
exclude-deps = [
"argon2-cffi", # Optional dep for passlib
"bcrypt", # Optional dep for passlib
"flask-moreshell", # Auto-imported by Flask
"greenlet", # Optional dep for SQLAlchemy's asyncio support
"gunicorn", # Not imported, used as server
"linkify-it-py", # Optional dep for markdown-it-py
"psycopg", # Optional dep for SQLAlchemy
"python-dateutil", # Creosote fails to recognise the import
"rq-dashboard", # Creosote fails to recognise the import
"tzdata", # Resource-only dep, no code to import
"urllib3", # Unused but required to silence a pip-audit warning
]
[tool.djlint]
profile = 'jinja'
extension = '.html.jinja2'
indent = 2
ignore = "T002,T028,H006,H016,H020,H023,H030,H031"
[tool.curlylint]
# Curlylint is not used, but the configuration is preserved here for future use
include = '\.html.jinja2$'
template_tags = [['set'], ['trans', 'pluralize', 'endtrans']]
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| __pycache__
| buck-out
| build
| dist
| node_modules
| funnel/assets
)/
'''
[tool.curlylint.rules]
# All role attributes must be valid.
# See https://www.curlylint.org/docs/rules/aria_role
aria_role = true
# HTML lang attribute must be set
# See https://www.curlylint.org/docs/rules/html_has_lang
html_has_lang = true
# The `alt` attribute must be present.
# See https://www.curlylint.org/docs/rules/image_alt
image_alt = true
# Indent 2 spaces
# See https://www.curlylint.org/docs/rules/indent
# Enable after issue 6 is fixed: https://github.com/thibaudcolas/curlylint/issues/6
# indent = 2
# Avoid positive `tabindex` values
tabindex_no_positive = true
[tool.isort]
# Some isort functionality is replicated in ruff, which should have matching config
profile = 'black'
multi_line_output = 3
include_trailing_comma = true
line_length = 88
order_by_type = true
use_parentheses = true
combine_as_imports = true
split_on_trailing_comma = false
known_repo = ['funnel']
known_first_party = ['baseframe', 'coaster', 'flask_lastuser']
default_section = 'THIRDPARTY'
sections = [
'FUTURE',
'STDLIB',
'THIRDPARTY',
'FIRSTPARTY',
'REPO',
'LOCALFOLDER',
]
[tool.pytest.ini_options]
minversion = "6.1" # For config.rootpath
required_plugins = [
'pytest-asyncio',
'pytest-bdd',
'pytest-cov',
'pytest-dotenv',
'pytest-env',
'pytest-rerunfailures',
'pytest-socket',
'requests-mock',
]
addopts = [
'--cov-report=term-missing',
'--disable-socket',
'--allow-unix-socket', # Required for Playwright tests
'--allow-hosts=127.0.0.1,::1', # Add Docker IPs here
'--strict-markers',
]
asyncio_mode = 'auto'
markers = [
'dbcommit: Test requires true database commits',
'formdata(dict): HTTP form data for form fixture',
'formuser("user"): User fixture for editing a form',
'update_markdown_data: Regenerate markdown test output (dev use only)',
'debug_markdown_output: Generate markdown debug file tests/data/markdown/output.html (dev use only)',
'requires_config("app", "feature"): Run test only if app config is available',
'mock_config("app", config_dict): Create mock configuration for a feature',
]
bdd_features_base_dir = 'tests/features/'
env = [
'FLASK_ENV=testing',
'FLASK_TESTING=true',
'FLASK_DEBUG_TB_ENABLED=false',
]
env_override_existing_values = false
env_files = ['.env.testing', '.testenv', '.env', '.flaskenv']
filterwarnings = ['ignore:.*:DeprecationWarning']
[tool.pyright]
venv = '.venv'
reportMissingImports = true
reportMissingTypeStubs = false
reportShadowedImports = false
pythonVersion = '3.11'
[tool.mypy]
files = '**/*.py'
exclude = ['node_modules', 'build']
ignore_missing_imports = true
show_error_codes = true
warn_unreachable = true
warn_unused_ignores = true
warn_redundant_casts = true
check_untyped_defs = true
[[tool.mypy.overrides]]
module = 'tests.*'
check_untyped_defs = true
warn_unreachable = false
[tool.pylint.master]
max-parents = 10
init-hook = """
import os, astroid.bases, pathlib
# Tell Pylint where to find packages from within tests
for path in pathlib.Path.cwd().parents:
if (path / 'pyproject.toml').is_file():
sys.path.append(str(path))
# Tell Pylint hybrid_property and cached_property are property-types
astroid.bases.POSSIBLE_PROPERTIES.add('hybrid_property')
astroid.bases.POSSIBLE_PROPERTIES.add('cached_property')
"""
[tool.pylint.message_control]
max-line-length = 88
disable = [
'abstract-method', # Defer to static type checkers
'attribute-defined-outside-init', # Defer to static type checkers
'comparison-with-callable', # Pylint is confused by SQLAlchemy attributes
'cyclic-import', # We have tail imports all over
'duplicate-code', # Too many false positives
'fixme', # Our workflow is to tag for future fixes
'invalid-name', # Ruff covers our naming convention requirements
'line-too-long', # Long lines are okay if Black doesn't wrap them
'no-member', # Pylint gets confused over how some members become part of an instance
'no-value-for-parameter', # False positives with SQLAlchemy's hybrid_method
'too-few-public-methods', # Data classes and validator classes have few methods
'too-many-ancestors', # Our models have a large number of mixin classes
'too-many-arguments', # Callables can have many optional arguments
'too-many-instance-attributes', # Some instances are just bags of attributes
'too-many-lines', # We have large files that include all related functionality
'too-many-public-methods', # Models and views have many public methods
'unused-argument', # Arguments required for spec compatibility aren't always used
'wrong-import-order', # Let isort and ruff handle this
'wrong-import-position', # Let black, isort and ruff handle this
# False positives caused by lazy_loader in funnel.models, so we depend on Mypy instead
'isinstance-second-argument-not-valid-type',
'no-name-in-module',
'not-callable',
'unsubscriptable-object',
# Temporarily disabled pending audit and fixes
'missing-class-docstring',
'missing-function-docstring',
'too-many-branches',
'too-many-locals',
'too-many-nested-blocks',
'too-many-positional-arguments',
'too-many-return-statements',
'too-many-statements',
]
[tool.bandit]
exclude_dirs = ['node_modules']
skips = [
'B113', # Handled by pylint; bandit incorrectly flags requests_mock for timeout
'B608', # Raw SQL detector is noisy for migrations and not configurable
]
[tool.bandit.assert_used]
skips = ['**/*_test.py', '**/test_*.py', '**/conftest.py']
[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]
# Same as Black.
line-length = 88
# Target Python 3.11
target-version = "py311"
[tool.ruff.format]
docstring-code-format = true
quote-style = "preserve"
[tool.ruff.lint]
select = [
"A", # flake8-builtins
"ANN", # flake8-annotations
"ARG", # flake8-unused-arguments
"ASYNC", # flake8-async
"ASYNC1", # flake8-trio
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C", # pylint convention
"C4", # flake8-comprehensions
"D", # pydocstyle
"E", # Error
"EM", # flake8-errmsg
"EXE", # flake8-executable
"F", # pyflakes
"FA", # flake8-future-annotations
"FLY", # flynt
"G", # flake8-logging-format
"I", # isort
"INP", # flake8-no-pep420
"INT", # flake8-gettext
"ISC", # flake8-implicit-str-concat
"N", # pep8-naming
"PERF", # Perflint
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"PYI", # flake8-pyi
"RET", # flake8-return
"RUF", # ruff
"S", # flake8-bandit
"SIM", # flake8-simplify
"SLOT", # flake8-slots
"T20", # flake8-print
"UP", # pyupgrade
"W", # Warnings
"YTT", # flake8-2020
]
ignore = [
"ANN002", # `*args` is implicit `Any`
"ANN003", # `**kwargs` is implicit `Any`
"ANN101", # `self` type is implicit
"ANN102", # `cls` type is implicit
"ANN401", # Allow `Any` type
"C901",
"D101",
"D102",
"D103",
"D105", # Magic methods don't need docstrings
"D106", # Nested classes don't need docstrings
"D107", # `__init__` doesn't need a docstring
"D203", # No blank lines before class docstring
"D212", # Allow multiline docstring to start on next line after quotes
"D213", # But also allow multiline docstring to start right after quotes
"E402", # Allow top-level imports after statements
"E501", # Allow long lines if the formatter can't fix it
"EM101", # Allow Exception("string")
"EM102", # Allow Exception(f"string")
"ISC001", # Allow implicitly concatenated string literals (required for formatter)
"PLR2004", # Too many false positives
"PLR0911", # Alow multiple return statements
"PLR0912", # Some functions are complex
"PLR0913", # Some functions need many args
"PLR0915", # Too many statements are okay
"RUF012", # Allow mutable ClassVar without annotation (conflicts with SQLAlchemy)
"SLOT000", # Don't require `__slots__` for subclasses of str
]
# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []
# Allow these characters in strings
allowed-confusables = ["‘", "’", "–"]
[tool.ruff.lint.extend-per-file-ignores]
"__init__.py" = ["E402"] # Allow non-top-level imports
"tests/**.py" = [
"ARG001", # Context manager fixtures may not be used within a test
"ANN001", # Args don't need types (usually fixtures)
"D401", # Fixture docstrings shouldn't be imperative
"N802", # Fixture returning a class may be named per class name convention
"N803", # Args don't require naming convention (fixture could be a class)
"N999", # Module name may have a CamelCased class name in it
"S101", # Allow assert
]
"tests/**/__init__.py" = ["D104"] # Allow empty marker `__init__.py` files
"migrations/**.py" = [
"INP001", # This folder is not a package
]
[tool.ruff.lint.isort]
# These config options should match isort config above under [tool.isort]
combine-as-imports = true
split-on-trailing-comma = false
relative-imports-order = 'furthest-to-closest'
known-first-party = ['baseframe', 'coaster', 'flask_lastuser']
section-order = [
'future',
'standard-library',
'third-party',
'first-party',
'repo',
'local-folder',
]
[tool.ruff.lint.isort.sections]
repo = ['funnel']
[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false
[tool.ruff.lint.pyupgrade]
keep-runtime-typing = true