marshmallow icon indicating copy to clipboard operation
marshmallow copied to clipboard

Use fromisoformat from standard library (or backport)

Open lafrech opened this issue 1 year ago • 2 comments

This PR shows what it would look like if we used Python 3.11's improved fromisoformat (backported for older releases).

Less code on our side and it should be more efficient (C implementation).

(We could simplify even more by passing those functions directly to the class and remove everything from utils.py.)

There are 2 failing tests.

  • "2018-01-01" is accepted as a datetime while it is currently rejected in marshmallow. I guess this would be a breaking change. We may keep the old behaviour with a temporary trick until marshmallow 4 (keep the regex or even just check input string length).

  • Time deserialization respects timezones. It is not clear to me what a time with timezone but without date means. It could be ambiguous for timezones with DST. In any case, this can be considered either bugfix or breaking change, and it could be "fixed" to keep old behaviour.


Consider this as an RFC.

Meanwhile, anyone willing to do it in their app may set those functions as class attributes and use the backport if needed.

lafrech avatar Dec 08 '22 16:12 lafrech