Skip to content

Commit 4ba516e

Browse files
committed
fix(python): validate ISO date-times (#3518)
1 parent f0be684 commit 4ba516e

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎packages/quicktype-core/src/language/Python/JSONPythonRenderer.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ export class JSONPythonRenderer extends PythonRenderer {
521521
this.emitLine(
522522
"assert isinstance(x, str) and ",
523523
this.withModuleImport("re"),
524-
'.match(r"^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})?$", x)',
524+
'.match(r"^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:[Zz]|[+-]\\d{2}:\\d{2})?$", x)',
525525
);
526526
this.emitLine("return dateutil.parser.parse(x).timetz()");
527527
},
@@ -542,7 +542,7 @@ export class JSONPythonRenderer extends PythonRenderer {
542542
],
543543
() => {
544544
this._haveDateutil = true;
545-
this.emitLine("return dateutil.parser.parse(x)");
545+
this.emitLine("return dateutil.parser.isoparse(x)");
546546
},
547547
);
548548
}

‎test/languages.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ export const PythonLanguage: Language = {
297297
"union",
298298
"no-defaults",
299299
"date-time",
300+
"date",
301+
"time",
300302
"integer-string",
301303
"bool-string",
302304
"uuid",

0 commit comments

Comments
 (0)