django_parser.py
Module for parsing Django models and extracting field information.
- class ts_backend_check.parsers.django_parser.DjangoModelVisitor(models_to_ignore: list[str] | None)[source]
AST visitor to extract fields from Django models.
- Parameters:
- models_to_ignorelist[str]
Model classes to ignore, obtained from the config file.
- visit_ClassDef(node: ClassDef) None[source]
Check class definitions, specifically those that inherit from other classes and not listed in ignore classes.
- Parameters:
- nodeast.ClassDef
A class definition from Python AST (Abstract Syntax Tree). It contains information about the class, such as its name, base classes, body, decorators, etc.
- ts_backend_check.parsers.django_parser.extract_model_fields(models_file: str, models_to_ignore: list[str] | None) tuple[dict[str, list[Any]], dict[str, list[Any]], dict[str, list[Any]]][source]
Extract fields from Django models file.
- Parameters:
- models_filestr
A models.py file that defines Django models.
- models_to_ignorelist[str]
Model classes to ignore, obtained from the config file.
- Returns:
- tuple(dict[str, list[Any]], dict[str, list[Any]], dict[str, list[Any]])
The fields from the models file extracted into dictionaries for future processing.