-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathpyproject.toml
More file actions
190 lines (162 loc) · 4.36 KB
/
Copy pathpyproject.toml
File metadata and controls
190 lines (162 loc) · 4.36 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
[build-system]
requires = ["setuptools>=48", "setuptools_scm[toml]>=6.3.1"]
build-backend = "setuptools.build_meta"
[project]
name = "any-guardrail"
readme = "README.md"
license = {text = "Apache-2.0"}
requires-python = ">=3.11"
dynamic = ["version"]
dependencies = [
"any-llm-sdk>=1.7.0",
"pydantic",
]
[project.optional-dependencies]
all = [
"any-guardrail[flowjudge,huggingface,azure-content-safety,encoderfile,bedrock,llamafile,openai]"
]
bedrock = [
# >= 1.39.0 for native AWS_BEARER_TOKEN_BEDROCK (Bedrock API key) auth.
"boto3>=1.39.0"
]
flowjudge = [
"flow-judge[hf]>=0.1.2"
]
huggingface = [
"huggingface-hub>=0.33.4",
"transformers>=4.53.2",
"torch>=2.7.1",
"hf-xet>=1.1.5"
]
azure-content-safety = [
"azure-ai-contentsafety>=1.0.0",
"pathvalidate>=3.3.1",
]
encoderfile = [
"huggingface-hub>=0.33.4",
"hf-xet>=1.1.5",
"numpy>=1.26",
]
llamafile = [
"huggingface-hub>=0.33.4",
"hf-xet>=1.1.5",
]
# Already a core dependency of any-llm-sdk today; declared explicitly so the
# OpenaiModeration guardrail keeps working even if that transitive dep changes.
openai = [
"openai>=1.99.3",
]
[project.urls]
Documentation = "https://mozilla-ai.github.io/any-guardrail/"
Issues = "https://github.com/mozilla-ai/any-guardrail/issues"
Source = "https://github.com/mozilla-ai/any-guardrail"
[tool.setuptools.package-data]
"*" = ["py.typed"]
[tool.setuptools.packages.find]
exclude = ["tests", "tests.*"]
where = ["src"]
namespaces = false
[tool.setuptools_scm]
[tool.pylint.messages_control]
disable = [
"import-outside-toplevel",
]
[tool.ruff]
line-length = 120
[tool.ruff.lint]
ignore = [
"TD",
"FIX",
"D100", # We don't use module docstrings
"D104", # We don't use package docstrings
"D203", # <- disable to resolve conflict with D211
"D213", # <- disable to resolve conflict with D212
"FBT",
"COM",
"ANN",
"ARG",
"S101",
"E501",
"INP001",
"PERF",
"PLR",
"SIM",
"PTH",
"DTZ005",
"BLE001",
"TRY004",
"S113",
"PLW2901",
"C901",
"ERA001",
"SLF001",
"PLC0415", # We use lazy imports in several places
"PLR0912",
"PLR0913",
"N999",
"B024",
]
extend-select = ["ALL"]
[tool.ruff.lint.per-file-ignores]
# D: docstrings aren't required in tests.
# S105/S106 are scoped to the bedrock test only — its fake-cred fixtures hardcode
# "credentials" that ruff flags, but they're fixtures, not real secrets. Ruff unions
# per-file-ignores across matching patterns, so that file keeps D + S105 + S106.
"tests/**" = ["D"]
"tests/unit/test_unit_bedrock_guardrails.py" = ["S105", "S106"]
"docs/cookbook/**" = ["T201", "TRY300"]
"scripts/**" = ["T201"]
[tool.mypy]
strict = true
disallow_untyped_calls = true
disallow_untyped_defs = true
follow_untyped_imports = true
[[tool.mypy.overrides]]
module = "tests.*"
disallow_untyped_decorators = false # mypy gets confused by pytest decorators
[[tool.mypy.overrides]]
module = ["pytest", "mktestdocs", "pytest_lazy_fixtures"]
ignore_missing_imports = true # pytest related modules are not found
[[tool.mypy.overrides]]
module = ["generate_cookbooks"]
ignore_missing_imports = true # script imported via sys.path.insert in tests/unit/test_generate_cookbooks.py
[tool.pytest.ini_options]
timeout = 120
addopts = "--strict-markers"
markers = [
"e2e: tests that exercise real binaries / downloaded models / external APIs. Selected explicitly via -m e2e; not run by default in CI's unit-test job. Run locally with `pytest -m e2e tests/integration`.",
"heavy: e2e subset that needs >5 GB RAM/disk or a GPU to be realistic (currently: Granite Guardian, ShieldGemma, Glider). Run with `-m \"e2e and heavy\"` only on machines that can host the model weights.",
]
[dependency-groups]
dev = [
{ include-group = "docs" },
{ include-group = "lint" },
{ include-group = "tests" },
]
docs = [
"mkdocs",
"mkdocs-material",
"mkdocstrings-python",
"mkdocs-include-markdown-plugin>=7.1.5",
"mkdocs-jupyter>=0.25.1",
]
lint = [
"pre-commit==4.6.0",
"pre-commit-uv==4.2.1",
"mypy @ git+https://github.com/python/mypy.git",
]
tests = [
"pytest>=8,<10",
"pytest-asyncio>=0.26.0",
"mktestdocs>=0.2.4",
"pytest-xdist>=3.6.1",
"pytest-timeout",
"pytest-rerunfailures>=14.0",
"debugpy",
]
# For completeness, but 'uv sync --group dev' currently installs the others too.
all = [
{ include-group = "lint" },
{ include-group = "tests" },
{ include-group = "docs" },
]