
    yIfF@                    z   d Z ddlmZ ddlZddlZddlmZ ddlmZmZm	Z	 ddl
mZ ddlmZ ddlmZ erdd	lmZ 	 ddlZdd
lmZmZmZmZmZmZ dZnX# e$ rP dZdZ G d d          Z G d d          Z G d d          Z G d d          Z G d d          Z	 	 	 d=d>dZY nw xY wd?d Zd@d#ZdAd'Z e            Z G d( d)e          Z  G d* d+e          Z! G d, d-e          Z" G d. d/e"          Z# G d0 d1e"          Z$ G d2 d3e          Z% ej&        d4          Z'dBd6Z( G d7 d8e          Z)dCd<Z*dS )Dz7Checker for spelling errors in comments and docstrings.    )annotationsN)Pattern)TYPE_CHECKINGAnyLiteral)nodes)BaseTokenChecker)only_required_for_messages)PyLinter)ChunkerEmailFilterFilter	URLFilterWikiWordFilterget_tokenizerTFc                      e Zd ZdS )r   N__name__
__module____qualname__     L/var/www/piapp/venv/lib/python3.11/site-packages/pylint/checkers/spelling.pyr   r   &           r   r   c                      e Zd ZdS )r   Nr   r   r   r   r   r   )   r   r   r   c                      e Zd ZdS )r   Nr   r   r   r   r   r   ,   r   r   r   c                      e Zd ZddZdS )r   wordstrreturnboolc                    t           N)NotImplementedErrorselfr   s     r   _skipzFilter._skip0   s    %%r   Nr   r   r    r!   )r   r   r   r'   r   r   r   r   r   /   s(        	& 	& 	& 	& 	& 	&r   r   c                      e Zd ZdS )r   Nr   r   r   r   r   r   3   s        r   r   tag
str | Nonechunkerslist[Chunker] | Nonefilterslist[Filter] | Noner    c                    t                      S r#   )r   )r*   r,   r.   s      r   r   r   6   s    
 xxr   &list[tuple[Any, enchant.ProviderDesc]]c                 ^    t           r%t          j                                                    ng S r#   )PYENCHANT_AVAILABLEenchantBroker
list_dictsr   r   r   _get_enchant_dictsr7   >   s&    ,?G7>&&(((RGr   inner_enchant_dicts	list[str]c                "    dgd | D             z   S )N c                    g | ]
}|d          S )r   r   .0ds     r   
<listcomp>z-_get_enchant_dict_choices.<locals>.<listcomp>F   s    555A1Q4555r   r   )r8   s    r   _get_enchant_dict_choicesrA   C   s!     455!455555r   pyenchant_availabler!   r   c                x    | r%d | D             }dd                     |           }nd}|s|dz  }|dz  }d| dS )	Nc                @    g | ]}|d           d|d         j          dS )r   z (   ))namer=   s     r   r@   z*_get_enchant_dict_help.<locals>.<listcomp>N   s3    LLL1!A$..!A$)...LLLr   zAvailable dictionaries: z, z0No available dictionaries : You need to install zboth the python package and z)the system dependency for enchant to workzSpelling dictionary name. .)join)r8   rB   dict_as_strenchant_helps       r   _get_enchant_dict_helprL   I   sp      DLL8KLLLJ$))K2H2HJJI" 	;::LCC77777r   c                      e Zd ZdZddZdS )	WordsWithDigitsFilterzSkips words with digits.r   r   r    r!   c                4    t          d |D                       S )Nc              3  >   K   | ]}|                                 V  d S r#   )isdigit)r>   chars     r   	<genexpr>z.WordsWithDigitsFilter._skip.<locals>.<genexpr>_   s*      33d4<<>>333333r   )anyr%   s     r   r'   zWordsWithDigitsFilter._skip^   s    33d333333r   Nr(   r   r   r   __doc__r'   r   r   r   rN   rN   [   s.        ""4 4 4 4 4 4r   rN   c                      e Zd ZdZddZdS )	WordsWithUnderscoreszSSkips words with underscores.

    They are probably function parameter names.
    r   r   r    r!   c                
    d|v S )N_r   r%   s     r   r'   zWordsWithUnderscores._skiph   s    d{r   Nr(   rU   r   r   r   rX   rX   b   s2         
     r   rX   c                  &    e Zd ZU dZded<   d
dZd	S )RegExFilterzParent class for filters using regular expressions.

    This filter skips any words the match the expression
    assigned to the class attribute ``_pattern``.
    zPattern[str]_patternr   r   r    r!   c                P    t          | j                            |                    S r#   )r!   r]   matchr%   s     r   r'   zRegExFilter._skipu   s     DM''--...r   Nr(   )r   r   r   rV   __annotations__r'   r   r   r   r\   r\   l   sB           / / / / / /r   r\   c                  2    e Zd ZdZ ej        d          ZdS )CamelCasedWordzFilter skipping over camelCasedWords.
    This filter skips any words matching the following regular expression:

           ^([a-z]\w+[A-Z]+\w+)

    That is, any words that are camelCasedWords.
    z^([a-z]+(\d|[A-Z])(?:\w+)?)Nr   r   r   rV   recompiler]   r   r   r   rb   rb   y   s,          rz899HHHr   rb   c                  2    e Zd ZdZ ej        d          ZdS )SphinxDirectiveszFilter skipping over Sphinx Directives.
    This filter skips any words matching the following regular expression:

           ^(:([a-z]+)){1,2}:`([^`]+)(`)?

    That is, for example, :class:`BaseQuery`
    z^(:([a-z]+)){1,2}:`([^`]+)(`)?Nrc   r   r   r   rg   rg      s,          rz;<<HHHr   rg   c                  .    e Zd ZU dZded<   d
dZddZd	S )ForwardSlashChunkerz[This chunker allows splitting words like 'before/after' into 'before' and
    'after'.
    r   _textr    tuple[str, int]c                p   	 | j         st                      d| j         vr| j         }d| _        d| _         |dfS | j                             dd          \  }}|| _         d| _        |r6|r4|d                                         r|d                                         sd| _         d| _        | d| dfS |dfS )NT/r   r;   rE   )rj   StopIteration_offsetsplitisalpha)r&   textpre_text	post_texts       r   nextzForwardSlashChunker.next   s    	: &#oo%$*$$z 
Qw"&*"2"23":":Hi"DJDL4 4  |++--4 !|++--	4  
 "00Y00!33Q;r   tuple[str, Literal[0]]c                *   	 d| j         vr	| j         dfS | j                             dd          \  }}|r|snP|d                                         r|d                                         st                      |dz   |z   | _         t                      )NTrm   r   rE   rn    )rj   rq   rr   ro   )r&   rt   ru   s      r   _nextzForwardSlashChunker._next   s    	4$*$$z1}$"&*"2"23":":Hi 9 B<'')) &11E1E1G1G &#oo%!C)3DJ	4 oor   N)r    rk   )r    rw   )r   r   r   rV   r`   rv   rz   r   r   r   ri   ri      sS           JJJ   .
 
 
 
 
 
r   ri   z!(\s|^)(`{1,2})([^`]+)(\2)([^`]|$)linec                @    dd}t                               ||           S )zAlter line so code flanked in back-ticks is ignored.

    Pyenchant automatically strips back-ticks when parsing tokens,
    so this cannot be done at the individual filter level.
    	match_objre.Match[str]r    r   c                X    |                      d          |                      d          z   S )NrE      )group)r}   s    r   -replace_code_but_leave_surrounding_characterszW_strip_code_flanked_in_backticks.<locals>.replace_code_but_leave_surrounding_characters   s%    q!!IOOA$6$666r   )r}   r~   r    r   )CODE_FLANKED_IN_BACKTICK_REGEXsub)r{   r   s     r    _strip_code_flanked_in_backticksr      s5    7 7 7 7 *--5t  r   c                  P   e Zd ZdZdZddddZddd	d
 ee           eee	          dfddddddfddddddfddddddfddddddfdd ddd!dffZ
d8d$Zd9d)Zd:d,Z ed-          d;d0            Z ed-          d<d2            Z ed-          d=d4            ZeZd>d6Zd7S )?SpellingCheckerz*Check spelling in comments and docstrings.spelling)zEWrong spelling of a word '%s' in a comment:
%s
%s
Did you mean: '%s'?wrong-spelling-in-commentz5Used when a word in comment is not spelled correctly.)zGWrong spelling of a word '%s' in a docstring:
%s
%s
Did you mean: '%s'?wrong-spelling-in-docstringz7Used when a word in docstring is not spelled correctly.)z$Invalid characters %r in a docstringinvalid-characters-in-docstringz;Used when a word in docstring cannot be checked by enchant.)C0401C0402C0403zspelling-dictr;   choicez<dict name>)defaulttypemetavarchoiceshelpzspelling-ignore-wordsstringz<comma separated words>z9List of comma separated words that should not be checked.)r   r   r   r   zspelling-private-dict-filepathz<path to file>zIA path to a file that contains the private dictionary; one word per line.zspelling-store-unknown-wordsnynz<y or n>zTells whether to store unknown words to the private dictionary (see the --spelling-private-dict-file option) instead of raising a message.zmax-spelling-suggestions   intNz:Limits count of emitted suggestions for spelling mistakes.z"spelling-ignore-comment-directivesz2fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy:zList of comma separated words that should be considered directives if they appear at the beginning of a comment and should not be checked.r    Nonec                   d| _         t          sd S | j        j        j        }|sd S d | j        j        j                            d          D             | _        | j                            ddg           d | j        j        j	                            d          D             | _
        | j        j        j        r*t          j        || j        j        j                  | _        nt          j        |          | _        | j        j        j        rt!                      | _        t%          |t&          gt(          t*          t,          t.          t0          t2          t4          g          | _        d| _         d S )	NFc                6    g | ]}|                                 S r   stripr>   ws     r   r@   z(SpellingChecker.open.<locals>.<listcomp>.  s-     
 
 
AGGII
 
 
r   ,parampylintc                6    g | ]}|                                 S r   r   r   s     r   r@   z(SpellingChecker.open.<locals>.<listcomp>5  s0     .
 .
 .
 GGII.
 .
 .
r   )r,   r.   T)initializedr3   linterconfigspelling_dictspelling_ignore_wordsrq   ignore_listextend"spelling_ignore_comment_directivesignore_comment_directive_listspelling_private_dict_filer4   DictWithPWLDictspelling_store_unknown_wordssetunknown_wordsr   ri   r   r   r   rN   rX   rb   rg   	tokenizer)r&   	dict_names     r   openzSpellingChecker.open&  sn    " 	FK&4	 	F
 
#{1GMMcRR
 
 

 	( 3444.
 .
['JPPQTUU.
 .
 .
*
 ;8 	9!(!44;-H" "D ")i!8!8D;: 	1+.55D&)*%$ 
 
 
  r   msgidr   r{   line_numc                ~   |}	 t          j        d|          j        d         d         }n# t          t          f$ r d}Y nw xY w|                                                    d          rad|vr]|                                dd          }| j        D ]6}|                    d|z             r|t          |          dz   d          } n7d}nd}t          |          }| 
                    |                                          D ]7\  }}	|	|z  }	|                                }
|| j        v s	|
| j        v r2|                    d	          r't          |          d
k    r|d
d          }|
d
d          }
	 | j                            |
          r| j                            |          rn3# t          j        j        $ r |                     d||f           Y w xY w| j        j        j        rv|
| j        vrkt/          | j        j        j        dd          5 }|                    |
 d           d d d            n# 1 swxY w Y   | j                            |
           `| j                            |          }|| j        j        j        d = ||	d          }t          j        d| d|          }|r|j        d
         d         }n|                    |          }||	z  }|r|dz  }d|z  dt          |          z  z   }d                    |          }|||d| df}|                     |||           9d S )Nz^\s+r   rE   #	docstringry   TF)zu'zu"zr'zr"   r   )r{   argsazutf-8)encoding
z(\W|^)(z)(\W|$)^z' or '')rd   searchregs
IndexErrorAttributeErrorr   
startswithr   lenr   r   casefoldr   r   checkr4   errorsErroradd_messager   r   r   r   r   r   writeaddsuggestmax_spelling_suggestionsindexrI   )r&   r   r{   r   original_lineinitial_spaceiter_directivestarts_with_commentr   word_start_atlower_cased_wordfsuggestionsline_segmentr_   col	indicatorall_suggestionr   s                      r   _check_spellingzSpellingChecker._check_spellingT  s   	Igt449!<Q?MMN+ 	 	 	MMM	::<<""3'' 	(Ku,D,D::<<#D #'"D  ??3#788 ^!4!4q!8 ; ;<DE #'"'/55#'>>$**,,#?#? 9	B 9	BD-]*M#}} t'''+;t?O+O+O 788 8SYY]]ABBx#3ABB#7 %++,<== 
 %++D11 >'     5HD7 !    	 {!> B#4+===*E!(   9 #3 7 7 78889 9 9 9 9 9 9 9 9 9 9 9 9 9 9 &**+;<<< #088>> 2 K M MN#MNN3	":T":":":LII 3*Q-*CC&,,T22C}$& 1HC 3Y3T?;	!){!;!;mY8MN8M8M8MN  XD AAAAs9	B 9	Bs9   &+ A A3F*F**-GGH==I	I	tokenslist[tokenize.TokenInfo]c                   | j         sd S |D ]z\  }}\  }}}}|t          j        k    r_|dk    r|                    d          r7|                    d          rM|                    d          rc|                     d||           {d S )NrE   z#!/z	# pylint:z# type: r   )r   tokenizeCOMMENTr   r   )r&   r   tok_typetoken	start_rowrZ   s         r   process_tokenszSpellingChecker.process_tokens  s     	F 6< 	T 	T1He^iQ8+++>>e&6&6u&=&=>##K00 ##J//  $$%@%SSS	T 	Tr   r   nodenodes.Modulec                0    |                      |           d S r#   _check_docstringr&   r   s     r   visit_modulezSpellingChecker.visit_module      d#####r   nodes.ClassDefc                0    |                      |           d S r#   r   r   s     r   visit_classdefzSpellingChecker.visit_classdef  r   r   *nodes.FunctionDef | nodes.AsyncFunctionDefc                0    |                      |           d S r#   r   r   s     r   visit_functiondefz!SpellingChecker.visit_functiondef  s     	d#####r   Jnodes.FunctionDef | nodes.AsyncFunctionDef | nodes.ClassDef | nodes.Modulec                    | j         sdS |j        sdS |j        dz   }t          |j        j                                                  D ]\  }}|                     d|||z               dS )z*Check if the node has any spelling errors.NrE   r   )r   doc_nodelineno	enumeratevalue
splitlinesr   )r&   r   
start_lineidxr{   s        r   r   z SpellingChecker._check_docstring  s      	F} 	F[1_
"4=#6#A#A#C#CDD 	X 	XIC  !>jSVFVWWWW	X 	Xr   N)r    r   )r   r   r{   r   r   r   r    r   )r   r   r    r   )r   r   r    r   )r   r   r    r   )r   r   r    r   )r   r   r    r   )r   r   r   rV   rG   msgsrA   enchant_dictsrL   r3   optionsr   r   r   r
   r   r   r   visit_asyncfunctiondefr   r   r   r   r   r      s       44D


 D*  (44]CC..}>QRR 		
 $ 4S	 	
 )+1	 		
 +%%	 	
 'T	 	
 1O 4-	 
	
g>G@+  +  +  + \OB OB OB OBbT T T T&   =>>$ $ $ ?>$   =>>$ $ $ ?>$   =>>$ $ $ ?>$
 /X X X X X Xr   r   r   r   r   c                J    |                      t          |                      d S r#   )register_checkerr   )r   s    r   registerr    s$    
OF3344444r   )NNN)r*   r+   r,   r-   r.   r/   r    r   )r    r1   )r8   r1   r    r9   )r8   r1   rB   r!   r    r   )r{   r   r    r   )r   r   r    r   )+rV   
__future__r   rd   r   r   typingr   r   r   astroidr   pylint.checkersr	   pylint.checkers.utilsr
   pylint.lintr   r4   enchant.tokenizer   r   r   r   r   r   r3   ImportErrorr7   rA   rL   r  rN   rX   r\   rb   rg   ri   re   r   r   r   r  r   r   r   <module>r     s  
 > = " " " " " " 				        . . . . . . . . . .       , , , , , , < < < < < < %$$$$$$%NNN                   G                     & & & & & & & &        )-'+      )8H H H H
6 6 6 68 8 8 8 #"$$4 4 4 4 4F 4 4 4    6   
/ 
/ 
/ 
/ 
/& 
/ 
/ 
/	: 	: 	: 	: 	:[ 	: 	: 	:
= 
= 
= 
= 
={ 
= 
= 
=( ( ( ( (' ( ( (V ",,P!Q!Q    GX GX GX GX GX& GX GX GXT5 5 5 5 5 5s   A AB('B(