-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdev
More file actions
executable file
·200 lines (174 loc) · 3.53 KB
/
dev
File metadata and controls
executable file
·200 lines (174 loc) · 3.53 KB
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
#!/usr/bin/env bash
usage() {
cat<<EOT
Various development utilities.
Upon running the 'bootstrap' subcommand, this script will be moved to the venv's bin
directory so will be available as an in-path executable when the venv is activated.
Usage: dev [SUBCOMMAND] [OPTIONS]
Subcommands:
bootstrap Initializes python virtual environment and installs project dependencies
docs Boots up documentation server on port 8080
docs-build Builds docs and emits to docs/sift_py
fmt Runs 'ruff fmt' to format the lib directory
lint-fix Runs 'ruff check --fix'
lint Runs 'ruff check' to lint the lib directory
mypy Runs 'mypy lib' for static analysis
pyright Runs 'pyright lib' for type checking
check Runs all python linting checks
gen-stubs Generates pyi stubs for sift_client synchronous wrappers
gen-extras Generates optional-dependencies in pyproject.toml
mypy-stubs Runs stubtest (mypy) on the generated pyi stubs
pip-install Install project dependencies
test Execute tests
test-integration Execute integration tests
test-all Execute all non-integration tests
update-dev Copies changes to the dev script over to the venv bin
Options:
-h, --help Print usage text
EOT
}
pip_install() {
source venv/bin/activate
pip install '.[all-dev]'
pip install -e .
}
update_dev() {
cp ./scripts/dev venv/bin
chmod u+x venv/bin/dev
}
bootstrap() {
python3 -m venv venv
pip_install
update_dev
}
run_mypy() {
source venv/bin/activate
mypy lib
}
run_pyright() {
source venv/bin/activate
pyright lib
}
run_checks() {
lint_fix
fmt
run_mypy
run_pyright
}
fmt() {
source venv/bin/activate
ruff format
}
lint() {
source venv/bin/activate
ruff check
}
lint_fix() {
source venv/bin/activate
ruff check --fix
}
doc() {
source venv/bin/activate
mkdocs serve
}
doc_build() {
source venv/bin/activate
mkdocs build
}
run_tests() {
pytest -m "not integration"
}
run_tests_integration() {
pytest -m "integration"
}
run_tests_all() {
pytest
}
gen_stubs() {
source venv/bin/activate
cd lib
python3 sift_client/_internal/gen_pyi.py sift_client/resources/sync_stubs
cd ..
ruff format ./lib/sift_client/resources/sync_stubs/*.pyi -q
ruff check ./lib/sift_client/resources/sync_stubs/*.pyi --fix --unsafe-fixes -q
}
mypy_stubs() {
source venv/bin/activate
cd lib
stubtest sift_client.resources.sync_stubs
}
gen_extras() {
source venv/bin/activate
cd scripts
python3 generate_extras.py
cd ..
}
shift "$((OPTIND - 1))"
case "$1" in
-h | --help)
usage
exit 0
;;
bootstrap)
bootstrap
;;
docs-build)
doc_build
;;
docs)
doc
;;
pip-install)
pip_install
;;
fmt)
fmt
;;
lint-fix)
lint_fix
;;
lint)
lint
;;
mypy)
run_mypy
;;
pyright)
run_pyright
;;
check)
run_checks
;;
test)
run_tests
;;
test-integration)
run_tests_integration
;;
test-all)
run_tests_all
;;
gen-stubs)
gen_stubs
;;
gen-extras)
gen_extras
;;
mypy-stubs)
mypy_stubs
;;
update-dev)
update_dev
;;
"")
echo "No subcommand provided"
usage
exit 1
;;
*)
echo "Invalid subcommand: $1"
usage
exit 1
;;
esac
exit 0