I only have experience with JavaScript plugins for IntelliJ, but it should work the same for Python.
You can write a plugin that provides an inspection. There's a learning curve of course, but once you get the environment setup it's pretty smooth.
First, you will need to check out the plugin development page from JetBrains. Here are the steps I would take:
- Download the IntelliJ IDEA Community Edition source. It's not required, but searching through the source is useful.
- Try to follow the basic plugin tutorial. It's a Java plugin, but it's a good start. For Python you may need to add a dependency on a plugin jar.
- Specific for your case, read up on PsiElements. Using PsiElements is how you navigate and modify the source code.
- For practical examples, browse the plugin repository and look for open source plugins. I found them the most helpful when developing my own plugin.
When you finish that, you can start writing your plugin. For an inspection, there are a few classes you will be concerned about:
LocalInspectionTool
is the actual inspection that will search a file and flag problems. You extend this classInspectionToolProvider
is the interface you implement to determine if a file will run a particular inspection.ProblemDescriptor
is the class that will represent your error message. You can optionally provide a fix to remove the elements in question.
You will get a PsiFile that represents your source file. Using this, you can search for the function in question and flag it as an error.
One last fantastic resource is the plugin development forum. Usually one of the developers will respond if someone else doesn't answer your question, so don't hesitate to post there.