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.
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.