-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Labels
Description
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 Django 4.1 data #181 (comment) and
View.view_is_asyncshould not be abool#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
| class CodeImporter(Protocol): | |
| def generate_code_data(self) -> Iterator[CodeElement]: | |
| ... |