Skip to content

Commit 2eeb64d

Browse files
authored
fix(python): validate ISO date-times (#3518)
1 parent 97aadbe commit 2eeb64d

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
@@ -515,7 +515,7 @@ export class JSONPythonRenderer extends PythonRenderer {
515515
this.emitLine(
516516
"assert isinstance(x, str) and ",
517517
this.withModuleImport("re"),
518-
'.match(r"^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})?$", x)',
518+
'.match(r"^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:[Zz]|[+-]\\d{2}:\\d{2})?$", x)',
519519
);
520520
this.emitLine("return dateutil.parser.parse(x).timetz()");
521521
},
@@ -536,7 +536,7 @@ export class JSONPythonRenderer extends PythonRenderer {
536536
],
537537
() => {
538538
this._haveDateutil = true;
539-
this.emitLine("return dateutil.parser.parse(x)");
539+
this.emitLine("return dateutil.parser.isoparse(x)");
540540
},
541541
);
542542
}

‎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)