-
Notifications
You must be signed in to change notification settings - Fork 12
/
pyproject.toml
267 lines (221 loc) · 7.15 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
[tool.poetry]
name = "notification-admin"
version = "0.1.0"
description = "Notifications admin application."
authors = ["Canadian Digital Service"]
license = "MIT license"
readme = "README.md"
packages = []
[build-system]
requires = ["poetry-core>=1.7.1"]
build-backend = "poetry.core.masonry.api"
[tool.poetry.dependencies]
python = "~3.12.7"
timeago = "1.0.16"
Flask = "2.3.3"
Flask-WTF = "1.2.1"
Flask-Login = "0.6.3"
Flask-Caching = "1.11.1"
environs = "9.5.0"
apig-wsgi = "2.18.0"
blinker = "1.8.2"
pyexcel = "0.7.0"
pyexcel-io = "0.6.6"
pyexcel-xls = "0.7.0"
pyexcel-xlsx = "0.6.0"
pyexcel-ods3 = "0.6.1"
pytz = "2021.3"
gunicorn = "22.0.0"
gevent = "23.9.1"
notifications-python-client = "6.4.1"
Babel = "2.16.0"
boto3 = "1.34.153"
Flask-Babel = "2.0.0"
python-dotenv = "1.0.1"
pwnedpasswords = "2.0.0"
PyYAML = "6.0.1"
translate-toolkit = "3.13.2"
ua-parser = "0.18.0"
user-agents = "2.2.0"
WTForms = "3.1.2"
email-validator = "1.3.1"
Werkzeug = "3.0.4"
greenlet = "3.1.1"
mixpanel = "4.10.1"
unidecode = "^1.3.8"
# PaaS
awscli-cwlogs = "^1.4.6"
notifications-utils = { git = "https://github.com/cds-snc/notifier-utils.git", tag = "53.0.1"}
# Pinned dependencies
certifi = "^2024.0.0" # Pinned for security reasons: https://github.com/cds-snc/notification-admin/security/dependabot/169
redis = "3.5.3" # pinned for now
xlrd = "1.2.0" # this is pinned so that we can continue to support .xslm files; see https://github.com/pyexcel/pyexcel-xls/issues/53
# Putting upgrade on hold due to v1.0.0 using sha512 instead of sha1 by default
itsdangerous = "2.2.0" # pyup: <1.0.0
newrelic = "10.3.0"
aws-xray-sdk = "^2.14.0"
validators = "^0.28.3"
[tool.poetry.group.test.dependencies]
pytest = "7.4.4"
pytest-env = "0.8.2"
pytest-cov = "2.12.1"
pytest-mock = "3.14.0"
pytest-xdist = "2.5.0"
coveralls = "1.11.1"
beautifulsoup4 = "4.12.3"
freezegun = "1.5.1"
requests-mock = "1.12.1"
# used for creating manifest file locally
jinja2-cli = { version = "^0.8.2", extras = ["yaml"] }
mypy = "1.11.2"
monkeytype = "23.3.0"
poethepoet = "^0.24.4"
pre-commit = "^3.7.1"
ruff = "^0.8.2"
# stubs libraries to keep mypy happy
types-python-dateutil = "2.9.0.20241003"
types-pytz = "2021.3.8"
types-requests = "2.32.0.20240914"
types-beautifulsoup4 = "^4.12.0.6"
[tool.poe.tasks.trace-app]
help = "Runs the app with monkeytype type collection enabled."
shell = """
monkeytype run -m flask run -p 6012 --host=0.0.0.0
"""
[tool.poe.tasks.trace-tests]
help = "Runs a test suite or single test through MonkeyType, generating a record of type annotation traces monkeytype.sqlite3"
shell = """
if [ -z "${method}" ]; then
monkeytype run -m pytest '/tests/app/${test-path}::${method}'
else
monkeytype run -m pytest '/tests/app/${test-path}'
fi
"""
# Define arguments for trace-tests
[tool.poe.tasks.trace-tests.args.test-path]
help = "Path to the test file to run. /tests/app/ can be omitted. e.g. poe trace-tests -p main/test_contact.py"
options = ["-p", "--path"]
type = "string"
required = true
[tool.poe.tasks.trace-tests.args.method]
help = "Name of the test method to execute and trace"
options = ["-m", "--method"]
type = "string"
default = ""
required = false
[tool.poe.tasks.list-modules]
help = "Lists all files and modules that have trace data associated with them in monkeytype.sqlite3"
cmd = "monkeytype list-modules"
# Composite task that uses list-modules to obtain a list of files and modules
[tool.poe.tasks.apply-annotations]
help = "Applies ALL known type annotations stored in monkeytype.sqlite3"
shell = """
for trace in ${TRACES}
do
monkeytype apply $trace
done
"""
deps = ["list-modules"]
uses = { TRACES = "list-modules"}
[tool.poe.tasks.generate-version-file]
help = "Generate the app version file"
shell = """
GIT_COMMIT="$(git rev-parse HEAD 2> /dev/null || echo "")"
DATE="$(date +%Y-%m-%dT%H:%M:%S)"
APP_VERSION_FILE="app/version.py"
printf "__commit_sha__ = '${GIT_COMMIT}'\n__time__ = '${DATE}'\n" > ${APP_VERSION_FILE}
"""
[tool.poe.tasks.test]
help = "Runs code linters, npm tests, and python tests for the project."
shell = """
./scripts/run_tests.sh
"""
[tool.poe.tasks.babel-test]
help = "Compiles app translations from fr.csv"
shell = """
pybabel extract -F babel.cfg -k _l -o /tmp/messages.po . && po2csv /tmp/messages.po /tmp/messages.csv
rm /tmp/messages.po
python scripts/test-translations.py /tmp/messages.csv
rm /tmp/messages.csv
"""
[tool.poe.tasks.babel]
help = "Compiles app translations from fr.csv"
shell = """
python scripts/generate_en_translations.py
csv2po app/translations/csv/en.csv app/translations/en/LC_MESSAGES/messages.po
csv2po app/translations/csv/fr.csv app/translations/fr/LC_MESSAGES/messages.po
pybabel compile -d app/translations
"""
[tool.poe.tasks.search-csv]
help = "Searches translations for the specified list of strings"
script = """
scripts.search_csv:search_translation_strings(search_terms=keywords)
"""
print_result = true
[tool.poe.tasks.search-csv.args.keywords]
help = "Comma separated list of keywords to search by."
options = ["-k", "--keywords"]
type = "string"
required = true
[tool.poe.tasks.lock-deps]
help = "Updates the Poetry lock file. Prevents automatic version bumps by default."
cmd = "poetry lock --no-update"
use_exec = true
[tool.poe.tasks.check-lock]
help = "Checks if the Poetry lock file is in sync with dependencies specified in pyproject.toml."
cmd = "poetry check --lock"
use_exec = true
[tool.poe.tasks.coverage]
help = "Creates a code coverage report. TODO: Is this still needed?"
shell = "coveralls"
[tool.poe.tasks.run-dev]
help = "Runs the app locally. Defaults: port = 6012, host=localhost"
shell = "flask run -p ${port} --host=${host}"
args = { port = { options = ["--port", "-p"], default = "6012"}, host = { options = ["--host", "-h"], default = "localhost"}}
[tool.poe.tasks.format]
help = "Formats the python code with isort, black, and flake8, and checks typing with mypy and formats the JS code with prettier."
shell = """
ruff check --select I --fix .
ruff check
ruff format .
mypy ./
npx prettier --write app/assets/javascripts app/assets/stylesheets tests_cypress/cypress/e2e
"""
[tool.poe.tasks.tailwind]
help = "Compiles Tailwind CSS"
shell = "npm run tailwind"
[tool.ruff]
target-version = "py310"
exclude = ["venv*", "__pycache__", "node_modules", "cache", "migrations", "build"]
extend-include = ['(app|migrations|tests)/.*\.pyi?$']
src = ["app", "migrations", "tests"]
# Ruff formatter will wrap lines at a length of 130 characters.
line-length = 130
indent-width = 4
[tool.ruff.lint]
select = [
# PyFlakes
"F",
# Pycodestyle
"E",
"W",
# isort
"I001",
"I002"
]
ignore = ["E203", "E501", "E402"]
# Provide line length leeway for docstrings
[tool.ruff.lint.pycodestyle]
max-doc-length = 170
# Enforce doc string format? (google, numpy or pep257)
# convention = "google"
[tool.ruff.format]
# Match black formatting
# Double quotes for strings.
quote-style = "double"
# Indent with spaces, rather than tabs.
indent-style = "space"
# Respect magic trailing commas.
skip-magic-trailing-comma = false
# Automatically detect the appropriate line ending.
line-ending = "auto"