
    9 f6                     f    d dl mZ d dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
  G d de          ZdS )	    )absolute_importN)BaseChecker)BASE_ID)check_messages)
foreignkeyc                        e Zd ZdZdZdZdddddd	ffZd
e dddefde ddiZ fdZ	d Z
 ed          d             Z xZS )ForeignKeyStringsCheckera<  
    Adds transforms to be able to do type inference for model ForeignKeyField
    properties which use a string to name the foreign relationship. This uses
    Django's model name resolution and this checker wraps the setup to ensure
    Django is able to configure itself before attempting to use the lookups.
    a/  Finding foreign-key relationships from strings in pylint-django requires configuring Django.
This can be done via the DJANGO_SETTINGS_MODULE environment variable or the pylint option django-settings-module, eg:

    `pylint --load-plugins=pylint_django --django-settings-module=myproject.settings`

. This can also be set as an option in a .pylintrc configuration file.

Some basic default settings were used, however this will lead to less accurate linting.
Consider passing in an explicit Django configuration file to match your project to improve accuracy.z)Django foreign keys referenced by stringszdjango-settings-moduleNstringz<django settings module>z=A module containing Django settings to be used while linting.)defaulttypemetavarhelpE10zxDjango was not configured. For more information run pylint --load-plugins=pylint_django --help-msg=django-not-configureddjango-not-configuredF)z/Provided Django settings %s could not be loaded django-settings-module-not-foundz@The provided Django settings module %s was not found on the pathc                 H     t                      j        |i | d| _        d S )NF)super__init___raise_warning)selfargskwargs	__class__s      `/var/www/equiseq/venv/lib/python3.11/site-packages/pylint_django/checkers/foreign_key_strings.pyr   z!ForeignKeyStringsChecker.__init__:   s-    $)&)))#    c                    	 ddl m} n# t          $ r Y d S w xY w	 dd l}|                                 ddlm} n# |$ r t          | d          r| j        j	        j
        }n| j	        j
        }|6d| _        ddlm} |                                 |                                 n	 ddlm}m} |                     ||                     |                                 n_# t           $ rR |                     d| j	        j
        	           ddlm} |                                 |                                 Y nw xY wY nw xY wt%          j        t(          j                   d S )
Nr   )ImproperlyConfigured)appslinterT)settings)Settingsr"   r   )r   )django.core.exceptionsr   ModuleNotFoundErrordjangosetupdjango.appsr    hasattrr!   configdjango_settings_moduler   django.confr"   	configurer#   ImportErroradd_messager   add_transformastroidMANAGER)r   r   r&   r    r+   r"   r#   s          r   openzForeignKeyStringsChecker.open>   s   "	CCCCCCC" 	 	 	FF	*	#MMMLLNNN((((((( $ #	# #	# #	# tX&& L)-);)R&&)-)K&%-&*#000000""$$$#>>>>>>>>&&xx0F'G'GHHHLLNNNN" # # # $$:![? %   
 544444&&(((LLNNNNN#1#	#L 	 11111sA   	 
; A,E(:C#"E#AD?<E>D??EEc                 T    | j         r |                     d|           d| _         d S d S )Nr   )nodeF)r   r/   )r   r5   s     r   visit_modulez%ForeignKeyStringsChecker.visit_module   s?     	(44@@@"'D	( 	(r   )__name__
__module____qualname____doc___LONG_MESSAGEnameoptionsr   msgsr   r3   r   r6   __classcell__)r   s   @r   r	   r	      s         hM 7D % 5W	 	

G 	GS#	
 	G 
D$ $ $ $ $C2 C2 C2R ^+,,( ( -,( ( ( ( (r   r	   )
__future__r   r1   pylint.checkersr   pylint_django.__pkginfo__r   pylint_django.compatr   pylint_django.transformsr   r	    r   r   <module>rF      s    & & & & & &  ' ' ' ' ' ' - - - - - - / / / / / / / / / / / /A( A( A( A( A({ A( A( A( A( A(r   