Skip to content

Commit 77001c9

Browse files
authored
Generate single-line model_config in surface types (#3820)
1 parent 82adc27 commit 77001c9

3 files changed

Lines changed: 305 additions & 904 deletions

File tree

‎scripts/gen_surface_types.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def patch(match: re.Match[str]) -> str:
250250
return match.group(0).replace('extra="ignore"', 'extra="allow"')
251251

252252
source = re.sub(
253-
r'^class (\w+)\(WireModel\):\n(?: {4}.*\n|\n)*? {4}model_config = ConfigDict\(\n {8}extra="ignore",\n {4}\)\n',
253+
r'^class (\w+)\(WireModel\):\n(?: {4}.*\n|\n)*? {4}model_config = ConfigDict\(extra="ignore"\)\n',
254254
patch,
255255
source,
256256
flags=re.MULTILINE,
@@ -310,6 +310,9 @@ def build(entry: dict[str, str]) -> str:
310310
# them to full URLs so they resolve from the rendered API docs and pass the
311311
# strict mkdocs link validation.
312312
source = source.replace("](/", "](https://modelcontextprotocol.io/")
313+
source = re.sub(
314+
r'model_config = ConfigDict\(\n\s+(extra="ignore"),\n\s+\)', r"model_config = ConfigDict(\1)", source
315+
)
313316
source = allow_open_class_extras(source, OPEN_CLASSES[version])
314317
if epilogue := EPILOGUES.get(version, ""):
315318
# Resolve aliases before rebuilding models with forward references.

0 commit comments

Comments
 (0)