
    c                    x    d Z ddlmZ ddlmZ ddlmZmZmZ ddl	m
Z
mZ dZ G d de
j                  ZddZdS )a  All alphanumeric unicode character are allowed in Python but due
to similarities in how they look they can be confused.

See: https://peps.python.org/pep-0672/#confusing-features

The following checkers are intended to make users are aware of these issues.
    )annotations)nodes)	constants
interfaceslint)base_checkerutilsac  Used when the name contains at least one non-ASCII unicode character. See https://peps.python.org/pep-0672/#confusing-features for a background why this could be bad. 
If your programming guideline defines that you are programming in English, then there should be no need for non ASCII characters in Python Names. If not you can simply disable this check.c                     e Zd ZdZddeddgifdddefd	Zd
Zd(dZ ej	        dd          d)d            Z
 ej	        d          d*d            ZeZ ej	        d          d+d            Z ej	        d          d,d            Z ej	        d          d-d            Zd.d Z ej	        dd          d/d"            Z ej	        dd          d0d$            Z ej	        d          d1d&            Zd'S )2NonAsciiNameCheckerzA strict name checker only allowing ASCII.

    Note: This check only checks Names, so it ignores the content of
          docstrings and comments!
    zB%s name "%s" contains a non-ASCII character, consider renaming it.non-ascii-name	old_names)C0144zold-non-ascii-name)zh%s name "%s" contains a non-ASCII character. PEP 3131 only allows non-ascii identifiers, not file names.non-ascii-file-nameaA  Some editors don't support non-ASCII file names properly. Even though Python supports UTF-8 files since Python 3.5 this isn't recommended for interoperability. Further reading:
- https://peps.python.org/pep-0489/#export-hook-name
- https://peps.python.org/pep-0672/#confusing-features
- https://bugs.python.org/issue20485zP%s name "%s" contains a non-ASCII character, use an ASCII-only alias for import.non-ascii-module-import)C2401W2402C2403zNonASCII-Checker	node_typestrname
str | Nonenodenodes.NodeNGreturnNonec                   |dS t          |                                          s`t          j        |         }|                                |f}d}|dk    rd}n|dk    rd}|                     |||t          j                   dS dS )z3Check whether a name is using non-ASCII characters.Nr   filer   moduler   )r   args
confidence)r   isasciir   HUMAN_READABLE_TYPES
capitalizeadd_messager   HIGH)selfr   r   r   
type_labelr   msgs          ?lib/python3.11/site-packages/pylint/checkers/non_ascii_names.py_check_namezNonAsciiNameChecker._check_nameJ   s      	F4yy  "" 	T"7	BJ))++T2D"C F" 0+h& 0/St$:?SSSSS	T 	T    r   nodes.Modulec                p    |                      d|j                            d          d         |           d S )Nr   .)r*   r   splitr&   r   s     r)   visit_modulez NonAsciiNameChecker.visit_module_   s3    !5!5b!94@@@@@r+   *nodes.FunctionDef | nodes.AsyncFunctionDefc                ^   |                      d|j        |           |j        }|j        r&|j        D ]}|                      d|j        |           |j        r&|j        D ]}|                      d|j        |           |j        r&|j        D ] }|                      d|j        |           d S d S )Nfunctionargument)r*   r   r   posonlyargs
kwonlyargs)r&   r   	argumentspos_only_argargkwargs         r)   visit_functiondefz%NonAsciiNameChecker.visit_functiondefc   s     	TY555 I	   	N ) 5 N N  \->MMMM > 	< ~ < <  SXs;;;;  	@"- @ @  UZ????	@ 	@@ @r+   nodes.Globalc                H    |j         D ]}|                     d||           d S )Nconstnamesr*   )r&   r   r   s      r)   visit_globalz NonAsciiNameChecker.visit_global}   s8    J 	2 	2DWdD1111	2 	2r+   nodes.AssignNamec                f   |                                 }t          |t          j                  r.|j        |j        v r|                     d|j        |           dS dS t          |t          j                  r|                     d|j        |           dS |                     d|j        |           dS )z"Check module level assigned names.variableattrN)	frame
isinstancer   FunctionDefparentbodyr*   r   ClassDef)r&   r   rH   s      r)   visit_assignnamez$NonAsciiNameChecker.visit_assignname   s     

eU.// 	:{ej( >
   TY=====> > u~.. 	:VTY55555 ZD99999r+   nodes.ClassDefc                    |                      d|j        |           |j                                        D ]D\  }}t	          |                    |                    s|                      d||d                    Ed S )NclassrG   r   )r*   r   instance_attrsitemsanyinstance_attr_ancestors)r&   r   rG   anodess       r)   visit_classdefz"NonAsciiNameChecker.visit_classdef   s    $)T222 /5577 	: 	:LD&t33D99:: :  vay999	: 	:r+   nodes.ImportFrom | nodes.Importc                V    |j         D ] \  }}|p|}|                     d||           !d S )Nr   rA   )r&   r   module_namealiasr   s        r)   _check_module_importz(NonAsciiNameChecker._check_module_import   sG    "&* 	3 	3K'KDXtT2222	3 	3r+   nodes.Importc                0    |                      |           d S Nr\   r1   s     r)   visit_importz NonAsciiNameChecker.visit_import       !!$'''''r+   nodes.ImportFromc                0    |                      |           d S r_   r`   r1   s     r)   visit_importfromz$NonAsciiNameChecker.visit_importfrom   rb   r+   
nodes.Callc                R    |j         D ]}|                     d|j        |           dS )z+Check if the used keyword args are correct.r6   N)keywordsr*   r;   )r&   r   keywords      r)   
visit_callzNonAsciiNameChecker.visit_call   s<     } 	? 	?GZg>>>>	? 	?r+   N)r   r   r   r   r   r   r   r   )r   r,   r   r   )r   r3   r   r   )r   r>   r   r   )r   rD   r   r   )r   rO   r   r   )r   rX   r   r   )r   r]   r   r   )r   rc   r   r   )r   rf   r   r   )__name__
__module____qualname____doc__NON_ASCII_HELPmsgsr   r*   r	   only_required_for_messagesr2   r=   visit_asyncfunctiondefrC   rN   rW   r\   ra   re   rj    r+   r)   r   r      s#         Q:;<	

* _%
9! !DF DT T T T* &U%&68MNNA A A ONA &U%&677@ @ @ 87@. /%U%&6772 2 2 872 &U%&677: : : 87:0 &U%&677: : : 87:3 3 3 3
 &U%&68QRR( ( ( SR( &U%&68QRR( ( ( SR( &U%&677? ? ? 87? ? ?r+   r   linterlint.PyLinterr   r   c                J    |                      t          |                      d S r_   )register_checkerr   )rt   s    r)   registerrx      s%    
/7788888r+   N)rt   ru   r   r   )rn   
__future__r   astroidr   pylintr   r   r   pylint.checkersr   r	   ro   BaseCheckerr   rx   rs   r+   r)   <module>r~      s   
  # " " " " "       . . . . . . . . . . / / / / / / / /> U? U? U? U? U?,2 U? U? U?p9 9 9 9 9 9r+   