Make pyastgrep usable as a pre-commit hook - #27
Conversation
|
Thanks so much for this, it's an interesting approach. I've documented the patterns I use for this kind of thing here: https://lukeplant.me.uk/blog/posts/pyastgrep-and-custom-linting/ There are some significant issues with pyastgrep for linting, especially that non-matches can start failing silently very easily when you change Python version, due to changes in Python's AST, or just because you didn't check the XPath expression properly - the XPath is tricky enough to need its own tests. That's why I prefer the method in the post that uses explicit "can I find the needle" checks, with example of what exactly the needle looks like. Regarding the example in the PR: This actually checks for a definition I'd be interested in your feedback! |
Thanks!
yes, not carefully enough prepared example
I think this
is a quite good explanation, so closing it, thank you! |
Hi,
I played a bit for make pyastgrep usable as pre-commit hook, not really sure how practical is to use it this ways, but I guess it's cheap to have it and give people chance to try, at least for simple cases it should be good.