J> d Z ddlZddlmZmZ ddlmZ ddlmZ ddl m Z ddlmZ ddl mZ d Z G d dej Z G d d ej Zd Zd Zd ZdS )z Various suggestions around migrations. Disabled by default! Enable with pylint --load-plugins=pylint_django.checkers.migrations N)checkers interfaces)utils)suppress_message)compat)BASE_ID)is_migrations_modulec t | j t j sdS | j j dk sdS | j D ]J}|j dk r=t |j t j r|j j D ]}|j dk r dS KdS )NFAddFieldfielddefaultT) isinstancefuncastroid AttributeattrnamekeywordsargvalueCall)callkeyword field_keywords s/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pylint_django/checkers/migrations.py_is_addfield_with_defaultr s di!233 u9++u= ;'!!j&M&M! ")!7 $ 11444 2 5 c | e Zd ZdZej fZdZde ddiZ g Z i Zd Zd Z ej d d Zd S ) NewDbFieldWithDefaultCheckera Looks for migrations which add new model fields and these fields have a default value. According to Django docs this may have performance penalties especially on large tables: https://docs.djangoproject.com/en/2.0/topics/migrations/#postgresql The preferred way is to add a new DB column with null=True because it will be created instantly and then possibly populate the table with the desired default values. new-db-field-with-defaultW98)z%s AddField with default valuer zKUsed when Pylint detects migrations adding new fields with a default value.c \ t | r| j | d S d S N)r _migration_modulesappend)selfnodes r visit_modulez)NewDbFieldWithDefaultChecker.visit_moduleE s9 %% 1#**400000 1 1r c | j }n# Y d S xY wt | sd S t | rD|| j vr g | j |<