-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: pyformat param types #545
Comments
It would be nice to support this kind of parameters, but I wouldn't really like to add a specific option for this Python formatting syntax. Rather I would consider providing a more flexible way of customizing the possible parameter types. But I'm not fully sure what would be the best API for this. Currently the paramTypes setting categorizes parameters to 4 types:
This Python syntax looks most similar to the quoted type, with parenthesis sort-of used for quoting, plus there's this extra Assuming these pyformat parameters can be parsed with regular expressions, the syntax could be something like: paramTypes: {
custom: [
{ regex: String.raw`%\((\w+)\)[a-z]` }
]
} Additional consideration is that we also need a way to determine the actual name inside the parenthesis. This is used by the parameter-substitution feature. A simplest approach would be to just use a regex capture group as I've done above. |
That would definitely be good for us, though it sounds like a bit of a bigger rewrite of the param code, unless it's already using regex behind the scenes. |
Well, it is indeed using regexes behind the scenes. It's more about how the final regexes for matching parameter tokens get built. |
Related discussion: #551 |
This is now implemented in 12.2.0 |
Describe the Feature
Would you consider adding support for pyformat param types? I've run a few of our snowsql scripts throught the formatter and for the most part it's absolutely fantastic, but it trips up on our param types which use, e.g.
%(end_date)s
.I thought I should ask before even considering diving in and attempting a PR, in case it was something that had been previously considered and rejected.
Why do you want this feature?
This would increase the number of situations in which the tool could be used, and is expanding on an existing feature rather than adding something entirely new.
The text was updated successfully, but these errors were encountered: