MenuDocs / Pyro

A Python Discord Bot
Apache License 2.0
25 stars 6 forks source link

autohelp: use ast parsing and deprecate regex #56

Closed onerandomusername closed 2 years ago

onerandomusername commented 2 years ago

Using regex to detect code problems leads a lot of room for interpretation, as it assumes the user formats their code in a specific way. Parsing the AST would probably make the most sense in order to be able to better help the user.

Additionally, it might be worth implementing black to format the code when returning a code snippet for the user. This can help with differing function definitions and making it easier to read and what to replace.

For a parser, it would probably make sense to use something like https://github.com/Instagram/LibCST, and use that in Aegir, then move Aegir into pyro as a dependency.