o
    tBhU                     @  s  U d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dl	m
Z
 d dlmZ ejdkr5d dlZnd dlZd dlmZmZmZmZmZmZmZmZmZmZmZ d dlmZmZ d dl m!Z! d d	l"m#Z#m$Z$ ee%e&e'e(ee%e%f ee% ee'e'f f Z)d
e*d< eege)f Z+d
e*d< dddZ,ddddZ-dddZ.dddZ/dd d!Z0dd$d%Z1dd&d'Z2dd)d*Z3i d+e,d,d-d. d/e%d0e/d1d2d. d3e2d4e/d5e/d6e&d7e&d8e3d9e&d:d;d. d<d=d. d>d?d. d@dAd. dBdCd. dDd. e/e/e&dEd. dFZ4dGe*dH< e45 Z6dGe*dI< e67e,e-dJd. dKd. dLd. e-e-e-dMd. dNd. e-e0dO 		dddZd[Z8dd^d_Z9ddadbZ:ddedfZ;ej<fddndoZ=ddrdsZ>ddvdwZ?ddzd{Z@dddZAdddZBG dd deCZDdS )    )annotationsN)StringIO)error_codes)      )AnyCallableDictIterableListMappingMutableMappingSequenceTextIOTupleUnion)Final	TypeAlias)defaults)PER_MODULE_OPTIONSOptions
_TypeAlias_CONFIG_VALUE_TYPES_INI_PARSER_CALLABLEvstr | floatreturntuple[int, int]c                 C  s   t dt| }|std|  dt|dt|d}}|dkr/|dkr/	 ||fS |dkrV|tjd k rRdj	|gtjR  }t
| trM|d	7 }t|||fS td
| d)Nz\A(\d)\.(\d+)\ZzInvalid python version 'z' (expected format: 'x.y')         r   z6Python 3.{} is not supported (must be {}.{} or higher)z7. You may need to put quotes around your Python versionzPython major version 'z' out of range (must be 3))rematchstrargparseArgumentTypeErrorintgroupr   PYTHON3_VERSION_MINformat
isinstancefloat)r   mmajorminormsg r0   i/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/mypy/config_parser.pyparse_version*   s*   


r2   [,]str | Sequence[str]split_regexr#   	list[str]c                 C  s.   t | trdd t|| D S dd | D S )z6Split and trim a str or list of str into a list of strc                 S     g | ]}|  qS r0   strip.0pr0   r0   r1   
<listcomp>E       ztry_split.<locals>.<listcomp>c                 S  r7   r0   r8   r:   r0   r0   r1   r=   G   r>   )r*   r#   r!   split)r   r5   r0   r0   r1   	try_splitB   s   
r@   codesc                 C  s6   t | t t  }|rtddt| | S )NzInvalid error code(s): , )setr   keysr$   r%   joinsorted)rA   invalid_codesr0   r0   r1   validate_codesJ   s   rH   pathc                 C  s   t jt j| S )ziExpand the user home directory and any environment variables contained within
    the provided path.
    )osrI   
expandvars
expanduser)rI   r0   r0   r1   expand_pathS   s   rM   c                 C  s.   t | tr|  r|  gS g S dd | D S )Nc                 S  s   g | ]
}|  r|  qS r0   r8   r:   r0   r0   r1   r=   ^   s    z(str_or_array_as_list.<locals>.<listcomp>)r*   r#   r9   )r   r0   r0   r1   str_or_array_as_list[   s   
rN   pathsSequence[str]c                 C  sF   g }| D ]}t | }tj|dd}|r|| q|| q|S )zTake a list of files/directories (with support for globbing through the glob library).

    Where a path/glob matches no file, we still include the raw path in the resulting list.

    Returns a list of file paths
    T)	recursive)rM   r9   fileglobglobextendappend)rO   expanded_pathsrI   globbed_filesr0   r0   r1   split_and_match_files_lista   s   rX   c                 C  s   t | dS )zTake a string representing a list of files/directories (with support for globbing
    through the glob library).

    Where a path/glob matches no file, we still include the raw path in the resulting list.

    Returns a list of file paths
    ,)rX   r?   )rO   r0   r0   r1   split_and_match_filesu   s   	rZ   choicec              	   C  s6   g d}| |vrt d| ddd |D | S )N)normalsilentskiperrorz$invalid choice '{}' (choose from {})rB   c                 s  s    | ]	}d | d V  qdS )'Nr0   r;   xr0   r0   r1   	<genexpr>       z'check_follow_imports.<locals>.<genexpr>)r$   r%   r)   rE   )r[   choicesr0   r0   r1   check_follow_imports   s   rf   python_versionstrict_optional_whitelistc                 C  s   |   S Nr?   sr0   r0   r1   <lambda>   s    rm   custom_typing_modulecustom_typeshed_dir	mypy_pathc                 C  s   dd t d| D S )Nc                 S  s   g | ]}t | qS r0   )rM   r9   r:   r0   r0   r1   r=          <lambda>.<locals>.<listcomp>[,:])r!   r?   rk   r0   r0   r1   rm      s    filesquickstart_file	junit_xmlsilent_importsalmost_silentfollow_importsno_site_packagespluginsc                 C     dd |  dD S )Nc                 S  r7   r0   r8   r:   r0   r0   r1   r=      r>   rr   rY   rj   rk   r0   r0   r1   rm      r>   always_truec                 C  r|   )Nc                 S  r7   r0   r8   r:   r0   r0   r1   r=      r>   rr   rY   rj   rk   r0   r0   r1   rm      r>   always_falsec                 C  r|   )Nc                 S  r7   r0   r8   r:   r0   r0   r1   r=      r>   rr   rY   rj   rk   r0   r0   r1   rm      r>   disable_error_codec                 C     t dd | dD S )Nc                 S  r7   r0   r8   r:   r0   r0   r1   r=      r>   rr   rY   rH   r?   rk   r0   r0   r1   rm      rq   enable_error_codec                 C  r   )Nc                 S  r7   r0   r8   r:   r0   r0   r1   r=      r>   rr   rY   r   rk   r0   r0   r1   rm      rq   c                 C  r|   )Nc                 S  r7   r0   r8   r:   r0   r0   r1   r=      r>   rr   rY   rj   rk   r0   r0   r1   rm      r>   c                 C  s
   |   gS ri   r8   rk   r0   r0   r1   rm      s   
 )package_root	cache_dirpython_executablestrictexcludez&Final[dict[str, _INI_PARSER_CALLABLE]]ini_config_typestoml_config_typesc                 C  s   dd t | dD S )Nc                 S  s   g | ]}t |qS r0   )rM   r:   r0   r0   r1   r=      r>   rr   rs   )r@   rk   r0   r0   r1   rm      r>   c                 C     t t| S ri   )rX   r@   rk   r0   r0   r1   rm          c                 C  r   ri   )rf   r#   rk   r0   r0   r1   rm      r   c                 C  r   ri   rH   r@   rk   r0   r0   r1   rm      r   c                 C  r   ri   r   rk   r0   r0   r1   rm      r   )rg   rh   rp   rt   ry   r{   r}   r~   r   r   r   r   optionsr   set_strict_flagsCallable[[], None]filename
str | NonestdoutTextIO | NonestderrNonec                   s(  |pt j}|p	t j}|dur|f}nttjjtj}t	|}t
 }|D ]~}tj|s-q$zBt|ret|d}	t|	}
W d   n1 sGw   Y  |
di }
d|
vrXW q$d|
d i}
t|
}t}n	|| |}t}W n" tjt
jtfy } zt| d| |d W Y d}~q$d}~ww |tjv rd|vrq$|}|| _ ndS tjtj|tjd< d|vr|s|tjvrt| d|d n)|d }| d	}t|| ||||\}}|  D ]
\}}t!| || q| j"#| |  D ]\}}|$d
rt%||}t|| ||||\}}|r%td|d&dd t'|D f |d t(|t) rHtd|d&t't(|t) f |d dd |  D }|dd }|*dD ]=  +tj,d tj-rg +tj-d t. fdddD st.dd  *dD rtd| |d qS|| j/ < qSqdS )zParse a config file into an Options object.

    Errors are written to stderr but are not fatal.

    If filename is None, fall back to default config files.
    Nrbtoolmypy: fileMYPY_CONFIG_FILE_DIRz": No [mypy] section in config filez
: [mypy]: mypy-z5%sPer-module sections should not specify reports (%s)rB   c                 s  s    | ]}|d  V  qdS )_reportNr0   )r;   rl   r0   r0   r1   rc         z$parse_config_file.<locals>.<genexpr>z?%sPer-module sections should only specify per-module flags (%s)c                 S  s   i | ]\}}|t v r||qS r0   )r   )r;   kr   r0   r0   r1   
<dictcomp>  s    z%parse_config_file.<locals>.<dictcomp>   rY   .c                 3  s    | ]}| v V  qd S ri   r0   )r;   crS   r0   r1   rc     r   z?[]!c                 s  s     | ]}d |v o|d kV  qdS )*Nr0   ra   r0   r0   r1   rc     s    
zk%sPatterns must be fully-qualified module names, optionally with '*' in some components (e.g spam.*.eggs.*))0sysr   r   maprJ   rI   rL   r   CONFIG_FILEStupleconfigparserRawConfigParserexistsis_tomlopentomllibloadgetdestructure_overridesr   readr   TOMLDecodeErrorErrorConfigTOMLValueErrorprintSHARED_CONFIG_FILESconfig_filedirnameabspathenvironparse_sectionitemssetattrreport_dirsupdate
startswith
get_prefixrE   rF   rC   r   r?   replacesepaltsepanyper_module_options)r   r   r   r   r   config_filesconfig_files_iterconfig_parserr   f	toml_dataparserconfig_typeserr	file_readsectionprefixupdatesr   r   r   nameglobsr0   r   r1   parse_config_file   s   


"

 

r   r   r   c                 C  s:   t | rdd|ddd   }n|}|  d| dS )Nzmodule = "%s"-r   z: [z]: )r   rE   r?   )r   r   module_name_strr0   r0   r1   r   )  s   r   boolc                 C  s   |   dS )Nz.toml)lowerendswith)r   r0   r0   r1   r   2  s   r   r   dict[str, Any]c           	      C  s  d| d vr| S t | d d tstd|  }|d d D ]f}d|vr)tdt |d tr6|d g}nt |d trB|d }ntd|D ]<}| }|d= d| }||vr_|||< qH| D ] \}}||| v r}|| | |kr}td||f ||| |< qcqHq|d d= |S )	aF  Take the new [[tool.mypy.overrides]] section array in the pyproject.toml file,
    and convert it back to a flatter structure that the existing config_parser can handle.

    E.g. the following pyproject.toml file:

        [[tool.mypy.overrides]]
        module = [
            "a.b",
            "b.*"
        ]
        disallow_untyped_defs = true

        [[tool.mypy.overrides]]
        module = 'c'
        disallow_untyped_defs = false

    Would map to the following config dict that it would have gotten from parsing an equivalent
    ini file:

        {
            "mypy-a.b": {
                disallow_untyped_defs = true,
            },
            "mypy-b.*": {
                disallow_untyped_defs = true,
            },
            "mypy-c": {
                disallow_untyped_defs: false,
            },
        }
    	overridesr   z~tool.mypy.overrides sections must be an array. Please make sure you are using double brackets like so: [[tool.mypy.overrides]]modulezetoml config file contains a [[tool.mypy.overrides]] section, but no module to override was specified.zytoml config file contains a [[tool.mypy.overrides]] section with a module value that is not a string or a list of stringsr   ztoml config file contains [[tool.mypy.overrides]] sections with conflicting values. Module '%s' has two different values for '%s')r*   listr   copyr#   r   )	r   resultoverridemodulesr   module_overridesold_config_namenew_key	new_valuer0   r0   r1   r   6  sL    



r   r   templater   Mapping[str, Any]r   r   (tuple[dict[str, object], dict[str, str]]c                 C  sb  i }i }|D ]}d}	|}
||v r|| }nd}t |dsJ |dkr)t||d}|du r|drV|dd dd}|tjv rJt|| ||< nt|  d| |d	 q|d
r\nV|drst ||dd rs|dd }
d}	n?|drt |d| rd| }
d}	n,|drt ||dd r|dd }
d}	n|dkrnt|  d| d||  |d	 |	rt||
d}nqt	|}d}zl|t
u rt|trt||}n||}|	r| }nNt|r|	rt|  d|
 |d	 W qz	|||}W n0 tjy } zt|  | d| |d	 W Y d}~W qd}~ww t|  d| d|d	 W qW n  tyN } zt|  | d| |d	 W Y d}~qd}~ww |dkr[|rZ|  q|dkr}td|  |d	 |r}d|vrtd|d< d|vr}d|d< |dkrtd|  |d	 |rd|vrd|d< |||
< qd |vrg |d < d!|vrg |d!< ||fS )"z|Parse one section of a config file.

    Returns a dict of option values encountered, and a dict of report directories.
    FNnew_semantic_analyzerr   i_r   zUnrecognized report type: r   x_no_r   Tallowdisdisallowr   zUnrecognized option: z = zCan not invert non-boolean key r   zDon't know what type z should haverw   zV%ssilent_imports has been replaced by ignore_missing_imports=True; follow_imports=skipignore_missing_importsry   r^   rx   z9%salmost_silent has been replaced by follow_imports=errorr_   r   r   )hasattrgetattrr   r   r   REPORTER_NAMESr#   r   r   typer   r*   dictconvert_to_booleanr   
getbooleancallabler$   r%   
ValueError)r   r   r   r   r   r   resultsr   keyinvertoptions_keyctdvreport_typer   r   r0   r0   r1   r     s   




 











r   value
Any | Nonec                 C  sN   t | tr| S t | tst| } |  tjjvrtd|  tjj|   S )zAReturn a boolean value translating from other types if necessary.zNot a boolean: )r*   r   r#   r   r   r   BOOLEAN_STATESr   )r  r0   r0   r1   r     s   

r   rl   tuple[list[str], list[str]]c                 C  s   g }g }g }d}|t | k ro| | dkr!|d|  g }nD| | dkr^|d7 }|t | k rN| | dkrN|| |  |d7 }|t | k rN| | dks7|t | kr]|d |  n|| |  |d7 }|t | k s|r{|d|  ||fS )zfSplit s on commas, except during quoted sections.

    Returns the parts and a list of error messages.r   rY    "r   z+Unterminated quote in configuration comment)lenrU   rE   r9   clear)rl   partscurerrorsir0   r0   r1   split_directive  s0   
r  line tuple[dict[str, str], list[str]]c                 C  sn   i }t | \}}|D ](}d|vr|}d}ndd |ddD \}}|dd}|du r.d}|||< q
||fS )	zGRewrite the mypy comment syntax into ini file syntax.

    Returns
    =Nc                 s  s    | ]}|  V  qd S ri   r8   ra   r0   r0   r1   rc   .  r   z.mypy_comments_to_config_map.<locals>.<genexpr>r   r   r   True)r  r?   r   )r  r   r   entriesr  entryr   r  r0   r0   r1   mypy_comments_to_config_map"  s   
r  argslist[tuple[int, str]]/tuple[dict[str, object], list[tuple[int, str]]]c              	     s   g }i }| D ]c\ }t  }t||\}}||d< | fdd|D  t }ddfdd}	td	||	|d t|d
\}
}| fdd|  	dD  |r[|
 df rd|
 df ||
 q||fS )zParse a collection of inline mypy: configuration comments.

    Returns a dictionary of options to be applied and a list of error messages
    generated.
    dummyc                 3  s    | ]} |fV  qd S ri   r0   ra   linenor0   r1   rc   K  r   z&parse_mypy_comments.<locals>.<genexpr>Fr   r   c                     s   d d S )NTr0   r0   )strict_foundr0   r1   r   P  s   z-parse_mypy_comments.<locals>.set_strict_flagsr	  )r   c                 3  s    | ]	}|r |fV  qd S ri   r0   ra   r  r0   r1   rc   W  rd   
z-Reports not supported in inline configurationzSetting "strict" not supported in inline configuration: specify it in a configuration file instead, or set individual inline flags (see "mypy -h" for the list of flags enabled in strict mode)N)r   r   )r   r   r  rT   r   r   r   getvaluer9   r?   rU   r   )r  r   r  sectionsr  r   r   parse_errorsr   r   new_sectionsreportsr0   )r  r  r1   parse_mypy_comments8  s0   	
&	r&  r   c                 C  s:   | r|sdS t | sddd |D S ddt| S )Nr	  rB   c                 s  s    | ]	}d | dV  qdS )z[mypy-]Nr0   )r;   r   r0   r0   r1   rc   n  rd   z*get_config_module_names.<locals>.<genexpr>zmodule = ['%s']z', ')r   rE   rF   )r   r   r0   r0   r1   get_config_module_namesi  s
   r(  c                   @  s   e Zd ZdS )r   N)__name__
__module____qualname__r0   r0   r0   r1   r   s  s    r   )r   r   r   r   )r3   )r   r4   r5   r#   r   r6   )rA   r6   r   r6   )rI   r#   r   r#   )r   r4   r   r6   )rO   rP   r   r6   )rO   r#   r   r6   )r[   r#   r   r#   )NN)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   r   r   r   r   r   r   r   )r  r  r   r   )rl   r#   r   r  )r  r#   r   r   r   r  )r  r  r   r   r   r  )r   r   r   r6   r   r#   )E
__future__r   r$   r   rS   rR   rJ   r!   r   ior   mypy.errorcodesr   version_infor   tomlitypingr   r   r	   r
   r   r   r   r   r   r   r   typing_extensionsr   r   r   r   r   mypy.optionsr   r   r#   r   r&   r+   r   __annotations__r   r2   r@   rH   rM   rN   rX   rZ   rf   r   r   r   r   r   r   r   r   r   r   r   r  r  r&  r(  r   r   r0   r0   r0   r1   <module>   s    

4$


	





k
	
Z
p



1
