Server IP : 66.29.132.122 / Your IP : 3.145.46.232 Web Server : LiteSpeed System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : admazpex ( 531) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/opt/cloudlinux/venv/lib64/python3.11/site-packages/pylint_django/transforms/ |
Upload File : |
""" These transforms replace the Django types with adapted versions to provide additional typing and method inference to pylint. All of these transforms are considered "global" to pylint-django, in that all checks and improvements requre them to be loaded. Additional transforms specific to checkers are loaded by the checker rather than here. For example, the ForeignKeyStringsChecker loads the foreignkey.py transforms itself as it may be disabled independently of the rest of pylint-django """ import os import re import astroid from pylint_django.transforms import fields fields.add_transforms(astroid.MANAGER) def _add_transform(package_name): def fake_module_builder(): """ Build a fake module to use within transformations. @package_name is a parameter from the outer scope b/c according to the docs this can't receive any parameters. http://pylint.pycqa.org/projects/astroid/en/latest/extending.html?highlight=MANAGER#module-extender-transforms """ transforms_dir = os.path.join(os.path.dirname(__file__), "transforms") transformed_name = re.sub(r"\.", "_", package_name) fake_module_path = os.path.join(transforms_dir, f"{transformed_name}.py") with open(fake_module_path, encoding="utf-8") as modulefile: fake_module = modulefile.read() return astroid.builder.AstroidBuilder(astroid.MANAGER).string_build(fake_module) astroid.register_module_extender(astroid.MANAGER, package_name, fake_module_builder) _add_transform("django.utils.translation") # register transform for FileField/ImageField, see #60 _add_transform("django.db.models.fields.files")