From fd3c42c3a7b24be5b1f5001482a75a212f724486 Mon Sep 17 00:00:00 2001 From: Mark Probst Date: Mon, 7 Sep 2026 07:59:37 -0700 Subject: [PATCH] fix(python): validate ISO date-times --- .../quicktype-core/src/language/Python/JSONPythonRenderer.ts | 4 ++-- test/languages.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/quicktype-core/src/language/Python/JSONPythonRenderer.ts b/packages/quicktype-core/src/language/Python/JSONPythonRenderer.ts index ce8a3e256f..3cee1b34ef 100644 --- a/packages/quicktype-core/src/language/Python/JSONPythonRenderer.ts +++ b/packages/quicktype-core/src/language/Python/JSONPythonRenderer.ts @@ -515,7 +515,7 @@ export class JSONPythonRenderer extends PythonRenderer { this.emitLine( "assert isinstance(x, str) and ", this.withModuleImport("re"), - '.match(r"^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})?$", x)', + '.match(r"^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:[Zz]|[+-]\\d{2}:\\d{2})?$", x)', ); this.emitLine("return dateutil.parser.parse(x).timetz()"); }, @@ -536,7 +536,7 @@ export class JSONPythonRenderer extends PythonRenderer { ], () => { this._haveDateutil = true; - this.emitLine("return dateutil.parser.parse(x)"); + this.emitLine("return dateutil.parser.isoparse(x)"); }, ); } diff --git a/test/languages.ts b/test/languages.ts index c827e5ce08..c908fd1d4d 100644 --- a/test/languages.ts +++ b/test/languages.ts @@ -297,6 +297,8 @@ export const PythonLanguage: Language = { "union", "no-defaults", "date-time", + "date", + "time", "integer-string", "bool-string", "uuid",