o
    2g-_                     @  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mZmZm	Z	m
Z
mZ d dlmZ d dlmZmZ d dlmZmZ G dd dZh d	Zd
ed< eh dB dh Zd
ed< dZd
ed< dZd
ed< dZd
ed< dZd
ed< dZd
ed< eeefZd
ed< eeeefZd
ed< G dd dZ dS )    )annotationsN)AnyCallableFinalMappingPattern)defaults)	ErrorCodeerror_codes)get_class_descriptorsreplace_object_statec                   @  s2   e Zd ZU dZded< dZded< dZded< dS )		BuildTyper   r   STANDARD   MODULE   PROGRAM_TEXTN)__name__
__module____qualname__r   __annotations__r   r    r   r   D/home/garg/my-data/venv/lib/python3.10/site-packages/mypy/options.pyr      s   
 r   >$   mypycalways_truedebug_cachealways_falseextra_checksignore_errorsfollow_importswarn_no_returnstrict_equalitystrict_optionalwarn_return_anywarn_unreachabledisallow_any_exprenable_error_codeimplicit_optionalimplicit_reexportallow_redefinitioncheck_untyped_defsdisable_error_codestrict_concatenateenabled_error_codeslocal_partial_typeswarn_unused_ignoresdisabled_error_codesallow_untyped_globalsdisallow_any_explicitdisallow_any_genericsdisallow_untyped_defsdisallow_any_decorateddisallow_untyped_callsignore_missing_importsdisallow_any_unimporteddisallow_incomplete_defsdisallow_subclassing_anyfollow_imports_for_stubsdisallow_untyped_decoratorsr   PER_MODULE_OPTIONS>   bazelpluginsplatformold_type_inferencedisable_bytearray_promotiondisable_memoryview_promotionr   OPTIONS_AFFECTING_CACHETypeVarTupleTYPE_VAR_TUPLEUnpackUNPACKPreciseTupleTypesPRECISE_TUPLE_TYPESNewGenericSyntaxNEW_GENERIC_SYNTAXInlineTypedDictINLINE_TYPEDDICTINCOMPLETE_FEATURESCOMPLETE_FEATURESc                   @  s   e Zd ZdZd/ddZd0ddZd0d	d
Zd0ddZed0ddZ	d1ddZ
d2ddZd3ddZd4ddZd5ddZd6d d!Zd/d"d#Zd7d%d&Zd8d)d*Zd9d,d-Zd.S ):OptionszOptions collected from flags.returnNonec                 C  s&  d | _ tj| _tjd d | _tj| _t	
d}|dkr || _ntj| _d | _d | _d | _g | _i | _d| _d| _d| _d| _d| _d| _d| _d| _g | _d| _d| _d| _d| _d| _d| _g | _ d| _!d| _"d| _#d| _$d| _%d| _&d| _'d| _(d| _)d| _*d| _+d| _,d| _-d| _.d| _/d| _0d| _1d| _2d| _3d| _4d| _5d| _6d| _7d| _8g | _9g | _:g | _;t< | _=g | _>t< | _?d| _@d | _Ad | _Bd | _Cd | _Dd | _Ed | _Fd| _Gd| _HtIjJ| _Kd| _Ld| _Md| _Nd| _Od| _Pd| _Qd| _Rd| _Sd| _Td| _Ud| _Vd| _Wg | _Xi | _Yg | _Zt< | _[d| _\d| _]d| _^d| __d| _`d| _ad| _bg | _cd | _dd | _ed| _fd| _gd| _hd | _id| _jd| _kd| _ld| _md| _nd| _od| _pd| _qd| _rd| _sd| _tg | _ui | _vd| _wd| _xd| _yd | _zd| _{d| _|d| _}tIj~| _d| _d| _d| _d| _d| _d| _d| _d | _d S )	Nr   MACHDEP
emscriptenFnormalTglobalr   )_per_module_cacher   r   
build_typesysversion_infopython_version
executablepython_executable	sysconfigget_config_varr@   custom_typing_modulecustom_typeshed_dirabs_custom_typeshed_dir	mypy_pathreport_dirsno_silence_site_packagesno_site_packagesr7   !ignore_missing_imports_per_moduler   r;   namespace_packagesexplicit_package_basesexcluder3   r8   r%   r5   r2   r6   untyped_calls_excluder4   r9   r*   r<   r:   warn_incomplete_stubwarn_redundant_castsr    r#   r/   warn_unused_configsr   r"   show_error_contextcolor_outputerror_summaryr'   r(   r1   r)   r!   r,   r   r$   r   r   r+   setr0   r&   r-   scripts_are_modulesconfig_filequickstart_filefilespackagesmodules	junit_xmljunit_formatincrementalr   	CACHE_DIR	cache_dirsqlite_cacher   skip_version_checkskip_cache_mtime_checksfine_grained_incrementalcache_fine_graineduse_fine_grained_cachedebug_serializer   inspectionspreserve_astsinclude_docstringsr?   per_module_options_glob_optionsunused_configs	verbositypdbshow_tracebackraise_exceptionsdump_type_statsdump_inference_statsdump_build_statsenable_incomplete_featuretiming_statsline_checking_statssemantic_analysis_onlyuse_builtins_fixturestest_envshadow_fileshow_column_numbersshow_error_endhide_error_codesshow_error_code_linkspretty
dump_graph	dump_depslogical_depsr.   r>   export_typespackage_root	cache_map	fast_exitfast_module_lookupallow_empty_bodiestransform_sourceshow_absolute_pathinstall_typesnon_interactiveMANY_ERRORS_THRESHOLDmany_errors_thresholdrA   new_type_inferenceexport_ref_inforB   rC   force_uppercase_builtinsforce_union_syntaxoutput)selfrT   r   r   r   __init__U   s   

zOptions.__init__boolc                 C     | j dkr	| j S dS )N)   	   F)r\   r   r   r   r   r   use_lowercase_names     
zOptions.use_lowercase_namesc                 C  r   )N)r   
   F)r\   r   r   r   r   r   use_or_syntax  r   zOptions.use_or_syntaxc                 C  s
   | j dkS )N)r      )r\   r   r   r   r   use_star_unpack  s   
zOptions.use_star_unpackc                 C  s   dS )NTr   r   r   r   r   new_semantic_analyzer  s   zOptions.new_semantic_analyzerdict[str, object]c                 C  sT   t t| dd}ttD ]}t| |r|dkrt| |||< qdd | D }|S )z,Produce a comparable snapshot of this Option__dict__r   r   c                 S  s    i | ]\}}| d s||qS )_)
startswith).0kvr   r   r   
<dictcomp>       z$Options.snapshot.<locals>.<dictcomp>)dictgetattrr   rQ   hasattritems)r   dr   r   r   r   snapshot  s   zOptions.snapshotstrc                 C  s   dt |   dS )NzOptions())pprintpformatr   r   r   r   r   __repr__  s   zOptions.__repr__error_callbackCallable[[str], Any]c                C  s   t | j}t | j}t t }||B | }|r$|ddt|  |  jdd |D O  _|  jdd |D O  _|  j| j8  _d S )NzInvalid error code(s): z, c                 S     h | ]}t | qS r   r
   r   coder   r   r   	<setcomp>      z.Options.process_error_codes.<locals>.<setcomp>c                 S  r   r   r   r   r   r   r   r     r   )	rs   r+   r&   r
   keysjoinsortedr0   r-   )r   r   disabled_codesenabled_codesvalid_error_codesinvalid_codesr   r   r   process_error_codes  s   

zOptions.process_error_codeswarning_callbackc                C  sB   | j D ]}|ttB vr|d|  |tv r|d| d qd S )NzUnknown incomplete feature: z	Warning: z is already enabled by default)r   rO   rP   )r   r   r   featurer   r   r   process_incomplete_features  s   
z#Options.process_incomplete_featureschangesc                 C  s   t  }t|| dd | D ]
\}}t||| q|dr!d|_| j |_| j |_|j	D ]}t
| }|j| |j| q0|jD ]}t
| }|j| |j| qF|S )NT)	copy_dictr7   )rQ   r   r   setattrgetrh   r0   copyr-   r+   r
   adddiscardr&   )r   r   new_optionskeyvaluecode_strr   r   r   r   apply_changes  s"   


zOptions.apply_changesother_snapshotc                 C  s$   t  |   t  | kS )a  Compare options in a way that is stable for snapshot() -> apply_changes() roundtrip.

        This is needed because apply_changes() has non-trivial effects for some flags, so
        Options().apply_changes(options.snapshot()) may result in a (slightly) different object.
        )rQ   r   r   )r   r   r   r   r   compare_stable  s   zOptions.compare_stablec                 C  s   i | _ dd | j D }dd | j D }tdd |D }dd |D }|D ]}| j|| |f q)t|| _|| D ]}| 	|}|
| j| | j |< q@| j| d S )Nc                 S  s    g | ]}d |dd v r|qS *Nr   r   r   r   r   r   
<listcomp>  r   z2Options.build_per_module_cache.<locals>.<listcomp>c                 S  s    g | ]}d |dd vr|qS r   r   r   r   r   r   r     r   c                 s  s    | ]
}| d r|V  qdS ).*Nendswithr   r   r   r   	<genexpr>  s    z1Options.build_per_module_cache.<locals>.<genexpr>c                 S  s   g | ]	}| d s|qS )r   r   r   r   r   r   r     s    )rX   r   r   r   r   appendcompile_globrs   r   clone_for_moduler   update)r   unstructured_glob_keysstructured_keys	wildcardsconcreteglobr   optionsr   r   r   build_per_module_cache  s   

zOptions.build_per_module_cachemodulec                 C  s   | j du r	|   | j dusJ || j v r | j| | j | S | }|d}tt|ddD ] }d|d| dg }|| j v rO| j| | j | } nq/|dsp| j	D ]\}}|
|ro| j| || j| }qX|S )zCreate an Options object that incorporates per-module options.

        NOTE: Once this method is called all Options objects should be
        considered read-only, else the caching might be incorrect.
        N.r   r   r   r   )rX   r	  r   r   splitrangelenr   r   r   matchr   r   )r   r
  r  pathir   patternr   r   r   r    s,   







zOptions.clone_for_modulesPattern[str]c                 C  sf   | d}|d dkrt|d nd}|dd  D ]}||dkr(td| nd7 }qt|d S )Nr  r   r   r   r   z(\..*)?z\Z)r  reescapecompile)r   r  partsexprpartr   r   r   r   :  s
   
 zOptions.compile_globMapping[str, object]c                 C  s>   i }t D ]}t| |}|dv rtdd |D }|||< q|S )N)r0   r-   c                 S  s   g | ]}|j qS r   )r   r   r   r   r   r   I  s    z:Options.select_options_affecting_cache.<locals>.<listcomp>)rD   r   r   )r   resultoptvalr   r   r   select_options_affecting_cacheD  s   

z&Options.select_options_affecting_cacheN)rR   rS   )rR   r   )rR   r   )rR   r   )r   r   rR   rS   )r   r   r   r   rR   rS   )r   r   rR   rQ   )r   r   rR   r   )r
  r   rR   rQ   )r  r   rR   r  )rR   r  )r   r   r   __doc__r   r   r   r   propertyr   r   r   r   r   r   r   r	  r  r   r  r   r   r   r   rQ   R   s(    
  
0










+
+
rQ   )!
__future__r   r   r  rZ   r_   typingr   r   r   r   r   mypyr   mypy.errorcodesr	   r
   	mypy.utilr   r   r   r=   r   rD   rF   rH   rJ   rL   rN   	frozensetrO   rP   rQ   r   r   r   r   <module>   s0    )	