Replace `inspect` module for parsing
meshy opened this issue · 3 comments
meshy commented
We currently use the inspect
module to extract Django code and structure.
This has several drawbacks:
- The version of Django that we're parsing needs to be installed in the project (at least locally).
- The inspect module executes code (on import) when parsing modules. This means:
- We can only inspect code we trust.
- Python code inspected can mutate itself on import (see #181 (comment) and #184 )
We recently refactored the populate_cbv
script to abstract the importer into a protocol that will (hopefully) make it easier for new importers to be written. LibCSV may be an appropriate alternative to inspect
.
ccbv/cbv/importer/importers.py
Lines 29 to 31 in a89118b
meshy commented
Python's ast
module has potential, if we can be sure it preserves formatting.
meshy commented
https://github.com/PyCQA/astroid is interesting.