jsontypedef / json-typedef-codegen

A CLI tool that generates code from JSON Typedef schemas
https://jsontypedef.com/docs/tools/jtd-codegen
MIT License
154 stars 31 forks source link

Make regex string a raw string in python #54

Open Emily-Steel opened 2 years ago

Emily-Steel commented 2 years ago

TL;DR: This prevents SyntaxError: invalid escape sequence \d

Longer explanation: Python 3 considers strings to be Unicode rather than ASCII. The \ in \d is interpreted as the beginning of a Unicode character escape sequence rather than left as is as part of the Regex. \d is not a valid Unicode sequence so it was left as is so far with a DeprecationWarning thrown. In Python 3.9+ (maybe earlier, haven't tested) it's now a SyntaxError. The easy solution which I have applied here is to use a raw string literal instead of a typical string literal as raw string literals treat backslashes within the string as "just backslashes" and not escaping characters.

cimpeanvasile commented 1 year ago

Is this project still maintained?

Emily-Steel commented 1 year ago

Unfortunately it doesn't look like it

On Fri, 24 Mar 2023, 15:29 Vasile Cimpean, @.***> wrote:

Is this project still maintained?

— Reply to this email directly, view it on GitHub https://github.com/jsontypedef/json-typedef-codegen/pull/54#issuecomment-1482996541, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2TBG4W4H2UDUEFSDOYML3W5W4UPANCNFSM53N43AQQ . You are receiving this because you authored the thread.Message ID: @.***>

zbowling commented 4 months ago

@Christopher-Steel Had to make the same patch locally. It looks like Upstream has been abandoned. Bummer. JSONSchema isn't a good alternative.