-
Notifications
You must be signed in to change notification settings - Fork 709
Expand file tree
/
Copy pathpyproject.toml
More file actions
345 lines (328 loc) · 9.96 KB
/
pyproject.toml
File metadata and controls
345 lines (328 loc) · 9.96 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
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
[project]
name = "pyrit"
version = "0.12.1.dev0"
description = "The Python Risk Identification Tool for LLMs (PyRIT) is a library used to assess the robustness of LLMs"
authors = [
{ name = "Microsoft AI Red Team", email = "airedteam@microsoft.com" },
]
readme = "README.md"
license = "MIT"
keywords = [
"llm",
"ai-safety",
"ai-security",
"ai-red-team",
"ai-red-teaming",
"ai-robustness",
"ai-robustness-testing",
"ai-risk-assessment",
]
classifiers = [
"Development Status :: 3 - Alpha",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
requires-python = ">=3.10, <3.14"
dependencies = [
"aiofiles>=24,<25",
"appdirs>=1.4.0",
"art>=6.5.0",
"av>=14.0.0",
"azure-core>=1.38.0",
"azure-identity>=1.19.0",
"azure-ai-contentsafety>=1.0.0",
"azure-storage-blob>=12.19.0",
"base2048>=0.1.3",
"colorama>=0.4.6",
"confusables>=1.2.0",
"confusable-homoglyphs>=3.3.1",
"ecoji>=0.1.1",
"datasets>=3.6.0",
"fastapi>=0.115.0",
"httpx[http2]>=0.27.2",
"jinja2>=3.1.6",
"numpy>=1.26.0",
"openai>=2.2.0",
"openpyxl>=3.1.5",
"pillow>=12.1.1",
"pydantic>=2.11.5",
"pyodbc>=5.1.0",
"pypdf>=6.8.0",
"python-docx>=1.1.0",
"python-dotenv>=1.0.1",
"reportlab>=4.4.4",
"segno>=1.6.6",
"scipy>=1.15.3",
"SQLAlchemy>=2.0.41",
"termcolor>=2.4.0",
"tenacity>=9.1.2",
"tinytag>=2.1.1",
"tqdm>=4.67.1",
"transformers>=4.52.4",
"treelib>=1.7.1",
"uvicorn[standard]>=0.32.0",
"websockets>=14.0",
]
[project.optional-dependencies]
# always make sure the individual ones are in sync with the all group
dev = [
"feedgen>=1.0.0",
"griffe>=2.0.0",
"ipykernel>=6.29.5",
"jupyter>=1.1.1",
"jupyter-book>=2.0.0",
"jupytext>=1.17.1",
"matplotlib>=3.10.0",
"mypy>=1.16.0",
"mock-alchemy>=0.2.6",
"pandas>=2.2.0",
"pre-commit>=4.2.0",
"pytest>=8.3.5",
"pytest-asyncio>=1.0.0",
"pytest-cov>=6.1.1",
"pytest-timeout>=2.4.0",
"pytest-xdist>=3.6.1",
"respx>=0.22.0",
"ruff>=0.14.4",
"types-aiofiles>=24.1.0",
"types-cachetools>=5.5.0",
"types-decorator>=5.1.0",
"types-paramiko>=3.5.0",
"types-pycurl>=7.45.0",
"types-pytz>=2024.2.0",
"types-PyYAML>=6.0.12.20250516",
"types-requests>=2.31.0.20250515",
"types-simplejson>=3.19.0",
"types-six>=1.16.0",
"types-tabulate>=0.9.0",
"types-ujson>=5.10.0",
]
huggingface = [
"torch>=2.7.0",
]
gcg = [
"accelerate>=1.7.0",
"azure-ai-ml>=1.27.1",
"azureml-mlflow>=1.60.0",
"mlflow>=2.22.0",
"ml-collections>=1.1.0",
"sentencepiece>=0.2.0",
"torch>=2.7.0",
]
playwright = [
"flask>=3.1.3",
"ollama>=0.5.1",
"playwright>=1.49.0",
]
gradio = [
"gradio>=6.7.0",
"rpyc>=6.0.1",
"pywebview>=5.4"
]
fairness_bias = [
"spacy>=3.8.7",
]
opencv = [
"opencv-python>=4.11.0.86",
]
speech = [
"azure-cognitiveservices-speech>=1.46.0",
]
# all includes all functional dependencies excluding the ones from the "dev" extra
all = [
"accelerate>=1.7.0",
"av>=14.0.0",
"azure-ai-ml>=1.27.1",
"azure-cognitiveservices-speech>=1.44.0",
"azureml-mlflow>=1.60.0",
"flask>=3.1.3",
"ipykernel>=6.29.5",
"jupyter>=1.1.1",
"gradio>=6.7.0",
"mlflow>=2.22.0",
"ml-collections>=1.1.0",
"ollama>=0.5.1",
"opencv-python>=4.11.0.86",
"playwright>=1.49.0",
"pywebview>=5.4",
"spacy>=3.8.7",
"rpyc>=6.0.1",
"torch>=2.7.0",
"types-PyYAML>=6.0.12.20250516",
"types-requests>=2.31.0.20250515",
]
[project.scripts]
pyrit_backend = "pyrit.cli.pyrit_backend:main"
pyrit_scan = "pyrit.cli.pyrit_scan:main"
pyrit_shell = "pyrit.cli.pyrit_shell:main"
[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
]
pythonpath = ["."]
asyncio_default_fixture_loop_scope = "function"
asyncio_mode = "auto"
[tool.mypy]
plugins = []
ignore_missing_imports = true
strict = false
follow_imports = "silent"
strict_optional = false
disable_error_code = ["empty-body"]
exclude = ["doc/code/", "pyrit/auxiliary_attacks/"]
[tool.uv]
constraint-dependencies = [
"cryptography>=46.0.5",
"orjson>=3.11.6",
"tornado>=6.5.5",
"werkzeug>=3.1.6",
]
[build-system]
requires = ["setuptools>=64.0.0", "wheel>=0.46.2"]
build-backend = "setuptools.build_meta"
[tool.setuptools.packages.find]
include = ["pyrit", "pyrit.*"]
[tool.setuptools.package-data]
pyrit = [
"backend/frontend/**/*",
"py.typed"
]
[tool.jupytext]
formats = "ipynb,py:percent"
[tool.ruff]
line-length = 120
target-version = "py310"
[tool.ruff.lint]
preview = true
fixable = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"I",
"N",
"Q",
"S",
"T",
"W",
"ANN",
"ARG",
"BLE",
"COM",
"DJ",
"DTZ",
"EM",
"ERA",
"EXE",
"FBT",
"ICN",
"INP",
"ISC",
"NPY",
"PD",
"PERF",
"PGH",
"PIE",
"PL",
"PT",
"PTH",
"PYI",
"RET",
"RSE",
"RUF",
"SIM",
"SLF",
"TCH",
"TID",
"TRY",
"UP",
"YTT",
]
select = [
"A", # https://docs.astral.sh/ruff/rules/#flake8-builtins-a
"B", # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
"C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
"CPY001", # missing-copyright-notice
"D", # https://docs.astral.sh/ruff/rules/#pydocstyle-d
"DOC", # https://docs.astral.sh/ruff/rules/#pydoclint-doc
"DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz
"E", # https://docs.astral.sh/ruff/rules/#pycodestyle-e
"ERA", # https://docs.astral.sh/ruff/rules/#eradicate-era
"EXE", # https://docs.astral.sh/ruff/rules/#flake8-executable-exe
"F401", # unused-import
"FA", # https://docs.astral.sh/ruff/rules/#flake8-future-annotations-fa
"FLY", # https://docs.astral.sh/ruff/rules/#flynt-fly
"I", # isort
"ICN", # https://docs.astral.sh/ruff/rules/#flake8-import-conventions-icn
"ISC", # https://docs.astral.sh/ruff/rules/#flake8-implicit-str-concat-isc
"LOG", # https://docs.astral.sh/ruff/rules/#flake8-logging-log
"N", # https://docs.astral.sh/ruff/rules/#pep8-naming-n
"PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf
"PGH", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh
"PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie
"PLE", # https://docs.astral.sh/ruff/rules/#pylint-ple
"Q", # https://docs.astral.sh/ruff/rules/#flake8-quotes-q
"RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret
"RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
"SLOT", # https://docs.astral.sh/ruff/rules/#flake8-slots-slot
"T10", # https://docs.astral.sh/ruff/rules/#flake8-debugger-t10
"TCH", # https://docs.astral.sh/ruff/rules/#flake8-type-checking-tch
"TID", # https://docs.astral.sh/ruff/rules/#flake8-tidy-imports-tid
"UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up
"W", # https://docs.astral.sh/ruff/rules/#pycodestyle-w
"YTT", # https://docs.astral.sh/ruff/rules/#flake8-2020-ytt
]
ignore = [
"B903", # class-as-data-structure (test helper classes use @apply_defaults pattern)
"D100", # Missing docstring in public module
"D200", # One-line docstring should fit on one line
"D205", # 1 blank line required between summary line and description
"D212", # Multi-line docstring summary should start at the first line
"D301", # Use r""" if any backslashes in a docstring
"DOC502", # Raised exception is not explicitly raised
"PERF203", # try-except-in-loop (intentional per-item error handling)
"SIM117", # multiple-with-statements (combining often exceeds line length)
"UP007", # non-pep604-annotation-union (keep Union[X, Y] syntax)
"UP045", # non-pep604-annotation-optional (keep Optional[X] syntax)
]
extend-select = [
"D204", # 1 blank line required after class docstring
"D213", # Multi-line docstring summary should start at the second line
"D401", # First line of docstring should be in imperative mood
"D404", # First word of the docstring should not be "This"
]
[tool.ruff.lint.isort]
known-first-party = ["pyrit"]
[tool.ruff.lint.flake8-copyright]
min-file-size = 1
notice-rgx = "Copyright \\(c\\) Microsoft Corporation\\.\\s*\\n.*Licensed under the MIT license"
[tool.ruff.lint.per-file-ignores]
# Ignore D and DOC rules everywhere except for the pyrit/ directory
"!pyrit/**.py" = ["D", "DOC"]
# Ignore copyright, import-location (E402), line length (E501), type-checking, and blanket type-ignore (PGH003) rules in doc/ directory
# E402: notebooks have imports in code cells, not at top of file
# E501: markdown comments in notebooks can exceed line length
# PGH003: blanket type: ignore in notebooks (not mypy-checked)
# A: notebook code commonly uses builtins like id, dir, display
# ERA001: jupytext markdown cells look like commented-out code
# LOG: notebooks use root logger for convenience
# PLE1142: top-level await is valid in Jupyter notebooks
"doc/**" = ["CPY001", "TCH", "E402", "E501", "PGH003", "A", "ERA001", "LOG", "PLE1142"]
"pyrit/{auxiliary_attacks,ui}/**/*.py" = ["B905", "D101", "D102", "D103", "D104", "D105", "D106", "D107", "D401", "D404", "D417", "D418", "DOC102", "DOC201", "DOC202", "DOC402", "DOC501", "N", "PERF", "SIM101", "SIM108"]
# Backend API routes raise HTTPException handled by FastAPI, not true exceptions
"pyrit/backend/**/*.py" = ["DOC501", "B008"]
# Vendored GCG attack code — external project with its own style
"pyrit/auxiliary_attacks/**/*.py" = ["A", "B905", "D", "DOC", "SIM101", "SIM108"]
# UI code has incomplete docstrings (external contributor code)
"pyrit/ui/**/*.py" = ["D", "DOC201", "DOC501"]
"pyrit/__init__.py" = ["D104"]
# Allow broad pytest.raises(Exception) in tests
"tests/**/*.py" = ["B017"]
[tool.ruff.lint.pydocstyle]
convention = "google"