
    io                   
   U d Z 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	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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mZm Z m!Z!m"Z"m#Z$m%Z%m&Z&m'Z' ddl(m)Z) dd	l*m+Z+m,Z,m-Z.m/Z0m1Z1m2Z2m3Z4m5Z6m7Z8m9Z9 ddl:Z;dd
l<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHm-Z-mIZImJZJm/Z/mKZKmLZLm3Z3mMZMm5Z5mNZNmOZOmPZPm7Z7mQZQmRZR ddlSmTZT ddlUmVZVmWZWmXZXmYZY ddlZm[Z[m\Z\ ddl]m^Z^ ddl_m`Z`maZambZbmcZc ddldmeZemfZfmgZg ddlhmiZi ddljmkZkmlZlmmZmmnZnmoZompZpmqZqmrZr ddlsmtZt ddlumvZvmwZwmxZxmyZymzZzm{Z{m|Z| ddl}m~Z~ ddlmZ ddlmZ ddlmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZ erddlmZ ddl;mZ ddlmZmZ ddlmZ ddlmZ ddlmZ dd lmZmZmZ dd!lmZmZmZmZmZmZmZ dd"lumZ dd#l}mZ dd$lmZmZ dd%lmZmZmZ dd&lmZ dd'lmZmZ dd(lmZ dd)lmZmZ dd*lmZmZ dd+lmZmZ dd,lmZmZ dd-lmZ d.Zd/ed0<   h d1Zd/ed2<   d3Zd/ed4<   d.aeed5f         Zd6ed7<   d8Zd/ed9<    G d: d;          Z G d< d=          Z G d> d?          ZԐd<dDZ	 	 	 	 	 	 	 d=d>dVZ֐d?d\Zאd@d^ZؐdAd_ZِdBdaZ G db dce%          ZddZd/ede<   dfZd/edg<   dhZd/edi<   djZd/edk<   dlZd/edm<   dnZd/edo<   dCdtZdDdxZdEdzZdFd}ZdGdZ G d d          ZdHdZdZd/ed<   dZd/ed<   dZd/ed<   dIdZdJdZdKdZdZd/ed<   dLdZdMdZdNdZdOdZdPdZdQdZdRdZdSdZdSdZdTdUdZdVdZdWdZdXdZ	 dTdYdZdZdZd[dZd\d̈́Z d]dЄZd^dӄZ	  G dԄ dզ          Z G dք dאe          Ze' G d؄ d5                      Z	 	 	 	 	 d_d`dZdadZdbdZ	dcdZ
dddZdedZdfdZdgdZdhdZdidZdjdZ G d d          ZdkdZdkdZdldmdZ	 	 dndodZdpdZdqdZdrd ZdsdZefdtdZdudZ	 dldvd
ZdwdZdxdZdydZ dzdZ!d{dZ"d|dZ#d}dZ$d~dZ%dd"Z&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-<   d.Z,d$eʐd/<    G d0 d1en          Z- G d2 d3en          Z. G d4 d5en          Z/ G d6 d7en          Z0 G d8 d9en          Z1 G d: d;en          Z2dS (  a  Facilities to analyze entire programs, including imported modules.

Parse and analyze the source files of a program in the correct order
(based on file dependencies), and collect the results.

This module only directs a build, which is performed in multiple passes per
file.  The individual passes are implemented in separate modules.

The function build() is the main interface to this module.
    )annotationsN)CallableIteratorMappingSequenceSet)heappopheappush)dedent)
TYPE_CHECKINGAnyClassVarFinalNoReturnTextIO	TypeAlias	TypedDictcastfinal)	b64encode)
cache_version	read_boolread_intread_strread_tag
write_boolwrite_bytes	write_int	write_str	write_tag)CACHE_VERSIONDICT_STR_GENLIST_GENLITERAL_NONE	CacheMeta
ErrorTuple	JsonValue
ReadBufferTagWriteBuffer
read_bytesread_errorsr   read_int_listread_int_optr   read_str_listread_str_optr   write_errorsr   write_int_listwrite_int_optwrite_json_valuer   write_str_listwrite_str_opt)TypeChecker)WORKER_CONNECTION_TIMEOUTWORKER_DONE_TIMEOUTWORKER_START_INTERVALWORKER_START_TIMEOUT)OUTPUT_CHOICESErrorFormatter)	ErrorCode)CompileError	ErrorInfoErrorsreport_internal_error)prepare_sccsstrongly_connected_componentstopsort)TypeIndirectionVisitor)	BadStatus	IPCClientIPCException
IPCMessageread_statusready_to_readreceivesend)MessageBuilder)FileRawDataImport	ImportAll
ImportBase
ImportFromMypyFileSymbolTable)#OPTIONS_AFFECTING_CACHE_NO_PLATFORM) PossiblyUndefinedVariableVisitor)SemanticAnalyzer)SemanticAnalyzerPreAnalysis)DecodeErrordecode_python_encodingget_mypy_commentshash_digesthash_digest_bytesis_stub_package_fileis_sub_path_normabsis_typeshed_filemodule_prefixos_path_joinread_py_filetime_reftime_spent_usReports)
errorcodes)get_config_module_namesparse_mypy_comments)fixup_module)	free_tree)FileSystemCache)FilesystemMetadataStoreMetadataStoreSqliteMetadataStore)BuildSourceBuildSourceSetFindModuleCacheModuleNotFoundReasonModuleSearchResultSearchPathscompute_search_paths)
Expression)Options)load_from_rawparse)ChainedPluginPluginReportConfigContext)DefaultPlugin)LimitedVariableRenameVisitorVariableRenameVisitor)dump_type_stats)%is_module_from_legacy_bundled_packagestub_distribution_name)Typeinstance_cache)reset_global_state
type_state)
json_dumps
json_loads)__version__Fr   DEBUG_FINE_GRAINED>   collections.abcabcsystypestypingbuiltins	_typeshedcollectionsmypy_extensions_collections_abctyping_extensionsCORE_BUILTIN_MODULES   MAX_GC_FREEZE_CYCLESState
_TypeAliasGraphzUhttps://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modulesMODULE_RESOLUTION_URLc                  .    e Zd ZU dZdZded<   	 dddZdS )SCCzMA simple class that represents a strongly connected component (import cycle).r   ClassVar[int]
id_counterNidsset[str]scc_id
int | Nonedepslist[int] | NonereturnNonec                    |'t           j        | _        t           xj        dz  c_        n|| _        || _        |t	          |          nt	                      | _        t	                      | _        g | _        d| _        d S Nr   r   )	r   r   idmod_idssetr   not_ready_depsdirect_dependents	size_hint)selfr   r   r   s       I/root/projects/qq-shell/venv/lib64/python3.11/site-packages/mypy/build.py__init__zSCC.__init__   sq     >nDGNNaNNNDG+/+;c$iii	 ), -/      NN)r   r   r   r   r   r   r   r   )__name__
__module____qualname____doc__r   __annotations__r    r   r   r   r      sM         WW !J!!!! RV             r   r   c                      e Zd ZdZd
dZd	S )BuildResultaP  The result of a successful build.

    Attributes:
      manager: The build manager.
      files:   Dictionary from module name to related AST node.
      types:   Dictionary from parse tree node to its inferred type.
      used_cache: Whether the build took advantage of a pre-existing cache
      errors:  List of error messages.
    managerBuildManagergraphr   r   r   c                x    || _         || _        |j        | _        |j        | _        |j        | _        g | _        d S N)	r   r   modulesfiles	all_typesr   cache_enabled
used_cacheerrors)r   r   r   s      r   r   zBuildResult.__init__   s8    
_
&
!/!#r   N)r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r      s2         $ $ $ $ $ $r   r   c                  6    e Zd ZU dZded<   ddZddZddZdS )WorkerClientz3A simple class that represents a mypy build worker.rH   connstatus_filestroptions_dataenvMapping[str, str]r   r   c                    || _         t          j                            |          rt          j        |           t
          j        ddd| d| dg}t          j        ||          | _	        d S )Nz-mzmypy.build_workerz--status-file=z--options-data="")r   )
r   ospathisfileunlinkr   
executable
subprocessPopenproc)r   r   r   r   commands        r   r   zWorkerClient.__init__  sz    &7>>+&& 	#Ik""" N*[**.|...
 $W#666			r   c                   t          j                     t          z   }d }t          j                     |k     r	 t          | j                  }n2# t          $ r%}|}t          j        t                     Y d }~Xd }~ww xY w	 |d         |d         }}t          |t                    sJ d|             t          |t                    sJ d|             t          j        dk    r*|| j        j        k    sJ d| d| j        j                     t          |t                    | _        d S # t"          $ r}|}Y d }~nd }~ww xY wt%          d|           t          j        d	           d S )
Npidconnection_namez	Bad PID: zBad connection name: win32zPID mismatch: z vs z+Failed to establish connection with worker:   )timer;   rK   r   rG   sleepr:   
isinstanceintr   r   platformr   r   rH   r8   r   	Exceptionprintexit)r   end_timelast_exceptiondataexcr   r   s          r   connectzWorkerClient.connect  s   9;;!55+/ikkH$$"4#344   !$
0111'+E{D9J4K_!#s++>>->->->>>>!/377bb9bQ`9b9bbbb<7** $)-///1Z#1Z1Z49=1Z1Z///%o7PQQ	   !$ 	;^LLLs0   A 
A;A66A;?B(D) )
D?3D::D?c                   | j                                          	 | j                            d           n# t          j        $ r Y nw xY wt          j                            | j	                  rt          j
        | j	                   d S d S )Nr   )timeout)r   closer   waitr   TimeoutExpiredr   r   r   r   r   r   s    r   r   zWorkerClient.close0  s    		INN1N%%%%( 	 	 	D	7>>$*++ 	(Id&'''''	( 	(s   7 A	A	N)r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r     sa         ==OOO7 7 7 7   4( ( ( ( ( (r   r   msgr   r   r   c                (    t          d|  g          )Nzmypy: error: )r?   )r   s    r   build_errorr   ;  s    
---.
/
//r   sourceslist[BuildSource]optionsr{   alt_lib_path
str | Noneflush_errors4Callable[[str | None, list[str], bool], None] | NonefscacheFileSystemCache | NonestdoutTextIO | Nonestderrextra_pluginsSequence[Plugin] | None
worker_envMapping[str, str] | Nonec	                   g t          j                     dfd	}	|p|	}|pt          j        }|pt          j        }|pg }g }
|j        d
k    rt          j        |                                          }t          |          
                                fdt          |j                  D             }
t          |           }t                      }|                    |           |                                }|
D ]0}|                                 |j                            |           1	 t'          | ||||||||
	  	        }|_        ||
D ]?}	 t+          |j        t-          di i                      )# t.          t0          f$ r Y <w xY w|
D ]}|                                 S # t4          $ r'}|j         } |d|j        |           |_         d}~ww xY w# |
D ]?}	 t+          |j        t-          di i                      )# t.          t0          f$ r Y <w xY w|
D ]}|                                 w xY w)a  Analyze a program.

    A single call to build performs parsing, semantic analysis and optionally
    type checking for the program *and* all imported modules, recursively.

    Return BuildResult if successful or only non-blocking errors were found;
    otherwise raise CompileError.

    If a flush_errors callback is provided, all error messages will be
    passed to it and the errors and messages fields of BuildResult and
    CompileError (respectively) will be empty. Otherwise those fields will
    report any error messages.

    Args:
      sources: list of sources to build
      options: build options
      alt_lib_path: an additional directory for looking up library modules
        (takes precedence over other directories)
      flush_errors: optional function to flush errors after a file is processed
      fscache: optionally a file-system cacher
      worker_env: An environment to start parallel build workers (used for tests)
    filenamer   new_messages	list[str]
is_seriousboolr   r   c                2                         |           d S r   )extend)r  r  r  messagess      r   default_flush_errorsz#build.<locals>.default_flush_errorsg  s     	%%%%%r   r   c                R    g | ]#}t          d | dpt          j                  $S )z.mypy_worker.z.json)r   r   environ).0idxr   r
  s     r   
<listcomp>zbuild.<locals>.<listcomp>v  sJ     
 
 
 3333\:C[QSQ[\\
 
 
r   r   Nr   import_errorsmod_data)r  r   r  r  r  r  r   r   )r   resetr   r  r  num_workerspickledumpssnapshotr   decoderangeSourcesDataMessager*   writegetvaluer   r   r   build_innerr   rN   SccRequestMessageOSErrorrI   r   r?   
use_stdoutr  )r   r   r   r  r  r  r  r  r
  r  workerspickled_optionssources_messagebufsources_dataworkerresulteseriousr  r   s           `          @@r   buildr6  ?  s   F H & & & & & &
  7#7L!szF!szF!'RMGQ ,w'7'7'9'9:: 1188::
 
 
 
 
W011
 
 
 -W===mmc"""||~~ 	2 	2FNNK##L1111

 

 !  	 	FV["34r\^"_"_"_````\*    	 	FLLNNNN	    
 l"T1:w///
  	 	FV["34r\^"_"_"_````\*    	 	FLLNNNN	sZ   3F. %E==FF.
G8"GGG" "H?(%HH?H"	H?!H"	"H?-Callable[[str | None, list[str], bool], None]r   Sequence[Plugin]r-  list[WorkerClient]c	                	   t          j                    dk    rt          j        ddd           t	                      }	|pt                      }t          | ||	|          }
d }|j        rddlm	}  ||	|j                  }t          |           }|j        t          |fd          }|rd|_        t          ||||          \  }}|                    t           	           t#          |	|
t%          j                    |||t(          ||||j        d nt-          j        |j                  ||||
          }||_        |                                dk    r"|                    t7          |                     t9                       	 t;          | ||          }|j        st?          j                      |j!        tE          |j!        |           |j#        tI          |j#        |           tK          ||           tM          ||          tO          j'                    }|j(        )                                 |*                    tO          j'                    |z
             |+                    dtO          j'                    |j,        z
  t[          |j.                  |j/        0                                fz             |1                                 ||2                                 t$          j3        4                    |j5                  r(tm          |j5                   to          |j5                   t$          j3        4                    |j5                  rtq          |j5        |j9                   S S # tO          j'                    }|j(        )                                 |*                    tO          j'                    |z
             |+                    dtO          j'                    |j,        z
  t[          |j.                  |j/        0                                fz             |1                                 ||2                                 t$          j3        4                    |j5                  r(tm          |j5                   to          |j5                   t$          j3        4                    |j5                  rtq          |j5        |j9                   w w xY w)NCPythoni@    r   rh   c                $    t          |           S r   )re   )r   cached_reads    r   <lambda>zbuild_inner.<locals>.<lambda>  s    l46U6U r   )read_sourceT)error_callback)ignore_prefix
source_setreportsr   
version_idpluginplugins_snapshotr   error_formatterr  r  r  r  r   )cache_commit_timez=Build finished in %.3f seconds with %d modules, and %d errors):r   python_implementationgcset_thresholddefault_data_dirro   ry   report_dirsmypy.reportri   rt   readrA   global_watcherload_pluginsprocess_error_codesr   r   r   getcwdr   outputr<   getr-  	verbositytracereprr   dispatchfine_grained_incrementalr   reset_all_subtype_cachestiming_statsdump_timing_statsline_checking_statsdump_line_checking_statswarn_unused_configsr   r   	metastorecommit	add_statslog
start_timelenr   r   num_messages
dump_statsfinishr   isdir	cache_diradd_catch_all_gitignoreexclude_from_backupsrecord_missing_stub_packagesmissing_stub_packages)r   r   r   r  r  r  r  r  r-  data_dirsearch_pathsrD  ri   rC  r   rF  r#  r   r   t0r>  s                       @r   r)  r)    s    %''944 	R,,,!!H***G'(LQQLG 9'''''''(G$788((J,KG)U)U)U)UVVVF % $#GVV]KKFH {;;;
 ikk! ' 6N<Nw~<^<^!  G" GOad7mm$$$['622/ 	2/111+g2E:::&2$W%@%HHHG\2227E**Y[[  """DIKK",<===K	g00GO$$++--	
 	
 	
 	NN7==*++ 	4#G$5666 !23337==*++ 	[():G<YZZZZ	[% Y[[  """DIKK",<===K	g00GO$$++--	
 	
 	
 	NN7==*++ 	4#G$5666 !23337==*++ 	[():G<YZZZZ	[s   BM1 1E*Sr   c                      j         ro j        rj j        set           j         fd j                                        D                       } |d d                     j        |          gd           d S d S d S d S )Nc                &    g | ]}|j         v |S r   )unused_configs)r  globr   s     r   r  z'warn_unused_configs.<locals>.<listcomp>  s&    bbbd47KaCaCaTCaCaCar   z{}: note: unused section(s): {}F)ra  rv  non_interactiverk   config_fileper_module_optionskeysformat)r   r  unuseds   `  r   ra  ra    s     " 
w'= 
gF] 
(bbbbg8==??bbb
 
 	4;;G<OQWXXY[`	
 	
 	
 	
 	

 
 
 
 
 
r   c                 J    t           j                            t                    S )z0Returns directory containing typeshed directory.)r   r   dirname__file__r   r   r   rM  rM    s    7??8$$$r   r   c                    |j         rt          j                            |           S t          j                            |           S )zConvert path to absolute; but to relative in bazel mode.

    (Bazel's distributed cache doesn't like filesystem metadata to
    end up in output files.)
    )bazelr   r   relpathabspath)r   r   s     r   normpathr    s6     } %wt$$$wt$$$r   c                  $    e Zd ZU ded<   ded<   dS )	FgDepMetar   r   r   mtimeN)r   r   r   r   r   r   r   r  r  ,  s"         IIIJJJJJr   r     PRI_HIGH
   PRI_MED   PRI_LOW   PRI_MYPYr<  PRI_INDIRECTc   PRI_ALLimprS   toplevel_priorityr   c                Z    | j         st          S | j        rt          t          |          S |S )z,Compute import priority from an import node.)is_top_levelr  is_mypy_onlymaxr  )r  r  s     r   import_priorityr  <  s4     
 08.///r   r   rA   #tuple[list[Plugin], dict[str, str]]c                Z   ddl }i }| j        sg |fS t          | j        dd          dk    rddfd}g }                    | j        d|            | j        D ]I}d}d}	dt
          j                            |          v r|                    dd          \  }}|	                    d          rt          t
          j                            | j                  |          }t
          j                            |          s |d| d           t
          j                            t
          j                            |                    }	t
          j                            |          }
|
dd         }t          j                            d|	           nFt!          j        d|          r/t
          j                            |          }
 |d|
 d           n|}	 |                    |          }n(# t&          $ r} |d| d|            Y d}~nd}~ww xY w|	%t          j        d         |	k    sJ t          j        d= n,# |	%t          j        d         |	k    sJ t          j        d= w xY wt)          ||          s |d                    ||                     	  t-          ||          t.                    }n$# t&          $ r t1          d| d|            w xY wt3          |t4                    s |d                    ||                     t7          |t8                    s |d                    |                     	 |                     ||                      t=          |          ||<   "# t&          $ r t1          d|j         d|            w xY w||fS )zLoad all configured plugins.

    Return a list of all the loaded plugins from the config file.
    The second return value is a snapshot of versions/hashes of loaded user
    plugins (for cache validation).
    r   Nmypypluginsr   messager   r   r   c                b                         d|                                d           d S )Nr   F)r,  )reportraise_error)r  r   lines    r   plugin_errorz.load_plugins_from_config.<locals>.plugin_error\  s6    dAw'''e,,,,,r   rF  :.pyzCan't find plugin "r   z[\\/]zPlugin "z" does not have a .py extensionzError importing plugin "z": z5Plugin "{}" does not define entry point function "{}"z1Error calling the plugin(version) entry point of 
filezFType object expected as the return value of "plugin"; got {!r} (in {})zKReturn value of "plugin" must be a subclass of "mypy.plugin.Plugin" (in {})z&Error constructing plugin instance of )r  r   r   r   ) 	importlibry  find_config_file_line_numberset_filer  r   r   basenamersplitendswithrd   r  r   r  r   insertresearchimport_moduler   hasattrr|  getattrr   r   r   type
issubclassr   appendtake_module_snapshotr   )r   r   r  r  r#  r  custom_pluginsplugin_path	func_name
plugin_dirfnammodule_namemoduler   plugin_typer  s    `             @r   load_plugins_from_configr  H  sX    !H 8|'(;VYOODrzz- - - - - - - $&N
OOG'w777 = =	!%
"'"";////%0%7%7Q%?%?"K&& 	&&rww7J'K'K[YYK7>>+.. DBKBBBCCC )E)EFFJ7##K00Dss)KHOOAz****Yx-- 	&7##K00DLIDIIIJJJJ%K	 ,,[99FF 	K 	K 	KLIKIICIIJJJJJJJJ	K %x{j0000HQK %x{j0000HQKvy)) 	LGNN   	4'&)44[AAKK 	 	 	UkUUU\bcccc	 +t,, 	LX__   
 +v.. 	L &--  	!!++g"6"6777$8$@$@H[!! 	 	 	S;;OSSSZ`aaaa	 8##sH   !G76I7
HHIHI)I0#K!K#0N  &N&tuple[Plugin, dict[str, str]]c                    t          | ||          \  }}||z  }t          |           }|s||fS t          | ||gz             |fS )a  Load all configured plugins.

    Return a plugin that encapsulates all plugins chained together. Always
    at least include the default plugin (it's last in the chain).
    The second return value is a snapshot of versions/hashes of loaded user
    plugins (for cache validation).
    )r  r   r~   )r   r   r  r  r  r#  default_plugins          r   rR  rR    sc      8PPNHm#N*733N (x'' .N3C"CDDhNNr   r  types.ModuleTypec                   t          | d          rX| j        J t          | j        d          5 }t          |                                          }ddd           n# 1 swxY w Y   nd}t          | dd          }| d| S )zTake plugin module snapshot by recording its version and hash.

    We record _both_ hash and the version to detect more possible changes
    (e.g. if there is a change in modules imported by a plugin).
    r  Nrbunknownr   noner  )r  r  openr^   rP  r  )r  fdigestvers       r   r  r    s     vz"" ***&/4(( 	+A **F	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 
&-
0
0CFs   "AA!$A!sectionsetting_namec                   d}	 g }t          | d          5 }t          |          D ]\  }}|                                }|                    d          r8|                    d          r#|dd                                         }||k    }f|r0t          j        | d|          r|                    |dz              	 d	d	d	           n# 1 swxY w Y   t          |          dk    r|d
         S n# t          $ r Y nw xY wdS )zReturn the approximate location of setting_name within mypy config file.

    Return -1 if can't determine the line unambiguously.
    FzUTF-8)encoding[]r   r  z\s*=Nr   )
r  	enumeratestrip
startswithr  r  matchr  rg  r+  )	r   r  r  in_desired_sectionresultsr  ir  current_sections	            r   r  r    st   
 $))) 	*Q$Q<< * *4zz||??3'' *DMM#,>,> *&*1R4j&6&6&8&8O)8G)C&&' *BH5K5K5KT,R,R *NN1q5)))*	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* w<<11:    2s5   C4 B)CC4 CC4 CC4 4
D Dc                     e Zd ZdZ	 	 dbdcd#Zddd$Zded%Zdfd'Zdgd)Zdhd+Z	did0Z
djd2Zdkd4Z	 dldmd9Zdnd;Zdod>Zdpd?ZdqdAZdqdBZdqdCZdrdFZdsdHZdtdMZdldudOZdvdQZdvdRZdwdUZ	 dldddVdxd^Z	 dldd_dyd`Z	 dldd_dydaZdS )zr   aL	  This class holds shared state for building a mypy program.

    It is used to coordinate parsing, import processing, semantic
    analysis and type checking.  The actual build steps are carried
    out by dispatch().

    Attributes:
      data_dir:        Mypy data directory (contains stubs)
      search_paths:    SearchPaths instance indicating where to look for modules
      modules:         Mapping of module ID to MypyFile (shared by the passes)
      semantic_analyzer:
                       Semantic analyzer, pass 2
      all_types:       Map {Expression: Type} from all modules (enabled by export_types)
      options:         Build options
      missing_modules: Modules that could not be imported (or intentionally skipped)
      stale_modules:   Set of modules that needed to be rechecked (only used by tests)
      fg_deps_meta:    Metadata for fine-grained dependencies caches associated with modules
      fg_deps:         A fine-grained dependency map
      version_id:      The current mypy version (based on commit id when possible)
      plugin:          Active mypy plugin(s)
      plugins_snapshot:
                       Snapshot of currently active user plugins (versions and hashes)
      old_plugins_snapshot:
                       Plugins snapshot from previous incremental run (or None in
                       non-incremental mode and if cache was not found)
      errors:          Used for reporting all errors
      flush_errors:    A function for processing errors after each SCC
      cache_enabled:   Whether cache is being read. This is set based on options,
                       but is disabled if fine-grained cache loading fails
                       and after an initial fine-grained load. This doesn't
                       determine whether we write cache files or not.
      quickstart_state:
                       A cache of filename -> mtime/size/hash info used to avoid
                       needing to hash source files when using a cache with mismatching mtimes
      stats:           Dict with various instrumentation numbers, it is used
                       not only for debugging, but also required for correctness,
                       in particular to check consistency of the fine-grained dependency cache.
      fscache:         A file system cacher
      ast_cache:       AST cache to speed up mypy daemon
    NFrq  r   rr  rx   rB  rC  rt   rD  Reports | Noner   r{   rE  rF  r   rG  dict[str, str]r   rA   r  r7  r  ro   r  r   r  rH  ErrorFormatter | Noneparallel_workerr  r   r   c                T   i | _         || _        || _        t          j                    | _        || _        |
| _        | j                            |           || _        || _	        || _
        || _        || _        || _        i | _        i | _        i | _        i | _        i | _        t'          |t(                    st)          ||g          }|| _        | j        j        | _        | j        j        dk    | _        | j        j        dk    | _        t7                      | _        t;          | j        | j        | j        | j        | j        | j                  | _        i | _        tA                      | _!        t7                      | _"        t7                      | _#        || _$        |d uo|j%        }|j&        o|j'         p|j(        o| | _)        || _*        tW          j,                    | _-        t]          | j	        | j*        | j        | j
                  | _/        t`          D ]}|j1        r
| j/        2                    |d          }t'          |tf                    sti          d| dg          tk          |j6        |          sto          |          rtti          dtV          j8        9                    |           d	| d
d| dg          tu          ||          | _;        i | _<        | j        j=        t}          | j        j=                  | _<        i | _?        || _        |	| _@        t          |           | _B        |                                 dk    r/| C                    dt          jE        | j@                              t          || j                  | _G        g | _H        t7                      | _I        i | _J        d| _K        i | _L        i | _M        g | _N        g | _O        t7                      | _P        g | _Q        t7                      | _R        d| _S        || _T        i | _U        i | _V        i | _W        d S )Nr   r   )rC  T	fast_pathzFailed to find builtin module z, perhaps typeshed is broken?zmypy: "z" shadows library module "r   z1note: A user-defined top-level module with name "z" is not supportedzPlugins snapshot (fresh) r   )Xstatsr  r  r   rf  rq  r   set_ignore_prefixrH  rr  rC  rD  r   rE  r   
import_mapmissing_modulesfg_deps_metafg_depsr   r~   rF  dump_build_statsstats_enabledrW  logging_enabledtracing_enabledr   incomplete_namespacesrY   semantic_analyzerr   rF   indirection_detectorstale_modulesrechecked_modulesr  	reportersincrementalr[  use_fine_grained_cacher   r  r   rT  cwdru   find_module_cacher   use_builtins_fixturesfind_moduler   r?   rb   abs_custom_typeshed_dirr`   r   r  create_metastorerb  
shadow_mapshadow_filedictshadow_equivalence_maprG  read_plugins_snapshotold_plugins_snapshotrX  jsonr"  read_quickstart_filequickstart_stateprocessed_targetsrp  	ast_cachegc_freeze_cycles	scc_by_idscc_by_mod_id	top_order	scc_queue	done_sccsr-  free_workersqueue_orderr  import_optionstransitive_deps_cacheknown_partial_packages)r   rq  rr  rB  rC  rD  r   rE  rF  rG  r   r  r  r  r  rH  r  has_reportersr  r   s                       r   r   zBuildManager.__init__  s-   & &(
)++ %%m444.($$,./1/124
 -/&-00 	6"7VH55F "\:#|5:#|5: 03uu"!1L &KKO"
 "
 24$:$<$<!'*uu+.55(t+A0A "55W9W"!! 	
 9;;!0t|T\do"
 "
 "
 + 	 	F, )55f5MMDdC(( "[f[[[\     ?FF J^K K  Xbgood33XXvXXXbbbb   *'?CC +-<#/"4<#;<<DO=?# 0$9$$?$?!>>q  JJV4:d>S3T3TVVWWW 4Wdk J J 9;/2uu" GI ! *, .0 %' 68#&55+- '*ee !. 13BD"79###r   c                    | j         r_t          d           t          |                                                                           D ]\  }}t          |dz   d|            d S d S )NzStats:r  24)r  r   sortedstats_summaryitems)r   keyvalues      r   ri  zBuildManager.dump_stats  s     	0(OOO$T%7%7%9%9%?%?%A%ABB 0 0
Us..u..////	0 	00 0r   c                (    | j         o| j        j        S r   )r   r   r  r   s    r   r  z#BuildManager.use_fine_grained_cache  s    !Idl&IIr   r   c                4   | j         s|S t          || j                  }|| j        v }|sP| j                                         D ]6\  }}| j                            ||          r|| j        |<    nd | j        |<   7| j                            |          }|r|n|S r   )r  r  r   r  r  r  samefilerV  )r   r   previously_checkedsourceshadowr   s         r   maybe_swap_for_shadow_pathz'BuildManager.maybe_swap_for_shadow_path  s     	Kdl++!T%@@! 	="&/"7"7"9"9 = =<((v66 =8>D/5E8<D/55155d;;)3{{t3r   os.stat_result | Nonec                \    | j                             |                     |                    S r   )r  stat_or_noner#  r   r   s     r   get_statzBuildManager.get_stat  s&    |(()H)H)N)NOOOr   r   c                l    | j         j        rdS t          | j                            |                    S )zReturn a file's mtime; but 0 in bazel mode.

        (Bazel's distributed cache doesn't like filesystem metadata to
        end up in output files.)
        r   )r   r  r   rb  getmtimer'  s     r   r*  zBuildManager.getmtime  s4     < 	61t~..t44555r   r  rU   r  ImportFrom | ImportAllc                   |j         }|j        }|dk    r|j        S t          j                            |j                                      d          r|dz  }|dk    r1d                    |                    d          d|                    }|j        r|dz   |j        z   n|}|sH| j	        
                    |j        |j        | j                   |                     |j        dd           |S )	z)Function to correct for relative imports.r   z	__init__.r   .Nz2No parent module -- cannot perform relative importTblocker)fullnamerelativer   r   r   r  r  joinsplitr   r  namer   errorr  )r   r  r  file_idrelnew_ids         r   correct_rel_impzBuildManager.correct_rel_imp  s    -l!886M7DI&&11+>> 	1HC!88hhw}}S11%C4%899G+.6>3''w 	K  DIt|DDDJJNX\     r   list[tuple[int, str, int]]c           	     N   g }|j         D ]}|j        st          |t                    rt	          |t
                    }t	          |t                    }|j        D ]\  }}|                    |||j	        f           |
                    d          dd         }g }	|D ]G}
|	                    |
           |                    |d                    |	          |j	        f           Ht          |t                    r|                     ||          }d}t	          |t
                    }|j        D ]B\  }}|dz   |z   }|                     |          r|                    |||j	        f           @d}Ct	          ||st           nt                    }|                    |||j	        f           t          |t"                    rFt	          |t                     }|                    ||                     ||          |j	        f           |                    d            |S )a  Find all reachable import statements in a file.

        Return list of tuples (priority, module id, import line number)
        for all modules imported in file; lower numbers == higher priority.

        Can generate blocking errors on bogus relative imports.
        r-  Nr  TFc                :    | d                              d           S )Nr   r-  )countxs    r   r?  z;BuildManager.all_imported_modules_in_file.<locals>.<lambda>  s    !

3/ r   r  )importsis_unreachabler   rQ   r  r  r  r   r  r  r3  r2  rT   r9  names	is_moduler  rR   sort)r   r  resr  priancestor_prir   _ancestor_parts	ancestorspartcur_idall_are_submodulesr4  __sub_ids                   r   all_imported_modules_in_filez)BuildManager.all_imported_modules_in_file  sG    +-< !	Q !	QC%  Qc6** Q)#w77C#23#@#@L!$ V VA

CSX#6777)+#ss);$&	$2 V VD%,,T222JJchhy6I6I38'TUUUUV	V  Z00 Q!11$<<F)-&)#w77C$'I 7 7b!'#!4>>&11 7JJVSX'>????16.. *#?Q/^xxW^__CJJVSX67777Y// Q)#x88CJJT%9%9$%D%DchOPPP 	//000
r   r   c                &    t          ||           duS )z>Is there a file in the file system corresponding to module id?Nfind_module_simple)r   r   s     r   rD  zBuildManager.is_module  s    !"d++477r   r!  ignore_errorsraw_dataFileRawData | Nonec                b   d}| j         r| j                            |          rd}t          j                    }|r| j        j                            |           |rt          |||| j        |          }	nt          |||| j        ||          }	||	_	        | 
                    dt          |	j                   t          |	j                  t          j                    |z
             | j                                        r.|                     d           | j                                         |	S )zoParse the source of a file with the given name.

        Raise CompileError if there is a parse error.
        FT)r   imports_onlyr   )files_parsedmodules_parsedstubs_parsed
parse_timezBailing due to parse errors)r-  r  existsr   r   ignored_filesaddr|   r}   	_fullnamerd  r   is_stubis_blockersre  r  )
r   r   r   r!  rU  r   rV  rY  rs  trees
             r   
parse_filezBuildManager.parse_file#  s.    < 	 DL//55 	 LY[[ 	0K%))$/// 	d r8T['JJDDr4;VbcccD4</00T\**y{{R'	 	 	
 	
 	
 ;""$$ 	&HH2333K##%%%r   dict[str, set[str]]c                D   t          j                     }|| j        v r9t          | j                            | j        |         d                             }ni }d |                                D             }|                     t          j                     |z
             |S )Nr   c                4    i | ]\  }}|t          |          S r   )r   r  kvs      r   
<dictcomp>z7BuildManager.load_fine_grained_deps.<locals>.<dictcomp>P  s$    222TQq#a&&222r   load_fg_deps_time)r   r  r   rb  rP  r  rd  )r   r   rs  r   vals        r   load_fine_grained_depsz#BuildManager.load_fine_grained_depsI  s    Y[["""dn11$2CB2G2OPPQQDDD22TZZ\\222r)9:::
r   type_mapdict[Expression, Type]c                    | j         >| j                            |          r&| j                             || j        ||           d S d S d S r   )rD  rC  	is_sourcer  r   )r   r  rq  r   s       r   report_filezBuildManager.report_fileT  sS     <#(A(A$(G(G#LdDL(GDDDDD $###r   c                    | j         j        S r   )r   rW  r   s    r   rW  zBuildManager.verbosityZ  s    |%%r   r  c                    |                                  dk    rH|rt          dg|R d| j        i nt          | j                   | j                                         d S d S )Nr   zLOG: r  r  rW  r   r  flushr   r  s     r   re  zBuildManager.log]  sw    >>q   (g::::dk::::4;''''K ! r   c                    |                                  dk    r | j        dg|R   d S t          j        j        rD|rt          |d| j        i nt          | j                   | j                                         d S d S )Nr   zfine-grained:r  r  )rW  re  r  r6  r   r   r  ry  rz  s     r   log_fine_grainedzBuildManager.log_fine_grainede  s    >>q  DH_/w//////Z* 	  (w1T[11114;''''K	  	 r   c                    |                                  dk    r0t          dg|R d| j        i | j                                         d S d S )Nr   zTRACE:r  rx  rz  s     r   rX  zBuildManager.tracep  sY    >>q  (7W7774;777K ! r   kwdsr   c                    |                                 D ].\  }}|| j        v r| j        |xx         |z  cc<   $|| j        |<   /d S r   )r  r  )r   r~  r  r  s       r   rd  zBuildManager.add_statsu  s[    **,, 	( 	(JCdj  
35("'
3		( 	(r   Mapping[str, object]c                    | j         S r   )r  r   s    r   r  zBuildManager.stats_summary|  s
    zr   r   r   sccs	list[SCC]c                    | j         r|                     ||           dS | j                            d |D                        dS )zISubmit a stale SCC for processing in current process or parallel workers.c                    g | ]}d d |fS r   r   r  sccs     r   r  z'BuildManager.submit.<locals>.<listcomp>  s    "?"?"?3Aq#;"?"?"?r   N)r-  submit_to_workersr  r  )r   r   r  s      r   submitzBuildManager.submit  sT    < 	A""5$/////N!!"?"?$"?"?"?@@@@@r   list[SCC] | Nonec           	         |8|D ]5}t           j        |j          j        |f            xj        dz  c_        6 j        r j        r j                                        }t           j                  \  }}} fd|j        D             }t           j	        |         j
        t          |j        |fd|j        D                                   j        r j        d S d S d S d S )Nr   c                l    i | ]0}|         j         xj        j        v |j        j                 1S r   )xpathr   recorded)r  mod_idr   r   r   s     r   rl  z2BuildManager.submit_to_workers.<locals>.<dictcomp>  sK       !&M//DDK4HHH ,T2HHHr   c                v    i | ]5}||                                          |         j        xrj        nd f6S r   )suppressed_deps_optsrd  rV  )r  r  r   rd  s     r   rl  z2BuildManager.submit_to_workers.<locals>.<dictcomp>  s_     	 	 	 #  "&M>>@@6;Fm6H.HdSDMMt!	 	 	r   r  )r
   r  r   r  r  popr	   r   rN   r-  r   r*  r   )	r   r   r  r  r  rI  r  r   rd  s	   ``     @@r   r  zBuildManager.submit_to_workers  sk    & &3=.$:JC)PQQQ  A%   n 	!2 	#''))C//IAq#     !k  M
 S!&!6"/	 	 	 	 	 '*k	 	 	     n 	!2 	 	 	 	 	 	 	 	 	r   8tuple[list[SCC], bool, dict[str, tuple[str, list[str]]]]c                    | j         r|                     |          S | j        sg di fS | j                            d          \  }}}t	          |||            |gt          | j                  i fS )a  Wait for a stale SCC processing to finish.

        Return a tuple three items:
          * processed SCCs
          * whether we have more in the queue
          * new interface hash and list of errors for each module
        The last item is only used for parallel processing.
        Fr   )r-  wait_for_done_workersr  r  process_stale_sccr  )r   r   rI  next_sccs       r   wait_for_donezBuildManager.wait_for_done  s~     < 	5--e444~ 	!ub= ++A..1h%4000z4//33r   c                   | j         s/t          | j                  t          | j                  k    rg di fS g }i }t	          d | j        D             t
                    D ]}t                              t          | j        |         j	                            }| j        
                    |           |j        }|j        |j        |j        J |                    |j                   |                    | j        |                    |                     |           |t%          | j                   p)t          | j                  t          | j                  k     |fS )NFc                    g | ]	}|j         
S r   )r   )r  ws     r   r  z6BuildManager.wait_for_done_workers.<locals>.<listcomp>  s    !?!?!?Q!&!?!?!?r   )r  rg  r  r-  rL   r9   SccResponseMessagerP  rM   r   r`  r   r/  r3  updater  r  r  r  )r   r   r  r  r  r   r   s          r   r  z"BuildManager.wait_for_done_workers  sQ    ~ 	!#d&7"8"8C<M<M"M"Mub= 	 !?!?$,!?!?!?ATUU 	5 	5C%**74<3D3I+J+JKKD!!#&&&[F|'l";***NN4;'''T^F34444u%%%  NC(9$:$:S=N=N$N
 	
r   from_scc_id	to_scc_idc                   ||f}| j                             |          x}|S | j        |         j        }t	                      }|rt	                      }|D ]l}|                    |           ||k    rd| j         |<    dS | j                             ||f          x}rd| j         |<    dS ||| j        |         j        z  }m|}|d| j         |<   |D ]}d| j         ||f<   dS )z9Check if one SCC is a (transitive) dependency of another.NTF)r  rV  r  r   r   r`  )	r   r  r  edgecachedtodoseenmoredeps	            r   is_transitive_scc_depz"BuildManager.is_transitive_scc_dep  s2   Y'044T:::FGM~k*/uu 	55D  	5 	5)##7;D.t444!7;;S)<LMMM6 57;D.t444^DN3/44DD  	 ,1"4( 	A 	AC <AD&Y'788ur   r/  	only_oncer  r   r   codeErrorCode | Noner/  r  c               X    |dx}}nd}| j                             ||||||           d S )Nr  r   r  r   r  )r   r  r   r  r/  r  columns          r   r5  zBuildManager.error  sC     <D66F4dGyYYYYYr   r  c               X    |dx}}nd}| j                             ||||d|           d S )Nr  r   note)severityr  r  )r   r  r   r  r  r  s         r   r  zBuildManager.note  sC     <D66F4dVyYYYYYr   c                   t          |                    d                                                    D ]}|                     ||||           d S )Nr  r  )r   lstrip
splitlinesr  )r   r  r   r  r  msg_lines         r   note_multilinezBuildManager.note_multiline  s^     szz$//00;;== 	A 	AHIIdHdiI@@@@	A 	Ar   NF)"rq  r   rr  rx   rB  r   rC  rt   rD  r  r   r{   rE  r   rF  r   rG  r  r   rA   r  r7  r  ro   r  r   r  r   rH  r  r  r  r   r   r   r   r  )r   r   r   r   )r   r   r   r$  )r   r   r   r   )r  rU   r  r+  r   r   )r  rU   r   r:  )r   r   r   r  r   )r   r   r   r   r!  r   rU  r  r   r{   rV  rW  r   rU   )r   r   r   rf  )r  rU   rq  rr  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  r/  r  r  r  r   r   )
r  r   r   r   r  r  r  r  r   r   )r   r   r   r   r   ri  r  r#  r(  r*  r9  rQ  rD  re  rp  ru  rW  re  r|  rX  rd  r  r  r  r  r  r  r5  r  r  r   r   r   r   r     s       ' 'r 26 %#`: `: `: `: `:D0 0 0 0J J J J4 4 4 4$P P P P	6 	6 	6 	6   (3 3 3 3j8 8 8 8 (,$ $ $ $ $L	 	 	 	E E E E& & & &       	  	  	  	        
( ( ( (   A A A A    >4 4 4 4&
 
 
 
0   B "&	Z Z Z Z Z Z Z  DHZ^cZ Z Z Z Z Z DHA^cA A A A A A A Ar   r   r?  rf  bytesc                X    t          d |                                 D                       S )Nc                4    i | ]\  }}|t          |          S r   )listri  s      r   rl  z deps_to_json.<locals>.<dictcomp>  s$    888daq$q''888r   )r   r  r>  s    r   deps_to_jsonr    s'    88aggii888999r   z@deps.meta.jsonDEPS_META_FILEz@root.deps.jsonDEPS_ROOT_FILEz@rootFAKE_ROOT_MODULErdepsdict[str, dict[str, set[str]]]r   r   c                   |j         }d}|j                                        }| D ]}|t          k    r&t	          |||         j        |j                  \  }}}nt          }|sJ |                    d|           |j         	                    |t          | |                             s|                    d|            d}||                    |          d||<   i }	|                                D ]/\  }}
|
j        r|
j        }n|
j        r|
j        j        }nd}||	|<   0|	|d}|	                    t           t#          |                    s|                    dt                       d}|rM|j                            t)          |j                  d	|j                   |                    d	d
d           d	S d	S )a  Write cache files for fine-grained dependencies.

    Serialize fine-grained dependencies map for fine-grained mode.

    Dependencies on some module 'm' is stored in the dependency cache
    file m.deps.json.  This entails some spooky action at a distance:
    if module 'n' depends on 'm', that produces entries in m.deps.json.
    When there is a dependency on a module that does not exist in the
    build, it is stored with its first existing parent module. If no
    such module exists, it is stored with the fake module FAKE_ROOT_MODULE.

    This means that the validity of the fine-grained dependency caches
    are a global property, so we store validity checking information for
    fine-grained dependencies in a global cache file:
     * We take a snapshot of current sources to later check consistency
       between the fine-grained dependency cache and module cache metadata
     * We store the mtime of all the dependency files to verify they
       haven't changed
    FzWriting deps cachez*Error writing fine-grained deps JSON file T)r   r   )r#  	deps_metaz/Error writing fine-grained deps meta JSON file Nz-Error writing fine-grained dependencies cacher.  )rb  r  copyr  get_cache_namesr  r   r  re  r'  r  r*  r  source_hashmetahashr  r   r   r  _cache_dir_prefixr5  )r  r   r   rb  r5  r  r   rI  	deps_jsonmeta_snapshotstr  r  s                r   write_deps_cacher    s   , !IE',,..L Y Y!!!-b%)/7?SSOAq))&I()444 &&y,uRy2I2IJJ 	YKKPYPPQQQEE(1G<L<LY<W<WXXL$&M++-- ! !B > 	>DDw w| b%LAAD??>:d+;+;<< VnVVWWW [ 1'/ B BD'/ZZZdKUYZZZZZ[ [r   r   c                v   ddl m} d |                                D             }|                                 D ]\  }}t          | ||                    }|r||         j        st
          }|                    |i           }|                    |t                                                    |           |S )aS  Splits fine-grained dependencies based on the module of the trigger.

    Returns a dictionary from module ids to all dependencies on that
    module. Dependencies not associated with a module in the build will be
    associated with the nearest parent module that is in the build, or the
    fake module FAKE_ROOT_MODULE if none are.
    r   )trigger_to_targetc                (    i | ]\  }}|j         |i S r   )rd  r  r   r  s      r   rl  zinvert_deps.<locals>.<dictcomp>j  s'    ,[,[,[BSUSZ,[R,[,[,[r   )	mypy.server.targetr  r  rc   rd  r  
setdefaultr   r  )r   r   r  r  triggertargetsr  	mod_rdepss           r   invert_depsr  \  s     544444
 -\,[%++--,[,[,[E JJLL = =u&7&7&@&@AA 	&U6]/ 	&%F$$VR00	Wcee,,33G<<<<Lr   c                    ddl m} t          | j        |          }|                                D ]&\  }}|                     |          } |||           '|S )a&  Generate fine-grained dependencies into a form suitable for serializing.

    This does a couple things:
    1. Splits fine-grained deps based on the module of the trigger
    2. For each module we generated fine-grained deps for, load any previous
       deps and merge them in.

    Returns a dictionary from module ids to all dependencies on that
    module. Dependencies not associated with a module in the build will be
    associated with the nearest parent module that is in the build, or the
    fake module FAKE_ROOT_MODULE if none are.
    r   merge_dependencies)mypy.server.depsr  r  r  r  rp  )r   r   r  r  r  mdepsold_depss          r   generate_deps_for_cacher  v  st     433333 //E
  , ,11&998U++++Lr   z@plugins_snapshot.jsonPLUGIN_SNAPSHOT_FILEc                @   t          | j                  }| j                            t          |          sg| j        j        t          j        k    rO| j	        
                    t          | j                  d| j                   |                     ddd           dS dS dS )zBWrite snapshot of versions and hashes of currently active plugins.NzError writing plugins snapshotTr.  )r   rG  rb  r'  r  r   rl  r   devnullr   r  r  r5  r   r#  s     r   write_plugins_snapshotr    s    '233H##$8(CCLO%33 1'/ B BD'/ZZZd<dKKKKKL L33r   dict[str, str] | Nonec                    t          t          | dd          }|dS t          |t                    s'|                     dt          |                      dS |S )zIRead cached snapshot of versions and hashes of plugins from previous run.zPlugins snapshot (cached) z!Could not load plugins snapshot: log_success	log_errorNz6Could not load plugins snapshot: cache is not a dict: )_load_json_filer  r   r  re  r  r  s     r   r  r    sm    05	  H th%% ]TRZ^^]]^^^tOr   (dict[str, tuple[float, int, str]] | Nonec                ~   d }| j         ri }	 t          | j         d          5 }t          |                                          }d d d            n# 1 swxY w Y   i }|                                D ]\  }\  }}}|||f||<   n9# t
          $ r,}	t          dt          |	           d|           Y d }	~	nd }	~	ww xY w|S )Nr  z)Warning: Failed to load quickstart file: r  r  )quickstart_filer  r   rP  r  r   r   r   )
r   r  
quickstartraw_quickstartr  r  r?  yzr4  s
             r   r  r    s>    <@J W *,	Wg-t44 6!+AFFHH!5!56 6 6 6 6 6 6 6 6 6 6 6 6 6 6 J#1#7#7#9#9 - -iq!Q$%q!9
4  - 	W 	W 	WHc!ffHHHvVVVVVVVVV	Ws:   B "AB AB A+B 
B:"B55B:dict[str, FgDepMeta] | Nonec                   t          t          | dd          }|dS |d         d |                                D             t                                                    t                                                    z  }t          fd|D                       r|                     d           dS |d	         }t          |t                    sJ | j	        j
        ss|                                D ]^}	 |                     |d
                   |d         k    }n# t          $ r d}Y nw xY w|s!|                     d|d
                      dS _|S )zRead and validate the fine-grained dependencies cache.

    See the write_deps_cache documentation for more information on
    the details of the cache.

    Returns None if the cache was invalid in some way.
    z
Deps meta z1Could not load fine-grained dependency metadata: r  Nr#  c                2    i | ]\  }}|j         ||j         S r   )meta_source_hashr  s      r   rl  z#read_deps_cache.<locals>.<dictcomp>  s0       $*Br?R?^B?^?^?^r   c              3  <   K   | ]}|         |         k    V  d S r   r   )r  r   current_meta_snapshotr  s     r   	<genexpr>z"read_deps_cache.<locals>.<genexpr>  s3      
K
Kb= 5b 99
K
K
K
K
K
Kr   z6Fine-grained dependencies cache inconsistent, ignoringr  r   r  Fz,Invalid or missing fine-grained deps cache: )r  r  r  r   r{  anyre  r   r  r   skip_cache_mtime_checksvaluesr*  FileNotFoundError)	r   r   r  commonmodule_deps_metasr  matchedr  r  s	          @@r   read_deps_cacher    s      E	  I tj)M .3kkmm   ##%%&&-B-G-G-I-I)J)JJF

K
K
K
K
KF
K
K
KKK LMMMt!+.'.....?2 %,,.. 	 	D !**4<88DMI$        Y4PV<YYZZZtt s   =%D##D21D2r  log_error_fmtr   bytes | Nonec                n   |j         rt          j                    }	 |j                            |           }nM# t          $ r@ |j        r5|r|                    |          | z   }n|| z   }|                    |           Y d S w xY w|j         r*|                    t          j                    |z
             |S )Nmetastore_read_time)	r  r   rb  rP  r+  r  r|  re  rd  )r  r   r  r   rs  r   r  s          r   _load_ff_filer	    s      Y[[	 %%d++   " 	! /'..r22T9'$.KK   tt  @dikkB.>???Ks   7 AB Br  r  dict[str, Any] | Nonec                T   t          j                     }	 |j                            |           }n)# t          $ r |                    || z              Y dS w xY w|                    t          j                     |z
             |                                dk    r<|                    ||                                	                                z              	 t          j                     }t          |          }|                    t          j                     |z
             t          |t                    sJ |S # t          j        $ r[ |j                            | d|j                   |                    dd                    |j        j                  d           Y dS w xY w)	z1A simple helper to read a JSON file with logging.Nr  r   )data_file_load_timezpError reading JSON file; you likely have a bad cache.
Try removing the {cache_dir} directory and run mypy again.rl  Tr.  )r   rb  rP  r+  re  rd  rW  rX  rstripr$  r   r   r  r  JSONDecodeErrorr   r  r   r5  r|  rl  )r  r   r  r  rs  r   t1r3  s           r   r  r    s    
B %%d++   I$%%%tt $)++*:;;;akDKKMM$8$8$:$::;;;Y[[D!!dikkB.>??? &$'''''  
 
 
dGO<<<# $*6GO4M6#N#N 	 	
 	
 	
 tt
s#   0 "AAAD= =A&F'&F'c                n    | j         rt          j        S | j        }| j        }t          |d|z            }|S )z5Get current cache directory (or file if id is given).z%d.%d)r  r   curdirrl  python_versionrd   )r   rl  	pyversionbases       r   r  r  '  s=    } y!I&I	7Y#677DKr   
target_dirc                    t          | d          }	 t          |d          5 }t          d|           t          d|           ddd           dS # 1 swxY w Y   dS # t          $ r Y dS w xY w)zdAdd catch-all .gitignore to an existing directory.

    No-op if the .gitignore already exists.
    z
.gitignorer?  z# Automatically created by mypyr  *N)rd   r  r   FileExistsError)r  	gitignorer  s      r   rm  rm  2  s    
 Z66I)S!! 	Q3!<<<<#A	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	    s4   A #AA AA AA 
A-,A-c                    t          | d          }	 t          |d          5 }|                    d           ddd           dS # 1 swxY w Y   dS # t          $ r Y dS w xY w)zExclude the directory from various archives and backups supporting CACHEDIR.TAG.

    If the CACHEDIR.TAG file exists the function is a no-op.
    zCACHEDIR.TAGr?  zSignature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag automatically created by mypy.
# For information about cache directory tags see https://bford.info/cachedir/
N)rd   r  r'  r  )r  cachedir_tagr  s      r   rn  rn  @  s    
  
N;;L,$$ 	GG    	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
    s3   A AA A		A A	A 
A A r  r  rq   c                    | j         r,| j        dk    p|}t          t          |           |          }nt	          t          |                     }|S )z&Create the appropriate metadata store.r   )sync_off)sqlite_cacher   rr   r  rp   )r   r  r  mdss       r   r  r  P  s[     B &*=o01B71K1KV^___%&7&@&@AAJr   	meta_namec                d    |                      dd          }d|d<   d                    |          S )Nr-  r   maxspliterrr   )r  r2  )r!  partss     r   get_errors_namer'  \  s3    S1--EE!H88E??r   tuple[str, str, str | None]c                H   |j         r)|j                             t          ||                    }nd}|\t          |          }t          j                            |d         |          t          j                            |d         |          dfS t	          j        j        |                     d           }t          j        	                    |          
                    d          }|rt          |d          }d}|j        r|dz   }|j        rd}d	}	nd
}d}	||	z   ||z   |fS )a  Return the file names for the cache files.

    Args:
      id: module ID
      path: module path
      options: build options

    Returns:
      A tuple with the file names to be used for the meta file, the
      data file, and the fine-grained deps JSON, respectively.
    Nr   r   r-  __init__.pyr   z
.deps.jsonz.data.ffz.meta.ffz
.data.jsonz
.meta.json)	cache_maprV  r  r  r   r   r  r2  r3  r  r  rd   cache_fine_grainedfixed_format_cache)
r   r   r   pairrootprefix
is_packager  data_suffixmeta_suffixs
             r   r  r  c  s$      $$XdG%<%<== !))wtAw--rwtAw/M/MtSSW\288C==)F!!$''22=AAJ 2fj11I! *\)	! #  ""K+!5y@@r   dict[str, object]c                n   |j                             |                                           \  }}|j         j        r&d|i}t	          t
          |          D ]
\  }}|||<   |S t                      }t          |t          t          |                     |t          |                                          dS )zMake compact snapshot of options for a module.

    Separately store only the options we may compare individually, and take a hash
    of everything else. If --debug-cache is specified, fall back to full snapshot.
    r   )r   other_options)r   clone_for_moduleselect_options_affecting_cachedebug_cacheziprW   r*   r4   r   r'   r^   r(  )r   r   platform_optr  r3  r  ro  r0  s           r   options_snapshotr<    s     #?;;B??^^``L&" %/$>?HH 	 	HCF3KK
--CS$y&11222${3<<>>7R7RSSSr   skip_validation)tuple[CacheMeta | None, list[ErrorTuple]]c           
     	   t          | ||j                  \  }}}|j        r|                    d|  d|            |j        rt          j                    }|j        j        rt          ||d|           }nt          ||d|  dd|  d	          }|d
g fS |j        rt          j                    }	t          |t                    rs|d         t                      k    s|d         t          k    r|                    d|  d           d
g fS t          |dd
                   }
t          j        |
|          }nt          j        ||          }||                    d|  d           d
g fS |j        r4t          j                    }|                    ||z
  |	|z
  ||	z
             |r|g fS |j        |j        k    r)|j        j        s|                    d|  d           d
g fS t+          |j                  t+          |j                  z   }t+          |j                  |k    st+          |j                  |k    r|                    d|  d           d
g fS |j        }t5          | |          }|j        j        r|d         |d<   d|v r|d= ||k    r|                    d|  d           |j        j        dk    rt9          t;          |          t;          |          z            D ]~}|                    |          |                    |          k    rP|                    d                    ||                    |          |                    |                               d
g fS |j         r4|j!        r-|j!        |j         k    r|                    d|  d           d
g fS |j"        #                    tI          | |d                    }|j        j        stK          tM          |                    }|j'        |k    r|                    d|  d           d
g fS tQ          |          }|j        j        rt          ||d|           }nt          ||d|  dd|  d	          }|d
g fS t          |t                    rt          |          }
tS          |
          }nd |d          D             }|                    d!           ||fS )"al  Find cache data for a module.

    Args:
      id: module ID
      path: module path
      manager: the build manager (for pyversion, log/trace, and build options)
      skip_validation: if True skip any validation steps (used for parallel checking)

    Returns:
      A CacheMeta instance if the cache data was found and appears
      valid; otherwise None.
    zLooking for z at zCould not load cache for {}: )r  r   zMeta  zCould not load cache for z: r  Nr   r   Metadata abandoned for z: incompatible cache formatr   z: cannot deserialize data)load_meta_timeload_meta_load_timeload_meta_from_dict_timez: different mypy versionz: broken dependenciesr   r9  z: options differz    {}: {} != {}z: plugins differTis_checkz: plugin configuration differszCould not load errors for {}: zErrors zCould not load errors for c                ,    g | ]}t          |          S r   )tuple)r  r%  s     r   r  z#find_cache_meta.<locals>.<listcomp>  s    999CU3ZZ999r   error_lines)fresh_metas)*r  r   r  rX  r  r   r-  r	  r  r   r  r   r!   re  r(   r%   rP  deserializerd  rE  skip_version_checkrg  dependencies
suppressed	dep_prios	dep_linesr<  rW  r  r   rV  r|  r  rG  rF  report_config_datar   r   r   plugin_datar'  r,   )r   r   r   r=  	meta_file	data_filerI  rs  r  r  data_iomt2
total_depscached_optionscurrent_optionsr  rR  errors_filer   r4  s                        r   find_cache_metar\    s     .b$HHIy! :8R88Y88999 Y[[) 

w.MRT
 
 
 %8"888	
 
 
 |Rx Y[[$ 
3 7moo%%aM)A)AKKQ"QQQRRR8OT!""X&&N7I..!$	22yKbKKKLLLRx 
Y[[7RZ\_aZa 	 	
 	
 	
  "u 	|w)))'/2T)JbJJJKKKRxQ^$$s1<'8'88J
1;:%%Q[)9)9Z)G)GGbGGGHHHRx YN&r733O) A%4Z%@z"&&=)((BbBBBCCC?$))c.11C4H4HHII  !%%c**o.A.A#.F.FFFMM*11!3!3C!8!8/:M:Mc:R:R   
 Rx# (@ #w'CCCKKF"FFFGGG8O.334GD[_4`4`4`aaK?- : !K!8!899}##PbPPPQQQRx "),,K) 

0PUW
 
 
 !'"92999	
 
 
 ~Rx&%   :V$$  996-#8999!$$$a4Kr   r  CacheMeta | None
ignore_allc                   | |                     d|            dS | j        r|s|                     d| d           dS |j        rt          j                    }|j        j        }|
J d            |j        j        sl	 |                    | j                  }n*# t          $ r |                     d| d           Y dS w xY w|| j
        k    r|                     d| d           dS |rt          ||j                  }|                    |          }|dS t          j        |j                  s7t          j        |j                  s|                     d| d| d	           dS |j        r*|                    t          j                    |z
  
           |                                }	|j        }
|
| j        k    r"|s |	s|                     d| d| d           dS |rdnt+          |j                  }|sR|| j        k    s|| j        k    r;|j        ri||j        v r`|j        |         \  }}}t+          |          |k    r<||
k    r6|| j        k    r+|                     d| d|            || _        || _        | S t          j                    }	 t          j        |j                  rd}n|j                            |          }n# t          t:          t<          f$ r Y dS w xY w|                    t          j                    |z
             || j        k    r=|	r|                     d| d|            | S |                     d| d| d           dS |j        rt          j                    }|| _        || _        |
| _        t?          ||          | _        tA          |||j                  \  }}}|j!        r0|                     d"                    |||| j                             tG          | ||           |j        rAt          j                    }|                    t          j                    |z
  ||z
             | S |j!        r|                     d| d|            | S )a  Checks whether the cached AST of this module can be used.

    Returns:
      None, if the cached AST is unusable.
      Original meta, if mtime/size matched.
      Meta with mtime updated to match source file, if hash/size matched but mtime/path didn't.
    NzMetadata not found for rA  z : errors were previously ignoredz0Internal error: meta was provided without a pathz: failed to stat data_filez: data cache is modifiedz: file or directory z does not exist)validate_stat_timez: file z has different sizer   z#Metadata fresh (by quickstart) for r  )validate_hash_timezUsing stale metadata for z has different hashz1Updating mtime for {}: file {}, meta {}, mtime {})validate_update_timevalidate_munging_timezMetadata fresh for )$re  r^  r  r   r   r  r  r*  rT  r+  
data_mtimer  r(  statS_ISDIRst_modeS_ISREGrd  r  st_sizesizer   st_mtimer  r   r  r  r  r^   UnicodeDecodeErrorr[   r<  r  r  r|  write_cache_meta)r  r   r   r^  r   rs  r  rd  r  fine_grained_cacherj  r  qmtimeqsizeqhashr  rS  rI  r  s                      r   validate_metarr     s'    |2b22333t z RbRRRSSSt Y[[O!EO?2 		 ))$.99JJ 	 	 	KKP"PPPQQQ44	 ((KKN"NNNOOO4 /go..			$		B	zt<
## DL,D,D [b[[d[[[\\\t ?TY[[2-=>>> !7799:Dty/ARbRRRRRSSSt ,AAC,,E 3etz))TTY->-># 
	0H(H(H
 $+#;D#A FE56{{e##%49:L:LS"SSTSSTTT"
 	Y[[	|BJ'' @ %o99$??+[9 	 	 	44	TY[[2-=>>>$)##! III4IIJJJZbZZZZZ[[[t$ !Y[[DJDIDI+B88DL-b$HHOIq!& GNND)TZ   
 T7I666$ Y[[!!)-r)9QSVXQX "    K  =;";;T;;<<<Ks$    B #CC6K K,+K,textc                F    t          |                     d                    S )Nzutf-8)r^   encode)rs  s    r   compute_hashrv    s     t{{7++,,,r   rd  rU   rM  r  rN  r  imports_ignoreddict[int, list[str]]rO  	list[int]rP  old_interface_hashtrans_dep_hashr  *tuple[bytes, tuple[CacheMeta, str] | None]c           
     F   |j         }|j        j        }t          | ||j                  \  }}}|                    d|  d| d| d|            |r||_        |j                            t          | |d                    }|j        j	        r8t                      }|                    |           |                                }n.|                                }t          ||j        j                  }t!          |t          |          z             }|                    |          }|H|                    d|            ||fD ]'}	 t%          j        |           # t(          $ r Y $w xY w|dfS |	|k    r|                    d|  d           nK|                    d|  d	           |                    ||          s|                    d
|            |dfS 	 |                    |          }n-# t(          $ r  |                    d|d           |dfcY S w xY w|rdnt/          |j                  }|j        }|J t5          d"i d| d|d|d|d|d|d|d|d|d|dt7          | |          d|d|d|d|d|
d|j        d|d |d!g }|||ffS )#a  Write cache files for a module.

    Note that this mypy's behavior is still correct when any given
    write_cache() call is replaced with a no-op, so error handling
    code that bails without writing anything is okay.

    Args:
      id: module ID
      path: module path
      tree: the fully checked module data
      dependencies: module IDs on which this module depends
      suppressed: module IDs which were suppressed as dependencies
      dep_prios: priorities (parallel array to dependencies)
      dep_lines: import line locations (parallel array to dependencies)
      old_interface_hash: the hash from the previous version of the data cache file
      source_hash: the hash of the source code
      ignore_all: the ignore_all flag for this module
      manager: the build manager (for pyversion, log/trace)

    Returns:
      A tuple containing the interface hash and inner tuple with CacheMeta
      that should be written and path to cache file (inner tuple may be None,
      if the cache data could not be written).
    zWriting r@  FrE  NzCannot get stat for zInterface for z is unchangedz has changedzError writing cache data file zError in os.stat(z), skipping cache writer   r   r   r  rj  r  rM  rd  rT  rN  rw  r   r  rO  rP  interface_hashr{  rE  r^  rR  
dep_hashesr   )rb  r   r  r  re  r   rF  rQ  r   r-  r*   r'  r(  	serializer   r9  r_   r(  r   remover+  rX  r*  r   rk  ri  r%   r<  rE  )r   r   rd  rM  rN  r  rw  rO  rP  rz  r{  r  r^  r   rb  r  rS  rT  rI  rR  rU  
data_bytesr   r~  r  r  rd  r  rj  r  s                                 r   write_cacher    s   P !IO!E .b$HHIy!KK>2>>>>y>>9>>???  	.334GD[`4a4a4abbK ) C--

7%%''

~~go&ABB
&zJ{4K4K'KLLN 
		$		B	z1411222 #I. 	 	H	(####    t## ^++8r88899997r777888y*55 	( KKDDDEEE "4''$%%i00

 $ $ $L	LLLMMMt####$ ,AAC,,E:D """   2T e T	
 [ "\ : ) : ( !W--- 21 ) ) &~  &~!" %%#$ :%&  K'* 2+D. D),,,s$   	E
E+*E+G4 4'HHr%   rS  c                   |j         }|j        j        r[t                      }|                     |           t          t                      t          g          |                                z   }n.| 	                                }t          ||j        j                  }|                    ||          s|                    d|            d S d S )NzError writing cache meta file )rb  r   r-  r*   r'  r  r   r!   r(  r  r   r9  re  )r  r   rS  rb  rU  
meta_bytes	meta_dicts          r   rm  rm  :  s    !I) H--

7 MOO];<<w?O?O?Q?QQ

NN$$		7?+FGG
??9j11 B 	@Y@@AAAAA	B Br   rI  list[ErrorTuple]c                H   t          |           }|j        }|j        j        r3t	                      }t          ||           |                                }nt          d|i|j        j                  }|	                    ||          s|
                    d|            d S d S )NrI  zError writing errors file )r'  rb  r   r-  r*   r1   r(  r   r9  r'  re  )rS  rI  r   r[  rb  rU  r  s          r   write_errors_filer  M  s     "),,K!I) [--Wk***%%''

   <go>YZZ
??;
33 @>>>?????@ @r   c                  ,    e Zd ZU dZded<   dZded<   dS )SuppressionReasonr   r   	NOT_FOUNDr   SKIPPEDN)r   r   r   r  r   r  r   r   r   r  r    s4         IGr   r  c                  (    e Zd ZdZej        fddZdS )	ModuleNotFoundz=Control flow exception to signal that a module was not found.reasonr   r   r   c                    || _         d S r   r  )r   r  s     r   r   zModuleNotFound.__init__  s    r   N)r  r   r   r   )r   r   r   r   r  r  r   r   r   r   r  r    s9        GG%6%@       r   r  c                     e Zd ZU dZded<   dZded<   ded<   d	ed
<   dZded<   dZded<   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<   ded<   ded<   ded<   ded<   ded<   ded<   d ed!<   d"ed#<   dZd$ed%<   d&ed'<   dZd(Zd)ed*<   d(Zd)ed+<   d,ed-<   d.Zd/ed0<   dZd1ed2<   d.ZdZded3<   d4ed5<   ded6<   d7ed8<   e	 	 	 	 	 d~ddA            Z	 dddDZddGZeddI            ZddJZddKZddLZddMZddNZddOZ e!j"        dddS            Z#ddUZ$dddVZ%ddWZ&d.ddXdd[Z'dd\Z(dd]Z)dd^Z*dd_Z+ddaZ,ddbZ-ddcZ.dddZ/ddfZ0ddhZ1ddiZ2ddjZ3ddkZ4ddlZ5ddpZ6ddqZ7ddsZ8ddtZ9ddvZ:dddxZ;ddzZ<dd{Z=dd|Z>dd}Z?dS )r   zThe state for a module.

    The source is only used for the -c command line option; in that
    case path is None.  Otherwise, source is None and path isn't.
    r   r   r   r   order_counterr   orderr   r   Nr   r   r  r  r!  r  r  r]  r  zMypyFile | Nonerd  r  rM  r   dependencies_setrN  suppressed_setdict[str, int]
prioritiesdep_line_mapdict[str, bytes]r  r  rI  zlist[str] | NonerK  list[tuple[str, int]]import_contextr   r  r~  r{  r{   r   Fzlist[ErrorInfo]early_errorszTypeChecker | None_type_checkerrg   zdict[int, int]per_line_checking_time_nsr   rx  rw  caller_stateState | Nonecaller_lineancestor_forroot_sourcer  	temporaryr   c	           
        |s| s|s|
J d            t           xj        dz  c_        |r6|j                                        }	|	                    |j        |f           ng }	| pd} |j                            |           }
|
                                |j	        | <   d}|sO|M| J 	 t          || |
|||||          \  }}n$# t          $ r}|s|j        |j        | <    d }~ww xY w|dk    rd}n|rt          ||          r|sd}d }d}d }|r-|+|j        r$t!          | ||          \  }}||j        }|j        }|r||j                            |          rd	}|j        rt-          j                    }t/          || |||          }|j        r*|                    t-          j                    |z
  
           |rt3          |j                  }t3          |j                  }||z   }t9          |          t9          |j                  k    sJ d t=          ||j                  D             }t9          |          t9          |j                  k    sJ d t=          ||j                  D             }t9          |j                   t9          |j                  k    sJ d t=          |j        |j                   D             }|rg n|}|j!        }ng }g }i }i }i }g }i }t          d%i d|dt           j        d| d|d|d|
d|d|d|	d|d|d|d|d|d|d|d|d|d |}|r|r|"                    d!           |#                                sptI          ||          r(|%                                 |&                                 tO          ||          r(|%                                 |&                                 |j(        |_)        n|#                                r#|*                    d"| d#|  d$           t          |%                    |!           |&                                 |j+        r|j,        rg |j,        _-        |j.        | = |S )&Nz!Neither id, path nor source givenr   __main__F)skip_diagnosesilentTr   r  )validate_meta_timec                    i | ]\  }}||	S r   r   )r  r   rG  s      r   rl  z#State.new_state.<locals>.<dictcomp>	  s    OOOgb#"cOOOr   c                    i | ]\  }}||	S r   r   )r  r   r  s      r   rl  z#State.new_state.<locals>.<dictcomp>	  s    SSSTBSSSr   c                    i | ]\  }}||	S r   r   ri  s      r   rl  z#State.new_state.<locals>.<dictcomp>	  s    UUU6Aq!QUUUr   r   r  r   r   r!  r   r^  r  r  r  r~  r  rM  rN  r  r  r  rI  rw  )r  z(Deferring module to fine-grained update  ()r   )/r   r  r  r  r  r  r   r7  dep_import_optionsr  find_module_and_diagnoser  r  r  is_silent_import_moduler   r\  r~  r  r  rk  r  r   rr  rd  r  rM  rN  rg  rO  r:  rP  r  rw  	load_treer  exist_added_packagesre  compute_dependenciesexist_removed_submodulesrj  r   re  r-  rd  rA  r	  )r   r   r!  r   r  r  r  r  r  r  r   r^  follow_importsr   r  r~  r  rI  rs  rM  rN  all_depsr  r  r  rw  states                              r   	new_statezState.new_stateH	  s      	YXX!3!35X!3!3!3q  	 )8==??N!!<#5{"CDDDDN:/22266%,%?%?%A%Ar"
 	>>>'?  "+	( 	( 	($nn "     =25*G+B/ ))!
 	-gt<< 	[ 	J 	-FNw'<N /D' B BD+!%!4#'9  	FNw'<'<T'B'BNF  	BT2tZAA  	Cr1ABBB 	!   122Ldo..J#j0Hx==C$7$77777OOXt~1N1NOOOJx==C$7$77777SSS4>5R5RSSSLt''3t/@+A+AAAAAUUS1BDO-T-TUUUJ *;""K"2OOLJJLJK O 
 
 
G
%%
 r
 	

 6
 G
 "z
 $
 *>
 
 *>
 .-
 &
 "z
 "z
  &!
" "z#
$ $%
& ,O'
,  *	* 0$///1133 1 (
G<< 1$$&&&..000 ,L'BB 1$$&&&..000"iEOO
 --// %TtTTrTTTUUU$$ y111&&((( *5: * &(
"%b)s   'C 
C#CC#r^  r   c                   || _         || _        || _        || _        |r^t          j                            |          r|| _        n7t          j                            t          |j	        |                    | _        |pd| _
        || _        || _        || _        || _        |	| _        |
| _        || _        || _        || _        || _        t+          |          | _        t+          |          | _        || _        || _        || _        || _        t9          j        t<                    | _        g | _         d | _!        | "                                 || _#        || _$        d | _%        d S )Nz<string>)&r   r  r   r   r   isabsr  r  rd   r  r  r!  r   r^  r  r  r  r~  r  rM  rN  r   r  r  r  r  r  rI  r   defaultdictr   r  r  r  add_ancestorsrw  r   known_suppressed_deps_opts)r   r   r  r   r   r!  r   r^  r  r  r  r~  r  rM  rN  r  r  r  rI  rw  r   s                        r   r   zState.__init__	  sS   . 
	 	Qw}}T"" Q#!w//W[$0O0OPP'Z
$&,	, 0($ #L 1 1!*oo$($&)4)@)E)E&!." 9='''r   r0  r*   c                `   t          || j                   t          || j                   t	          || j                   t	          || j                   t          || j                   t          || j	                   t          |t                     t          |t          | j                             | j        D ]%\  }}t          ||           t          ||           &t          || j                   t	          || j                   t%          || j                   t%          || j                   t          |t*                     t          |t          | j                             | j                                        D ]%\  }}t1          ||           t          ||           &t          |t*                     t          |t          | j                             | j                                        D ]%\  }}t1          ||           t          ||           &t          |t*                     t          |t          | j                             | j                                        D ]%\  }}t1          ||           t          ||           &t          || j                   dS )a#  Serialize State for sending to build worker.

        Note that unlike write() methods for most other classes, this one is
        not idempotent. We erase some bulky values that should either be not needed
        for processing by the worker, or can be re-created from other data relatively
        quickly. These are:
          * self.meta: workers will call self.reload_meta() anyway.
          * self.options: can be restored with Options.clone_for_module().
          * self.error_lines: fresh errors are handled by the coordinator.
        N)r   r  r   r   r6   r   r!  r   r^  r  r    r#   write_int_barerg  r  r   r~  r  r5   rM  rN  r"   r  r  write_str_barer  r  r   )r   r0  r   r  r  priodep_hashs          r   r'  zState.write%
  s    	#tz"""#twc49%%%c4;'''3(((#t'(((#x   sC 344555- 	! 	!JD$c4   c4    C,---c40111sD-...sDO,,, 	#|$$$sC00111 O1133 	! 	!LFD3'''c4    #|$$$sC 122333 -3355 	! 	!LFD3'''c4    #|$$$sC00111 $ 5 5 7 7 	' 	'FH3'''X&&&&#t~&&&&&r   r(   c                   t                    }t                    }t                    }t                    }t                    }t                    }t	                    t
          k    sJ fdt          t                              D             }	t                    }
t                    }t                    }t                    }t	                    t          k    sJ fdt          t                              D             }t	                    t          k    sJ fdt          t                              D             }t	                    t          k    sJ fdt          t                              D             } | di d|d|d|d|d	|d
|j        d|d|d|	dd d|
d|d|d|d|d|d|dg di dt                    S )Nc                L    g | ] }t                    t                    f!S r   )r   r   r  rI  r0  s     r   r  zState.read.<locals>.<listcomp>[
  s*    \\\Q8C==(3--8\\\r   c                J    i | ]}t                    t                     S r   read_str_barer   r  s     r   rl  zState.read.<locals>.<dictcomp>a
  s)    [[[AmC(((3--[[[r   c                J    i | ]}t                    t                     S r   r  r  s     r   rl  zState.read.<locals>.<dictcomp>c
  s)    ]]]ac**HSMM]]]r   c                J    i | ]}t                    t                     S r   )r  r+   r  s     r   rl  zState.read.<locals>.<dictcomp>e
  s)    ]]]amC((*S//]]]r   r   r  r   r   r!  r   r^  r  r  r  r~  r  rM  rN  r  r  r  rI  rw  r   r   )r   r   r0   r   r   r#   r%  read_int_barer+   r/   r"   r   )clsr0  r   r  r   r   r!  r^  r  r  r~  r  rM  rN  r  r  r  s    `               r   rP  z
State.readR
  s   c]]C  c""s^^
smm}}((((\\\\%VYHZHZB[B[\\\#C',,$S))"3''
}},,,,[[[[}UXGYGYAZAZ[[[
}},,,,]]]]5WZI[I[C\C\]]]}},,,,]]]]5WZI[I[C\C\]]]
s 
 
 
G
%
 r
 	

 6
 OO
 "z
 $
 *>
 
 *>
 .-
 &
 "z
  "z!
" &#
$ "z%
& '
( B)
* smmm+
 	
r   c                    | j         J t          | j        | j         | j        d          \  | _        }| j        J | j        j        | _        dS )zForce reload of cache meta.

        This is used by parallel checking workers to update shared information
        that may have changed after initial graph loading. Currently, this is only
        the interface hash.
        NT)r=  )r   r\  r   r   r  r~  )r   rI  s     r   reload_metazState.reload_meta~
  sV     y$$$&tw	4<Y]^^^	1y$$$"i6r   c                L   | j         Vt          j                             | j                   \  }}t          j                             |          \  }}d|v r	g | _        d S g }| j        }d|v r2|                    dd          \  }}|                    |           d|v 2|| _        d S )Nr-  r   )r   r   r3  splitextrK  r   r  r  )r   rI  r4  r  rK  parents         r   r  zState.add_ancestors
  s    9 gmmDI..GAtg&&t,,GD!d{{!#	Vmmc1--IFAV$$$ Vmm #r   c                    | j         duoB| j        | j         j        k    o-| j        j        p!| j         j        |                                 k    S )z5Return whether the cache data for this file is fresh.N)r  rM  r   r[  r  r   s    r   is_freshzState.is_fresh
  sV     IT! !TY%;; 5 Q91T5N5N5P5PP	
r   c                N    | j         j                            | j                   dS )zGMarks this module as having been fully re-analyzed by the type-checker.N)r   r  r`  r   r   s    r   mark_as_recheckedzState.mark_as_rechecked
  s#    &**4733333r   c                N    | j         j                            | j                   dS )zRMarks this module as having a stale public interface, and discards the cache data.N)r   r  r`  r   r   s    r   mark_interface_stalezState.mark_interface_stale
  s#    "&&tw/////r   c                    | j         j                                        r:| j                             d           | j         j                                         dS dS )z3Raise CompileError if a blocking error is detected.zBailing due to blocking errorsN)r   r   rc  re  r  r   s    r   check_blockerszState.check_blockers
  sY    <**,, 	.L=>>>L++-----	. 	.r   Tr  Iterator[None]c           
   #    K   | j         j                                        }| j         j                            | j                   	 dV  n^# t          $ r  t
          $ rG}t          || j        d| j         j        | j        | j         j	        | j         j
                   Y d}~nd}~ww xY w| j         j                            |           |r|                                  dS dS )a  Temporarily change the error import context to match this state.

        Also report an internal error if an unexpected exception was raised
        and raise an exception on a blocking error, unless
        check_blockers is False. Skipping blocking error reporting is used
        in the semantic analyzer so that we can report all blocking errors
        for a file (across multiple targets) to maintain backward
        compatibility.
        Nr   )r   r   r  set_import_contextr?   r   rB   r   r   r  r  r  )r   r  save_import_contextr%  s       r   wrap_contextzState.wrap_context
  s      #l1@@BB..t/BCCC	EEEE 	 	 	 		 		 		!	###       		 	../BCCC 	"!!!!!	" 	"s   A B&=B!!B&rf  c                @    | j                             | j                  S r   )r   rp  r   r   s    r   rp  zState.load_fine_grained_deps
  s    |2247;;;r   c                   | j         j        r3| j        J t          | j        | j        | j         j                  \  }}}n| j        
J d            | j        j        }| j        j        rt          || j         dd           }nt          || j         dd          }|d S t          j                    }t          |t                    r)t          |          }t          j        |          | _        nt          j        |          | _        t          j                    }| j                             ||z
             |s6| j        | j         j        | j        <   | j                             d           d S d S )NzBInternal error: this method must be called only for cached moduleszCould not load tree: z
Load tree )deserialize_timer   )fresh_trees)r   r  r   r  r   r   r  rT  r-  r	  r  r   r   r  r(   rU   rP  rd  rK  rd  r   )r   r  rI  rT  r   rs  rU  r  s           r   r  zState.load_tree
  sh   <' 	,9(((-dgty$,BVWWOAy!! 	%%S &%%	+I <* 	c DL:QSWXXDD"9dlLJabbD<FY[[dE"" 	3 &&G g..DII ,T22DIY[[R888 	2,0IDL )L""q"11111	2 	2r   c                |    | j         
J d            t          | j         | j        j        | j        j                   d S )N9Internal error: method must be called on parsed file only)rd  rm   r   r   r   r  r   s    r   fix_cross_refszState.fix_cross_refs
  s?    y$$&a$$$ 	TY 4dl6YZZZZZr   )r  rV  rV  rW  c          
        | j         dS | j        }| j        |j        v }|j        }|s'|                    d| j         d| j         d           n&|                    d| j         d| j         d           t                      }|                                 5  | j	        }| j
        re|b	 |                    | j
                  }t          |j                            |                    }|j                            |          | _        nL# t"          $ r}	|	j        J t'          d                    | j
                            t-          j                    t,          j        z   d          t-          j        |	j                            g| j                  |	d}	~	wt4          t6          f$ r[}
| j
                            d	          r| j
         d
}n| j
         dt;          |
           }t'          |g| j                  |
d}
~
ww xY w| j
        r.| j        j                            | j
                  r
d}d| _        n|J t?          |          | _        |                      |           | !                                 tE          |          | _#        |sC| j$        p| j%        j&        }|'                    | j        | j        ||| j%        |          | _         n|j        | j                 d         | _         ddd           n# 1 swxY w Y   | xj(        tQ          |          z  c_(        |sLtS          |j*        j+        ,                    | j        g                     | _-        | .                                 n|j        | j                 d         | _-        |s#| j         || j        <   | /                                 | j         | j-        f|j        | j        <   | 0                                 dS )zParse file and run first pass of semantic analysis.

        Everything done here is local to the file. Don't depend on imported
        modules in any way. Also record module dependencies based on imports.
        NzParsing r  r  zUsing cached AST for z&mypy: error: cannot read file '{}': {}r  )module_with_blockerz.pydz,: error: stubgen does not support .pyd filesz: error: cannot decode file: )rU  r   rV  r   r   )1rd  r   r   r	  r   re  r  rf   r  r!  r   r#  r\   r  rP  r^   r  r+  errnor?   r|  replacer   rT  sepstrerrorrl  r[   r  r   rk  rv  parse_inline_configurationcheck_for_invalid_optionsrg  r   r^  r   rU  re  rg   r  r   error_info_maprV  r  semantic_analysis_pass1r  setup_errors)r   r  rV  r   r  r   rs  r!  r   ioerr	decodeerrr%  rU  s                r   re  zState.parse_file  sI    9 F, G--/ 	JKK;4:;;;;;<<<<KKH
HHdgHHHIIIZZ   3	: 3	:[Fy 8V^Z"==diHHD3GO4H4H4N4NOOF'.'B'B4'H'HD$$ ! ! !
 !;222&DKK $	 1 1")++2F K K "EK 8 8  -1G   !! +K8 Z Z Zy))&11 Z!%XXX!%YYYYY&u$'JJJPYYZ  8t|399$)DD 8#%  )))#/#7#7 ++F333**,,, [[DN : $ M4<3M#..GJ"/ L% /  		 $-dg6q9	g3	: 3	: 3	: 3	: 3	: 3	: 3	: 3	: 3	: 3	: 3	: 3	: 3	: 3	: 3	:j 	mB/// 	> !%W^%B%F%FtzSU%V%V W WD((**** ' 1$' :1 =D 	"#yGDG!!!&*i1B%C$'"sF   L+A DL
H	BFH	.AHH		C/LLLc                    | j         J | j        j                            | j        | j         j        | j        p| j        j                   | j        j        	                    | j        | j         j
                   d S r   )rd  r   r   set_file_ignored_linesr  ignored_linesr^  r   rU  set_skipped_linesskipped_linesr   s    r   r  zState.setup_errors`  sq    y$$$22J	/1^DLD^	
 	
 	
 	--dj$):QRRRRRr   c                @   t          |          }|rt          || j                  \  }}| j                            |          | _        | j        j                            | j        | j        | j                   |D ]"\  }}| j        	                    ||           !dS dS )z8Check for inline mypy: options directive and parse them.N)
r]   rl   r   apply_changesr   r   r  r  r   r5  )r   r!  flagschangesconfig_errorslinenor5  s          r   r  z State.parse_inline_configurationg  s    !&)) 	2%8%M%M"G]<55g>>DLL((TWdlKKK!. 2 2""651111	2 	22 2r   c                    | j         j        r\| j         j        sR| j        j                            | j        | j        | j                    | j                            d dd           d S d S d S )Nr   z9Option --strict-bytes cannot be disabled when using mypycTr.  )	r   mypycstrict_bytesr   r   r  r  r   r5  r   s    r   r  zState.check_for_invalid_optionsq  s    < 	dl&? 	L((TWdl(SSSLQ[_      	 	 	 	r   c                R   | j         }| j        J t                      }|j        sat	                      }|                                 5  |                    | j        | j        | j        |           ddd           n# 1 swxY w Y   t                      | j        _
        | j        j        s_| j         j        s&| j                            t                                 |j        r&| j                            t!                                 | xj        t#          |          z  c_        dS )zPerform pass 1 of semantic analysis, which happens immediately after parsing.

        This pass can't assume that any other modules have been processed yet.
        N)r   rd  rf   native_parserrZ   r  
visit_filer  r   rV   rC  rb  allow_redefinition_newacceptr   allow_redefinition_oldr   rg   )r   r   rs  analyzers       r   r  zState.semantic_analysis_pass1x  sf   
 ,y$$$ZZ $ 	M244H""$$ M M##DItz47GLLLM M M M M M M M M M M M M M M &--	y  	:<6 A 	  !=!?!?@@@- :	  !6!8!8999mB///s   (A<<B B r  c                    || j         vr4| j                            |           | j                             |           || j        v r6| j                            |           | j                            |           d S d S r   )r  rM  r  r`  r  rN  r  r   r  s     r   add_dependencyzState.add_dependency  s    d+++$$S)))!%%c***$%%%O""3'''&&s+++++ &%r   c                    || j         v r4| j                            |           | j                             |           || j        vr6| j                            |           | j                            |           d S d S r   )r  rM  r  r  rN  r  r`  r  s     r   suppress_dependencyzState.suppress_dependency  s    $'''$$S)))!((---d)))O""3'''##C((((( *)r   c                X   | j         }| j        J g | _        t                      | _        g | _        t                      | _        i | _        i | _        i | _	        |
                    | j                  | j         j                            | j                  z   }|D ]p\  }}}t          || j                            |t                              | j        |<   || j        k    rH|                     |           || j        vr
|| j        |<   q| j                                        fd| j        j                                        D             | _        | j        dk    r|                     d           | j        j        r|                     d           |                                  dS )zCompute a module's dependencies after parsing it.

        This is used when we parse a file that we didn't have
        up-to-date cache information for. When we have an up-to-date
        cache, we just use the cached info.
        Nc                $    i | ]\  }}|v 	||S r   r   )r  r  codesimport_liness      r   rl  z.State.compute_dependencies.<locals>.<dictcomp>  s1      
  
  
'D%dVbNbNbD%NbNbNbr   r   zstring.templatelib)r   rd  rM  r   r  rN  r  r  r  r  rQ  rF  get_additional_depsminrV  r  r   r  r  r  r  rw  uses_template_stringsr  )r   r   dep_entriesrG  r   r  r  s         @r   r  zState.compute_dependencies  s    ,y$$$  #!ee::I
 
L33DI>>? ) 	- 	-MCT"%c4?+>+>r7+K+K"L"LDOBTW}}###***(,!"%(//11 
  
  
  
+/9+B+H+H+J+J 
  
  
 7j  
+++9* 	6 4555r   c                   | j         j        rd S t                      }|                                 5  |                                                                  d d d            n# 1 swxY w Y   | xj        t          |          z  c_        d S r   )r   semantic_analysis_onlyrf   r  type_checkercheck_first_passrg   )r   rs  s     r   type_check_first_passzState.type_check_first_pass  s    <. 	FZZ   	3 	300222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3mB///   'A$$A(+A(r7   c           	         | j         sU| j        
J d            | j        }t          |j        |j        | j        | j        | j        |j        | j	                  | _         | j         S )Nz2Internal error: must be called on parsed file only)
r  rd  r   r7   r   r   r   r  rF  r  r   r   s     r   r  zState.type_checker  sl    ! 	9((*^(((lG!,	
." "D !!r   rr  c                    t          |                                 j                  dk    sJ |                                 j        d         S r   )rg  r  
_type_mapsr   s    r   rq  zState.type_map  sF     4$$&&122a7777  ""-a00r   c                   | j         j        rdS t                      }|                                 5  |                                                                 }d d d            n# 1 swxY w Y   | xj        t          |          z  c_        |S r  )r   r  rf   r  r  check_second_passrg   )r   rs  r3  s      r   type_check_second_passzState.type_check_second_pass  s    <. 	5ZZ   	= 	=&&((::<<F	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=mB///r  c                   | j         
J d            | j         j        rd S | j        }|j                            | j        | j         j        | j                   |j                            t          j
                  s$|j                            t          j                  re| j                             t          t          |j        |j                  |                                 | j        | j         j                             d S d S )Nr  r  )rd  rb  r   r   r  r  r0  r   is_error_code_enabledr  POSSIBLY_UNDEFINEDUSED_BEFORE_DEFr	  rX   rO   r   rq  rC  r   s     r   detect_possibly_undefined_varsz$State.detect_possibly_undefined_vars  s    y$$&a$$$9 	F,
DI,>UUU>//$
 
 
	^11%2GHH
	 I0"7>7?CCMMOOLIO	     
	 
	r   c           	        | j         
J d            | j        }| j        j        rd S t	                      }|                                 5  |j        }|j        r,|j                            | 	                                           | 
                    | j         j        |                                 j        z  t          | 	                                                                                     | j        j        r:t!          | j         | j        | j        j        d| 	                                           |                    | j         | 	                                | j                   |                     | j        j                   |j        j        r.t/          | |j        |j        | 	                                           |                                  |j        j        s>|j        j        s2t9          | j                    | j         j                                         d d d            n# 1 swxY w Y   | xj        t?          |          z  c_        d S )Nr  T)r   inferredtypemap) rd  r   r   r  rf   r  export_typesr   r  rq  patch_indirect_dependenciesmodule_refsr  r   r  dump_inference_statsr   r  r   ru  update_fine_grained_depsr  export_ref_infowrite_undocumented_ref_inforb  
free_stater[  preserve_astsrn   defsclearrg   )r   r   rs  r   s       r   finish_passeszState.finish_passes  s[   y$$&a$$$,<. 	FZZ   &	' &	'oG# :!((999 ,, 	%(9(9(;(;(GGDMMOO**,,--   |0 IJ L0! MMOO    	4==??DLIII))$,*>???. +'+W_dmmoo   OO?; 'GODa '$)$$$	$$&&&M&	' &	' &	' &	' &	' &	' &	' &	' &	' &	' &	' &	' &	' &	' &	'N 	mB///s   	GH++H/2H/c                X    | j         r"| j                                          d | _         d S d S r   )r  r  r   s    r   r5  zState.free_state>  s:     	&$$&&&!%D	& 	&r   r0  r   	set[Type]c                h   | j         J t          | j        | j        z   | j         z             }|                    | j                   | j        j                            |          |z  }t          ||z
            D ]5}|| j        j
        vr|                     |           t          | j        |<   6d S r   )rK  r   rM  rN  r`  r   r   r  find_modulesr  r   r  r  r  )r   r0  r   existing_depsencounteredr  s         r   r/  z!State.patch_indirect_dependenciesC  s    ~)))D-?$.PQQ$'"""l7DDUKKkY+566 	0 	0C$,...$$$#/DOC  		0 	0r   c                    | j         J | j        dv ri S ddlm}  || j         |                                 | j        j        | j        j                  S )N)r   r   r   r   r   r   )get_dependencies)targetrq  r  r   )rd  r   r  rA  rq  r   r  r   )r   rA  s     r   compute_fine_grained_depszState.compute_fine_grained_depsO  sq    y$$$7III I5555559]]__<6L(	
 
 
 	
r   r   c                    | j         j        }|j        s|j        r:ddlm}  ||                                 |           t          j        |           d S d S )Nr   r  )	r   r   r,  r[  r  r  rC  r   update_protocol_deps)r   r   r   r  s       r   r2  zState.update_fine_grained_depsc  ss    ,&% 	2)I 	2;;;;;;t==??FFF+D11111		2 	2r   c                   | j         sdS | j        r| j        S t                      }| j        j        }t          | j                   D ]}| j        j                            |t          j	                  }| j
                            |          t          k    r6t          ||           t          |||                    t          ||           |                                S )Nr   )rN  r  r*   r   r  r  r  rV  r  r  r  r  r  write_bytes_barer  r(  )r   r0  r  r  r  s        r   r  zState.suppressed_deps_optsk  s     	3* 	322mm4$/** 	, 	,C \155c;L;VWWF""3''<77sC((( nS&9:::sF+++||~~r   tuple[CacheMeta, str] | Nonec                   | j         
J d            | j        r&| j        j        t          j        k    s| j        j        r| j        j        r	 | j        j        j	        r)t                      }| j                             |           n| j                                          n2# t          $ r% t          d| j         | j        j                    w xY wd S |                                 }|                                 }| j        J t)          t+          | j                            t)          | j                  k    sJ d| j         d| j         d            t/          | j        | j        | j         t1          | j                  t1          | j                  |                                 | j        ||| j        | j        | j        | j        | j                  \  }}|| j        k    r$| j                            d| j         d           n>| j                            d| j         d	           |                                   || _        |S )
Nr  zError serializing r  z$Duplicates in dependencies list for r  r  zCached module z has same interfacez has changed interface)!rd  r   r   rl  r   r  r[  debug_serializer   r-  r*   r'  r  r   r   r   r  dependency_prioritiesdependency_linesr  rg  r   rM  r  r  rN  r  rw  r~  r{  r^  re  r  )r   r   rO  rP  new_interface_hash
meta_tuples         r   r  zState.write_cache|  sj   y$$&a$$$ 		|%33|4 4 |+ 	|+> .*}}	----	++---    8tw88t|?RSSSS 4..00	))++	+++3t())**c/
 /
 
 
 
Q$'QQT=NQQQ
 
 
 *5GII"##!!%%'' OL*
 *
&J  !444LJdgJJJKKKKLMdgMMMNNN%%'''"4Ds   AB   /Csuppressed_onlyc           	          j         } j        J |r fd j        D             }n% fd j         j        z   D             }| j        z   }|D ]}||j        v r|j                            |          }|j        r. j        	                    |d          }	 | j        v rd} }	n d}	}t          ||||||	           r# t          t          f$ r Y w xY wdS )zReport errors for import targets in modules that don't exist.

        If suppressed_only is set, only check suppressed dependencies.
        Nc                Z    g | ]'}j                             |          t          k    %|(S r   r  rV  r  r  r  r   s     r   r  z-State.verify_dependencies.<locals>.<listcomp>  s4    ccc$/:M:Mc:R:RVb:b:b:b:b:br   c                Z    g | ]'}j                             |          t          k    %|(S r   rR  rS  s     r   r  z-State.verify_dependencies.<locals>.<listcomp>  s>       ?&&s++|;; ;;;r   r   )r  r  r  )r   rK  rN  rM  r   r   r7  ignore_missing_importsr  rV  r  r  r?   )
r   rO  r   r  rM  r  r   r  r  ancestors
   `         r   verify_dependencieszState.verify_dependencies  sa   
 ,~))) 	5cccctcccHH   ,t>  L
 $dn4H 	 	Cgo%%o66s;;G- $((a00D$.((*.E-1HH&*D8E(!& $!)     #L1    -	 	s   'CCCry  c                :      fd j          j        z   D             S )Nc                P    g | ]"}j                             |t                    #S r   r  rV  r  rS  s     r   r  z/State.dependency_priorities.<locals>.<listcomp>  s+    bbbs##C22bbbr   rM  rN  r   s   `r   rK  zState.dependency_priorities  s)    bbbbd>ORVRa>abbbbr   c                :      fd j          j        z   D             S )Nc                F    g | ]}j                             |d           S )r   )r  rV  rS  s     r   r  z*State.dependency_lines.<locals>.<listcomp>  s,    ]]]#!%%c1--]]]r   r[  r   s   `r   rL  zState.dependency_lines  s'    ]]]]9JT_9\]]]]r   c                r   | j         j        st          j        | j         j        v rt          j        | j         j        vrx| j        r"| j         j        r|                     d           | j	        d uo| j	        
                    | j                   }| j        j                            | j        |           d S d S d S )NTrO  )r   warn_unused_ignoresr  UNUSED_IGNOREenabled_error_codesdisabled_error_codesr  r[  rW  rd  rb   r   r   generate_unused_ignore_errorsr  r   is_typesheds     r   generate_unused_ignore_notesz"State.generate_unused_ignore_notes  s    L,	W"dl&FFF!)JJJy ?T\B ?(((>>>)4/\DI4N4Nt|4\4\KL==dj+VVVVV KJ GFr   c                   | j         j                            t          j                  rZ| j        d uo| j                            | j                  }| j         j                            | j	        | j        j
        |           d S d S r   )r   r   r'  r  IGNORE_WITHOUT_CODErd  rb   r   #generate_ignore_without_code_errorsr  r`  re  s     r   "generate_ignore_without_code_notesz(State.generate_ignore_without_code_notes  s    <44U5NOO 	)4/\DI4N4Nt|4\4\KLCC
DL<k    	 	r   Nr   NFF)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  r   rM  r  rN  r  r  r  r  r  r  r  rI  r  rw  rx  r   r   r   r   r0  r*   r   r   )r0  r(   r   r   r   r   r   r  )T)r  r  r   r  )r   rf  F)r  r  r   r   )r  r  rV  rW  r   r   )r!  r   r   r   )r  r   r   r   )r   r7   )r   rr  )r0  r   r   r;  r   r   )r   rf  r   r   )r   r  )r   rH  )rO  r  r   r   )r   ry  )@r   r   r   r   r   r  r   r  r!  r  r  r  rd  rK  r  r~  r{  r^  r  fine_grained_deps_loadedrg   staticmethodr  r   r'  classmethodrP  r  r  r  r  r  r  
contextlibcontextmanagerr  rp  r  r  re  r  r  r  r  r  r  r  r  r  rq  r%  r*  r9  r5  r/  rC  r2  r  r  rW  rK  rL  rg  rk  r   r   r   r   r     s          #$M$$$$JJJGGGDGJJJF"K""""#'''''!D!!!! D    
  !    !    "!!! #'I&&&& *))) K  N  N  J "!!! )-M,,,,$ M .--- NNN *))) &*%)!
  ^ ^ ^ ^ \^j +:= := := := :=x+' +' +' +'Z )
 )
 )
 [)
V
7 
7 
7 
7# # # # 
 
 
 
"4 4 4 40 0 0 0. . . . " " " " ">< < < <2 2 2 2 2>[ [ [ [ /4TX [ [ [ [ [ [zS S S S2 2 2 2   0 0 0 0B, , , ,) ) ) )+ + + +Z0 0 0 0" " " "1 1 1 1      &-0 -0 -0 -0^& & & &

0 
0 
0 
0
 
 
 
(2 2 2 2   "/ / / /b- - - - -^c c c c^ ^ ^ ^	W 	W 	W 	W     r   r  r  r  r  r  r  tuple[str, str]c                b   t          ||           }t          |t                    r|j        }	|s%|                    d          r|j        r	|t          v rd}	|rn|	dk    r|                     d| d| d           n|	dk    s|	dk    r|| j        vr|                     d	| d| d           |	dk    r(|rt          | |||           nt          | ||||           t          j        }
|j        rt          j        }
t          |

          t!          | |          r|sd}	||	fS |j        }| j        j        }t%          |          r|r|j        s|t(          j        u rd}|rt          |r,|s#t-          ||           st/          | ||||           t          |rt1          d| dg          t          )a  Find a module by name, respecting follow_imports and producing diagnostics.

    If the module is not found, then the ModuleNotFound exception is raised.

    Args:
      id: module to find
      options: the options for the module being loaded
      caller_state: the state of the importing module, if applicable
      caller_line: the line number of the import
      ancestor_for: the child module this is an ancestor of, if applicable
      root_source: whether this source was specified on the command line
      skip_diagnose: skip any error diagnosis and reporting (but ModuleNotFound is
          still raised if the module is missing)

    The specified value of follow_imports for a module can be overridden
    if the module is specified on the command line or if it is a stub,
    so we compute and return the "effective" follow_imports of the module.

    Returns a tuple containing (file path, target's effective follow_imports setting)
    .pyinormalr  z
Silencing r  r  skipr5  z	Skipping r  Fzmypy: can't find module '')find_module_with_reasonr   r   r  r  follow_imports_for_stubsr   re  r  skipping_ancestorskipping_moduler  r  rU  r  r  r  r   r   !ignore_missing_imports_per_modulerv   APPROVED_STUBS_NOT_INSTALLEDin_partial_packagemodule_not_foundr?   )r   r   r   r  r  r  r  r  r3  r  r  rU  global_ignore_missing_importss                r   r  r    s]   < %R11F&# F!
 !/	& ''	&  8		& )))%N 	0x''KK4V44r4445555v%%7)B)B000777"777888(( T%gr6<HHHH#G[,FSSS&.F- 5 +4 ////"7F33 	&K 	&%N~%% ")!? )0(N%1"55	+-	+ =	+ .KKK%*" 	!   
	!* Q.@W.M.M Q +|RPPP   	!  AB A A ABCCC  r   c                   | D ]}||j         j        v rt          ||          }|s$|j                            |          }|j        dv r|                    d          r|j        rdt          j	        
                    |          dv r dS dS )zFind if there are any newly added packages that were previously suppressed.

    Exclude everything not in build for follow-imports=skip.
    )rx  r5  rv  )r*  z__init__.pyiTF)rC  source_modulesrT  r   r7  r  r  r{  r   r   r  )rN  r   r  r   r   s        r   r  r  `  s    
   '$333 !#w// 	/22377 !%666f%% 7)0)I 7 7D!!%DDD44 E5r   c                    t          |           }| D ]H}d|vr||j        j        v r|                    dd          \  }}||vr5t	          ||           dS IdS )zFind if there are any submodules of packages that are now missing.

    This is conceptually an inverse of exist_added_packages().
    r-  r   r#  NTF)r   rC  r  r  rT  )rM  r   r  r  direct_ancestorrI  s         r   r  r    s    
 <(( 
 
c>>'$333 ZZaZ88"222c7++344 45r   c                   |j         rt          j                    }|j                            | d          }|j         r+|                    t          j                    |z
  d           t          |t                    rdS |S )z>Find a filesystem path for module `id` or `None` if not found.Tr  r   find_module_timefind_module_callsN)r  r   r  r  rd  r   rv   r   r   rs  r?  s       r   rT  rT    s     Y[[!--bD-AAA R49;;+;qQQQ!)** tHr   rw   c                    |j         rt          j                    }|j                            | d          }|j         r+|                    t          j                    |z
  d           |S )zGFind a filesystem path for module `id` or the reason it can't be found.Fr  r   r  )r  r   r  r  rd  r  s       r   rz  rz    sh     Y[[!--bE-BBA R49;;+;qQQQHr   c                f   d| v r|                      dd          \  }}||j        v r|j        |         S ||j        v r|j        |         }nH	 t                              |dd|d          }|j        }d|_        n# t          t          f$ r d}Y nw xY w||j        |j        |<   |j        S |} d| v dS )zCheck if a missing module can potentially be a part of a package.

    This checks if there is any existing parent __init__.pyi stub that
    defines a module-level __getattr__ (a.k.a. partial stub package).
    r-  r   NT)r   r   r!  r   r  F)	r  r  r   r   r  rd  r  r?   is_partial_stub_package)r   r   rV  rI  ancestor_modancestor_sts         r   r  r    s     ))iiQ''!w5551(;;w&&,3OH,ELL	(#ood4TX .    +/#'   #L1 $ $ $#$ #7C7[G*8477- )). 5s   A: :BBr  rB  r  rv   c                   | j         }|                                }|                    |j                   |                    |j        |j        |j                   |                    |j        |j        r|j        j	        n|j
        |j        p|j        j                   |dk    r.|                     |dd           |                                 n| j        j        }|                    |          \  }}	|t"          j        k    rt&          j        }
n9|t"          j        k    s|t"          j        k    rt&          j        }
nt&          j        }
|                     ||                    |          |
           t5          |          }|	D ]9}d|v r|J |                    |          }|                     ||d|
	           :|t"          j        u r|J | j                            |           |                    |           d S )
Nr   z7Cannot find 'builtins' module. Typeshed appears broken!Tr.  )r  )r  z{stub_dist})	stub_dist)r  r  )r   r  r  r  r  r   r   r  rd  r  rw  r^  rU  r5  r  r[  error_message_templatesrv   r  r  IMPORT_NOT_FOUNDFOUND_WITHOUT_TYPE_HINTSr  IMPORT_UNTYPEDIMPORTr|  r   r  rp  r`  )r   r  r  rB  r  r   r  daemonr   notesr  distr  s                r   r  r    s#    ^F //11
l9:::
OOL&9MNNN
!!+7+<^'',B^E<#7#E  
 KUY 	 	
 	
 	
 	933F;;
U)333)DD*CCC-JJJ'DD<DdCJJfJ55DAAA%f-- 	@ 	@D$$'''{{T{22LLtt$L????)FFF###)--d333
122222r   c                   |sJ ||f            | j                                         }| j                             |j                   | j                             |j        |j        | j                   |                     |d| d           |                     |dd           | j                             |           dS )zDProduce an error for an import ignored due to --follow_imports=errorzImport of "	" ignoredzA(Using --follow-imports=error, module not passed on command line)Tr  N)	r   r  r  r  r  r   r   r5  r  )r   r  r  r   r   r  s         r   r}  r}    s     ##"d###!.7799N%%l&ABBBNL.QQQMM$3b333444LLQ]a     N%%&9:::::r   c                    | j                             g            | j                             |j        |j        | j                   |                     dd| dd           |                     ddd           dS )zFProduce an error for an ancestor ignored due to --follow_imports=errorNzAncestor package "r  Tr  z@(Using --follow-imports=error, submodule passed on command line))r   r  r  r  r   r   r5  r  )r   r   r   r  s       r   r|  r|    s     N%%b)))NL.QQQMM$:R:::dMKKKLLP\`      r   c                    | j         sdS | j        j        }|rt          j                            |          }|                                  dt          fd|pdfd| j        j        pdfdt          j
        fd| j        j        fd	t          t                              d
                     fd| j        j        fg}|D ]"\  }}|                     |dz   d|            #|D ]}|                     dd|            | j                                                                        D ]U\  }}|s|                     d|             |                     | d           |D ]}	|                     d|	            VdS )z8Output useful configuration information to LOG and TRACENzMypy VersionzConfig FileDefaultzConfigured Executabler   zCurrent Executablez	Cache DirCompiledr  Excluder  r  zFound source:zNo z    )r  r   ry  r   r   r  re  r   python_executabler   r   rl  r   r  r  excluderr  asdictr  rX  )
r   r   ry  configuration_vars	conf_name
conf_valuer!  	path_typepathspths
             r   log_configurationr    s    " /-K 3gook22KKMMM	%	1	3	 '/"C"MvN	s~.	go/0	SX..u555667	GO+, "4 9 9	:y377:778888 5 5336334444 $07799??AA ( (	5 	MM+	++,,,ooo&&& 	( 	(CMM,,,''''	(( (r   c                   t          ||            t          j                    }|j        j        s1t	          j                    dk    rt          st          j                     t          | |          }|
                                rOt          |          dt          |           z  k     r,|                    d           d|_        t          | |          }|j        j        sYt	          j                    dk    rBt          s;t          j                     t          j                     t          j                     da|D ]}||         j        |j        |<   t          j                    }|                    t          |          t)          d |                                D                       ||z
  t          |j        j                             |st1          d|	           |S |                    d
t          |           d||z
  dd           |j        j        rt3          ||           |S |j        j        s|
                                rt          j                    }t7          ||          }|                    t          j                    |z
             |||_        nz|j                            dd          dk    r[|j                                         |                    d           d|_        |                    d           tA          | ||          S |
                                stC          ||           tE          |           |j#        |_$        |j        j        s|j        j%        rFtM          j'        |j(                   |j        j%        s!tS          ||          }	tU          |	||           |j        j+        r-ddl,m-}
  |
|j.        |j/        |j        j0        |j                   |S )Nr;  g      ?z=Redoing load_graph without cache because too much was missingFTc              3  \   K   | ]'}|j         d uo|j                             d          V  (d S )Nrv  )r   r  )r  gs     r   r  zdispatch.<locals>.<genexpr>m  s<      __1d*Fqvv/F/F______r   )
graph_sizestubs_foundgraph_load_timefm_cache_sizezNothing to do?!r  zLoaded graph with z nodes (z.3fz sec)rm  rJ  r   zDError reading fine-grained dependencies cache -- aborting cache loadz.Falling back to full run -- reloading graph...)dump_all_dependencies)1r  r   r   test_envr   rJ  initial_gc_freeze_donerK  disable
load_graphr  rg  re  r   freezeunfreezeenabler  r  rd  sumr  r  r  r   
dump_graphr,  r  r  r  rV  r8  rZ  process_graphr  rG  r  r[  r   add_all_protocol_depsr  r  r  	dump_depsr  r  r   r   r  )r   r   r  rs  r   r   r  rW  r  r  r  s              r   rZ  rZ  @  s   gw'''	B O$*,,	99& : 	
w((E %%'' -CJJG9L,L,LSTTT %7G,, O$&*,,	99& : 		

	!% < <!&r!;2	Bu::__PUP\P\P^P^_____b'3;<<	      f----KKKSZZKKbKKKKLLL! 5&!!! ) 6W-K-K-M-M 6Y[[&w66DIKK",<===##/G  ]}a00144M!!!KK^___$)G!KKHIIIGWf555
 ))++ 8eW%%%w''''.'?$?- 	81Y 	8
 ,W_===?; 8/?? 777  
::::::OW.0NPWP_	
 	
 	
 Lr   c                  "    e Zd ZdZddZdd
ZdS )NodeInfoz,Some info about a node in the graph of SCCs.indexr   r  r  r   r   c                D    d|z  | _         || _        i | _        i | _        d S )Nzn%d)node_idr  sizesr   )r   r  r  s      r   r   zNodeInfo.__init__  s&    u}%'
$&			r   r   c           	     \   t          | j                                                  }d                    t	          j        | j                  t	          j        |          t	          j        | j                  t	          j        | j                  t	          j        | j                            S )zConvert to JSON string.z[{}, {}, {},
     {},
     {}])	r  r  r  r|  r  r"  r  r  r   )r   
total_sizes     r   r"  zNodeInfo.dumps  s~    **,,--
188Jt|$$Jz""Jtx  Jtz""Jty!!
 
 	
r   N)r  r   r  r  r   r   r   r   )r   r   r   r   r   r"  r   r   r   r  r    sB        66' ' ' '	
 	
 	
 	
 	
 	
r   r  c                    t          | d          5 }t          |          D ](}|                    | d||         j         d           )	 ddd           dS # 1 swxY w Y   dS )z3Dump timing stats for each file in the given graph.r  r@  r  N)r  r  r'  rg   )r   r   r  r   s       r   r^  r^    s    	dC 9A-- 	9 	9BGGr77E"I37778888	99 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9s   9AAAc           	     j   t          | d          5 }t          |          D ]x}||         j        s|                    | d           t          ||         j                  D ]5}||         j        |         }|                    |dd|dz  dd           6y	 ddd           dS # 1 swxY w Y   dS )	z-Dump per-line expression type checking stats.r  z:
z>5r@  i  z8.1fr  N)r  r  r  r'  )r   r   r  r   r  	line_times         r   r`  r`    s   	dC >A-- 	> 	>B96 GGrJJJuRyBCC > >!"I?E	4<<<Yt^<<<<====>		>> > > > > > > > > > > > > > > > > >s   B	B((B,/B,c                   |pt           j        }g }t          |           }t          |          D ]?\  }}t	          | |j                  }t          ||          }|                    |           @i }|D ]}|j        D ]}	|j	        ||	<   |D ]}|j        D ]}	| |	         }
d}|
j
        r6	 t          j
                            |
j
                  }n# t          $ r Y nw xY w||j        |	<   |
j        D ]S}||
j        v rH|
j        |         }||v r7||         }||j	        k    r$||j        vs||j        |         k     r
||j        |<   Tt%          dd                    d |D                       z   dz   |           dS )zDump the graph as a JSON string to stdout.

    This copies some of the work by process_graph()
    (sorted_components() and order_ascc()).
    r   r  z,
 c              3  >   K   | ]}|                                 V  d S r   )r"  )r  nodes     r   r  zdump_graph.<locals>.<genexpr>  s*      ;;TDJJLL;;;;;;r   z
]r  N)r   r  sorted_componentsr  
order_asccr   r  r  r  r  r   r   getsizer+  r  rM  r  r   r   r2  )r   r  nodesr  r  asccr  r  	inv_nodesmodr  rj  r  rG  dep_ids                  r   r  r    s    !szFEU##DT??  4--3TI * *8 	* 	*C!\IcNN	* 4 48 	4 	4C#JEDz 7??5:66DD   D"DJsO) 4 4%****3/Ci''!*3!T\11"$)33sTYv=N7N7N03DIf-4	4$ 
#;;U;;;;;
;e
C&QQQQQQs   )$C
CC	old_graphGraph | Nonenew_moduleslist[State] | Nonec                   ||ni }||ng }t                      }| D ]$}	 t                              |j        |j        |j        |j                   n# t          $ r Y Ew xY wj        |v rj	        
                    j        j        j                                       ddj         d|j                 j         dd           dt           d	}                    d|           j	                                         |j        <   |                               |                    |j                   &d
 |                                D             }	|D ],j        J fdj        D             }
                                sfdj        D             }ng }j        |
z   j        z   D ]}|j        v o||v}|rm||vrit2          j        j        |<                                   rj        j        r4j                            |                                          j        |<   ||vrK	 |j        v r t                              |dd          }n9t                              |ddj         !                    |d                    }|j        ry|j"        }||	v ri                    dd|	|         j         d|j         dd           dt           d}                    d|           j	                                         ||	|<   |j        |vsJ |j                    |||j        <   |                    |           # t          $ r" |j#        v r$                    |           Y w xY wѐ.|                                D ]Rj        %                                D ]6}||v r0&                    |           j        '                    |d           7S|                                D ]3fdj        D             }|D ]}||vr$                    |           4j(        )                    j*                   dj	        _+        |S )a  Given some source files, load the full dependency graph.

    If an old_graph is passed in, it is used as the starting point and
    modified during graph loading.

    If a new_modules is passed in, any modules that are loaded are
    added to the list. This is an argument and not a return value
    so that the caller can access it even if load_graph fails.

    As this may need to parse files, this can raise CompileError in case
    there are syntax errors.
    N)r   r   r!  r   r  zDuplicate module named "z" (also at "z")Tr.  z
            See a   for more info
            Common resolutions include:
                a) using `--exclude` to avoid checking one of them,
                b) adding `__init__.py` somewhere,
                c) using `--explicit-package-bases` or adjusting `MYPYPATH`
            c                ,    i | ]}|j         	|j        |S r   )r   r  )r  r  s     r   rl  zload_graph.<locals>.<dictcomp>6  s#    EEERRWE"*bEEEr   c                Z    g | ]'}j                             |          t          k    %|(S r   rR  r  r  r  s     r   r  zload_graph.<locals>.<listcomp>G  s4    aaa"-:K:KC:P:PT`:`:`:`:`:`r   c                4    g | ]}t          |          |S r   rS  )r  r  r   s     r   r  zload_graph.<locals>.<listcomp>I  s)    VVVS5GW5U5UVSVVVr   )r   r   r!  r   r  r   )r   r   r!  r   r  r  z7Source file found twice under different module names: "z" and "r   z!
                            See a   for more info
                            Common resolutions include:
                                a) adding `__init__.py` somewhere,
                                b) using `--explicit-package-bases` or adjusting `MYPYPATH`
                            c                Z    g | ]'}j                             |          t          k    %|(S r   rR  r  s     r   r  zload_graph.<locals>.<listcomp>  s4    ]]]Cbm6G6G6L6LP\6\6\C6\6\6\r   F),r   r   r  r  r   rs  followedr  r   r   r  r  r   r5  r   r  r  r  r`  r  rK  rM  r  rN  r  r  r  r  ra  r7  r  r  r  rV  r  r  r  r  r  r  rF  set_modulesr   rQ  )r   r   r  r  r   newentry_pointsbsresolution_note
seen_filesrM  addedr  ignorednewst
newst_pathindirectr  s    `               @r   r  r    s   & !* 5992E
 %0++bC UUL $ $		9Ww "O !  BB  	 	 	H	5E>>N##BHbeW_EEEMMT25TTeBEl>PTTT    
&  O ""4999N&&(((be

2#### FE5<<>>EEEJ  K& K&|''' baaaraaa--// 	VVVVBMVVVEE
 E<,.> 6	& 6	&CR..J3l3JG 4&3e++/@/J', 5577 +7?;^ +29/2R2R3 3((** *3/ E!!+&bl** !&"dGZ\ !0 ! ! !&"!%#'$+)+(*(;(;C(C(C !0 ! ! z 7%*]
%33#MM $!R$.z$:$=!R !RFKh!R !R !R(,	 *   / !6/  /  / O $224III#N6688816
:. 85000%(000&+E%(OJJu%%%%7 & 4 4 4b111..s3334# "6	&t llnn 7 7=%%'' 	7 	7Ce||!!#&&&'++C666	7 llnn , ,]]]]2?]]] 	, 	,C%&&s+++	, Nw///$)GN!Ls$   4A
A%$A%A"M  (NNr  c                    t          | |j                  }d|j        v r;t          |d          }|                    d           |                    d           |S )zApply extra heuristics on top of order_ascc().

    This should be used only for actual SCCs, not for "inner" SCCs
    we create recursively during ordering of the SCC. Currently, this
    has only some special handling for builtin SCC.
    r   T)reverse)r  r   r  r  r  )r   r  r  s      r   order_ascc_exr    sa     UDL
)
)C T\!!S$''' 	

:

:Jr   c                P   | j         D ]}||         }|j        
J d            |j        |j        j        k    r1|j        D ]d}|j                            |          t          k    r?|j        |         j        }|| j        k    rC|	                    | j        |          s|c c S edS )zVerify all indirect dependencies of this SCC are still reachable via direct ones.

    Return first unreachable dependency id, or None.
    Nz!Must be called on fresh SCCs only)
r   r  r{  rM  r  rV  r  r  r   r  )r  r   r   r   r  r  
dep_scc_ids          r   verify_transitive_depsr    s    
 l  2Yw""$G""" 666? 	 	C}  %%55$237:
((44TWjII JJJJJ	 4r   r  r  tuple[list[SCC], list[SCC]]c                   g }g }| D ]}fd|j         D             }| }t                      }|j         D ]M}	|	         j        D ]=}
|
v r7|
         j        |	         j        |
         k    r|                    |
           >N|o| }d}|rt          ||          }|d}|j        r|rd}n|rbd}||j         k    r)|dd                    t          |                     dz  }|r)|d	d                    t          |                     dz  }n2|r'd
d                    t          |                     d}n	|J d| }d                    |j                   }|r|j	        r|
                    d| d| d           fd|j         D             }t          |          dk    r|}nt          |          }|D ]x}	|	         j        ri|j                            |	         j                  }|j                            ||	         j        |j                  }|                    ||d           y|                    |           F|j        rQt          |j                   }|dk    r|                    d| d|            n|                    d|||fz             |                    |           ||fS )a  Split a list of ready SCCs into stale and fresh.

    Fresh SCCs are those where:
    * We have valid cache files for all modules in the SCC.
    * There are no changes in dependencies (files removed from/added to the build).
    * The interface hashes of dependencies matches those recorded in the cache.
    * All indirect dependencies are still reachable via direct ones.
    The first and second conditions are verified by is_fresh().
    c                H    h | ]}|                                          |S r   )r  r  r   r   s     r   	<setcomp>z"find_stale_sccs.<locals>.<setcomp>  s.    KKKBeBi6H6H6J6JKRKKKr   NFfreshzinherently staler  r@  r  z with stale deps (zstale due to deps (z*stale due to stale indirect dep(s): first zFound z SCC (c                .    g | ]}|         j         |S r   )rI  r  s     r   r  z#find_stale_sccs.<locals>.<listcomp>  s%    SSSrU2Y=RSSSSr   r   	formatterzScheduling SCC singleton (z) as z$Scheduling SCC of size %d (%s) as %s)r   r   r  r~  r`  r  r  r2  r  r  rX  rg  r  rI  r   simplify_pathr  format_messagesrH  r  r  re  )r  r   r   
stale_sccs
fresh_sccsr  	stale_sccr  
stale_depsr   r  stale_indirect	fresh_msgscc_strmods_with_errorsr  r   	formattedrj  s    `                 r   find_stale_sccsr    s    JJ @$ @$KKKK$,KKK	 UU
, 	( 	(BRy+ ( (%<<E#J$=rAUVYAZ$Z$ZNN3'''( (j.
  	3D%IIN)" 	- Z#		 
Z.	,,!Dchhvi/@/@&A&A!D!D!DDI V!Uchhvj?Q?Q6R6R!U!U!UUI ZQ#((6*;M;M2N2NQQQ		%111YYY	hht|,,G 	$& DByBBBBBCCCSSSST\SSS#$$))& $E400 A A9( A">77b	HHD ' > >eBi3w?V !? ! !I ((y%@@@d####& 4<((199KK VW V V9 V VWWWWKK>$QZA[[   d####z!!r   c                   t          | |j                  }t                      }|                    |           |                                }|j        D ]H}t                              t          |j	                             |j	        
                    |           It          |           }|                    dt          |          t          d |D                       fz             d |D             }||_        d |D             |_        |D ]}|j        D ]}	||j        |	<   t'          |          }
t                      }|
                    |           |                                }|j        D ]H}t                              t          |j	                             |j	        
                    |           I|j        D ].}t                              t          |j	                             /t)          t+          |j        j                            |_        g }t)                      }|D ]4}|j        s|                    |           |                    |           5d}|s|s|rt9          || |          \  }}|rA|D ]&}|j        D ]}| |                                          '|                    | |           d}|r|}n|                    |           \  }}}|j        s|rJ |                                 D ]\  }\  }}tB          "                    |          }|| |         j#        k    r'| |         $                                 || |         _#        |%                    |j&        '                    | |         j(                  |d           g }|D ]t}|j)        D ]j}||         j*        +                    |j,                   ||         j*        s6|-                    ||                    |                    ||                    ku||||.                    d	t_          j0        |j1                              d
S )z'Process everything in dependency order.r   r  z#Found %d SCCs; largest has %d nodesc              3  >   K   | ]}t          |j                  V  d S r   )rg  r   r  s     r   r  z process_graph.<locals>.<genexpr>'  s-      ?a?aUXCK@P@P?a?a?a?a?a?ar   c                    i | ]
}|j         |S r   r   r  s     r   rl  z!process_graph.<locals>.<dictcomp>)  s    ------r   c                    g | ]	}|j         
S r   r  r  s     r   r  z!process_graph.<locals>.<listcomp>+  s    000C000r   r  FTzTransitive deps cache size: N)2GraphMessager  r*   r'  r(  r-  
AckMessagerP  rM   r   r   r  re  rg  r  r  r  r   r  SccsDataMessager   r%  r   r   r  r   r  r`  r  r  r  r  r  r  fromhexr~  r  r  r   r  r  r   r   discardr   r  rX  r   	getsizeofr  )r   r   graph_messager0  
graph_datar2  r  r  r  r  sccs_message	sccs_dataready	not_readystill_workingstaler  r   doner  r~  r   new_hashdone_scc	dependents                            r   r  r    s   
 !ug>UVVVM
--CJ/ , ,,,---
++++U##DKK-TC?a?a\`?a?a?a<a<a0bb   .----I!G004000G 0 0k 	0 	0F,/G!&))	0 #---L
--CsI/ + +,,---	****/ . .,,----uW_%@AABBG EI  x 	LLMM#M
  79  7  7&ueW==u 	! 2 2+ 2 2B"I//11112NN5%((( M
  	cDD+2+@+@+G+G(D- ? #""""07 c c,,^V ==88uRy777"I22444/7E"I,$$W^%A%A%)/%R%RTZ\abbbb 	7 	7H%7 7 7	)$3;;HKHHH +: 7$$Yy%9:::LL9!5666	79   79  7  7B MM_w?\1]1]__`````r   AbstractSet[str]pri_maxc                    t          |          dk    rt          |          S t                      }|D ]S} |         }|j        D ]A}||v r;|j                            |t                    }|k     r|                    |           BTt          |          dk    rt          | fd          S t          |          t           |          } fd|D             S )a%  Come up with the ideal processing order within an SCC.

    Using the priorities assigned by all_imported_modules_in_file(),
    try to reduce the cycle to a DAG, by omitting arcs representing
    dependencies of lower priority.

    In the simplest case, if we have A <--> B where A has a top-level
    "import B" (medium priority) but B only has the reverse "import A"
    inside a function (low priority), we turn the cycle into a DAG by
    dropping the B --> A arc, which leaves only A --> B.

    If all arcs have the same priority, we fall back to sorting by
    reverse global order (the order in which modules were first
    encountered).

    The algorithm is recursive, as follows: when as arcs of different
    priorities are present, drop all arcs of the lowest priority,
    identify SCCs in the resulting graph, and apply the algorithm to
    each SCC thus found.  The recursion is bounded because at each
    recursion the spread in priorities is (at least) one less.

    In practice there are only a few priority levels (less than a
    dozen) and in the worst case we just carry out the same algorithm
    for finding SCCs N times.  Thus, the complexity is no worse than
    the complexity of the original SCC-finding algorithm -- see
    strongly_connected_components() below for a reference.
    r   c                     |          j          S r   r  )r   r   s    r   r?  zorder_ascc.<locals>.<lambda>  s    E"IO+; r   r@  c                <    g | ]}t          |          D ]}|S r   )r  )r  sssr   r"  s      r   r  zorder_ascc.<locals>.<listcomp>  s2    EEE"jG&D&DEEAEEEEr   )rg  r  r   rM  r  rV  r  r`  r  r  sorted_components_inner)	r   r  r"  
pri_spreadr   r  r  rG  r  s	   ` `      r   r  r  k  s    8 4yyA~~DzzJ ( (b	% 	( 	(Cd{{&**399==NN3'''		(
 :!d ; ; ; ;<<<<*ooG"5$88DEEEEEEEEEr   r   c                .   t          j                     }|D ]}| |                                          t          j                     }|D ]}| |                                          t          j                     }|                    ||z
  ||z
             dS )zProcess the modules in one group of modules from their cached data.

    This can be used to process an SCC of modules. This involves loading the tree (i.e.
    module symbol tables) from cache file and then fixing cross-references in the symbols.
    )process_fresh_timeload_tree_timeN)r   r  r  rd  )r   r   r   rs  r   r  rW  s          r   process_fresh_modulesr.    s     
B  b		B # #b	  """"	BbbIIIIIr   
from_cacheset[str] | None dict[str, tuple[str, list[str]]]c                    t          j                     }t                      |j                                        }|r^|                                }|j        v s|v r$                    |           |                    j        |         j                   |^rfdj	        D             }j
        r)|D ]&}|j        D ]}	 |	                                          '                    dt          |           d           j        j        skt#          j                    dk    rTj        t(          k     sj
        r=t+          j        d           t+          j        d           t+          j                     |D ]D}j                            |j                   t3           t5          |j                             Ej        j        swt#          j                    dk    r`j        t(          k     sj
        rIxj        dz  c_        t+          j                     t+          j                     t+          j                     t          j                     }
t=           |          }t          j                     }|}|D ]K} |         j        s|r ||v r |                              d	            |         !                                 Ld
|v r d
         j"        }|s
J d            tF          j$        %                     |j&                   t          j                     }t          |          }|D ]} |         '                                  |         (                                j)        sI|*                    |            |         +                                  |         ,                                 |ro|D ]j}||vr |         -                                sI|*                    |            |         +                                  |         ,                                 k|o|D ]6} |         .                                  |         /                                 7t          j                     }i }i }i }|D ]} |         j0        j&        j1        vrj&        2                     |         j0                  }j&        3                     |         j0        |j4                  }5                    j&        6                     |         j0                  |d           |||<   |||<    |         7                                ||<   |D ]f}||         }||\  }} fd |         j8        D             |_9        tu          ||           tw          ||<                    |g                      gj                            |j                   =                    |
|z
  ||
z
  ||z
  ||z
  t          j                     |z
             i }|D ]:} |         j>        ?                                |<                    |g           f||<   ;|S )z0Process the modules in one SCC from source code.c                2    g | ]}|v j         |         S r   )r  )r  sidr   missing_sccss     r   r  z%process_stale_scc.<locals>.<listcomp>  s2     
 
 
'*3,CVCVGc"CVCVCVr   zProcessing z fresh SCCsr;  r   )
generationr   Tr_  r   z The typing module was not parsedr  FNc                *    g | ]}|         j         S r   )r~  )r  r  r   s     r   r  z%process_stale_scc.<locals>.<listcomp>(  s     WWW5:4WWWr   )load_missing_timeorder_scc_timesemanal_timetype_check_timeflush_and_cache_time)@r   r   r   r  r  r  r`  r  r  r  r  r   r  re  rg  r   r  r   rJ  r
  r   rK  collectr  r   r.  r  r  r  r  r  r  rW  re  rd  r  semanal_mainsemantic_analysis_for_sccr   r  r  deferred_nodesr  r*  r9  r%  rg  rk  r  r_  file_messagesr  rH  r  r  r  rM  r  rm  r  rV  rd  r~  hex)r   r  r   r/  rs  sccs_to_finddep_sccfresh_sccs_to_loadprev_sccr  r  r  rW  r  r   
typing_modt3unfinished_modulest4meta_tupleserrors_by_idformatted_by_idr   r  rN  r  rS  
scc_resultr5  s   ` `                         @r   r  r    s   
 
B55L9>>##L
 =""$$g'''7l+B+B!!!G-g6;<<<  =  +
 
 
 
 
.5.?
 
 
 " 	0 / 0 0&. 0 0F&M--////0 	F#&8"9"9FFFGGG(	.00I== ),@@@GD[@ J!$$$$J!$$$$JLLL* 	L 	LH!!(+...!%0@)A)A7KKKK(	.00I==),@@@GD[@$$)$$IKKKKMMMIKKK	B
t
$
$C	BE   9> 	@Z 	@B*,<,<"I))$)??? 	b	3 8_)
======//sGNKKK	B U & &b	'')))Ry%%''6 	&&&r***"I44666"I##%%%
 * 	* 	*B+++93355 *"**2...b	88:::b	'')))  *  7 7b	..000b	446666	BKLO 	2 	29?'.">>>^11%)/BBF66b	73J 7  I   !=!=eBio!N!NPY[`aaa%L"+OB)//11B H H _
$iWWWWb	@VWWWw	222)\%5%5b"%=%=wGGGG$'"""r'Bw"WR!Y[[2-     J U Ur155779L9LRQS9T9TT
2r   raw_sccsIterator[set[str]]edgesdict[str, list[str]]dict[SCC, set[SCC]]c                   d | D             }i |D ]}|j         D ]}||<   i }|D ]S}|j         D ]I}|                    |t                                                    fd||         D                        JT|D ]f}||                             |           ||         D ]@}|j                            |j                   |j                            |j                   Ag|S )zGTurn raw SCC sets into SCC objects and build dependency graph for SCCs.c                ,    g | ]}t          |          S r   )r   )r  raw_sccs     r   r  z%prepare_sccs_full.<locals>.<listcomp>=  s    111WCLL111r   c              3  (   K   | ]}|         V  d S r   r   )r  r  scc_maps     r   r  z$prepare_sccs_full.<locals>.<genexpr>E  s'      6Y6Yws|6Y6Y6Y6Y6Y6Yr   )	r   r  r   r  r  r   r`  r   r   )rO  rQ  r  r  r   scc_deps_maprD  rX  s          @r   prepare_sccs_fullrZ  9  s<    21111DG  + 	 	BGBKK	(*L Z Z+ 	Z 	ZB##C//666Y6Y6Y6YuUWy6Y6Y6YYYYY	Z / /S!!#&&&#C( 	/ 	/GHLL$$$""7:....	/ r   c                   
 t                     
 
fd
D             }t          t          
|          |          }g }t          |          D ]}t	          | fd          }|D ]x}t           fd|j        D                       |_        ||         D ]!}|j        	                    |j
                   "t          |           }|j        D ]}	| |	         _        y|                    |           |S )zReturn the graph's SCCs, topologically sorted by dependencies.

    The sort order is from leaves (nodes without dependencies) to
    roots (nodes on which no other nodes depend).
    c           	     @    i | ]}|t          |t                    S r   )deps_filteredr  )r  r   r   verticess     r   rl  z%sorted_components.<locals>.<dictcomp>W  s)    UUUbRuhLAAUUUr   c                F    t          fd| j        D                        S )Nc              3  2   K   | ]}|         j         V  d S r   r%  r  s     r   r  z6sorted_components.<locals>.<lambda>.<locals>.<genexpr>d  s)      9`9`b%)/9`9`9`9`9`9`r   )r  r   r  r   s    r   r?  z#sorted_components.<locals>.<lambda>d  s+    c9`9`9`9`TWT_9`9`9`6`6`5` r   r@  c              3  2   K   | ]}|         j         V  d S r   )r   )r  midr   s     r   r  z$sorted_components.<locals>.<genexpr>f  s*      LLc
 4LLLLLLr   )r   rZ  rD   rE   r  r  r   r   r   r  r   transitive_dep_hashr{  r  )r   rQ  scc_dep_maprF  r  sorted_readyr  r  r{  r   r^  s   `         @r   r  r  O  s7    5zzHUUUUUHUUUE#$A(E$R$RTYZZK
C%% ! ! e)`)`)`)`aaa 	: 	:CLLLLLLLLLCM"3' 5 5%,,SV4444 1e<<Nk : :+9b	((:

<    Jr   r^  list[AbstractSet[str]]c                      fdD             }t          t          |                    }g }t          t          ||                    D ])}|                    t          | fd                     *|S )a.  Simplified version of sorted_components() to work with sub-graphs.

    This doesn't create SCC objects, and operates with raw sets. This function
    also allows filtering dependencies to take into account when building SCCs.
    This is used for heuristic ordering of modules within actual SCCs.
    c           	     6    i | ]}|t          |          S r   )r]  )r  r   r   r"  r^  s     r   rl  z+sorted_components_inner.<locals>.<dictcomp>{  s)    PPPRuhG<<PPPr   c                <    t          fd| D                        S )Nc              3  2   K   | ]}|         j         V  d S r   r%  r  s     r   r  z<sorted_components_inner.<locals>.<lambda>.<locals>.<genexpr>  s)      5T5T"eBio5T5T5T5T5T5Tr   )r  ra  s    r   r?  z)sorted_components_inner.<locals>.<lambda>  s(    #5T5T5T5TPS5T5T5T2T2T1T r   r@  )r  rD   rE   rC   r  r  )r   r^  r"  rQ  r  rF  r  s   ```    r   r)  r)  r  s     QPPPPPxPPPE-h>>??D
CdE2233 W W

6%%T%T%T%TUUUVVVVJr   c                N    |vrg S | |         fdj         D             S )z.Filter dependencies for id with pri < pri_max.c                d    g | ],}|v j                             |t                    k     *|-S r   rZ  )r  r  r"  r  r^  s     r   r  z!deps_filtered.<locals>.<listcomp>  sI       (??u/33CBBWLL 	LLLr   )rM  )r   r^  r   r"  r  s    ` `@r   r]  r]    sV    		"IE     %   r   r  c                   t          fd| j        D                       }t                      }|D ]6}t          ||           || j        vrt	          ||         j                   7t          |                                          S )zECompute stable snapshot of transitive import structure for given SCC.c                    h | ]=}|         j         D ]-}|         j                            |          t          k    +|.>S r   )rM  r  rV  r  )r  r   r  r   s      r   r  z&transitive_dep_hash.<locals>.<setcomp>  sa     	
 	
 	
Ry-	
 	
 Ry#'',,<<  =<<<r   )r  r   r*   r  rG  r{  r_   r(  )r  r   all_direct_depsr0  r  s    `   r   rd  rd    s    	
 	
 	
 	
k	
 	
 	
 O --C! @ @sF###$$S%-">???S\\^^,,,r   rl  c                "    t          | d          S )Nmissing_stubs)rd   r  s    r   missing_stubs_filers    s    	?333r   rp  r   c                >   t          |           }|rVt          |d          5 }t          |          D ]}|                    | d           	 ddd           dS # 1 swxY w Y   dS t          j                            |          rt	          j        |           dS dS )zWrite a file containing missing stub packages.

    This allows a subsequent "mypy --install-types" run (without other arguments)
    to install missing stub packages.
    r  r  N)rs  r  r  r'  r   r   r   r  )rl  rp  r  r  pkgs        r   ro  ro    s     i((D $__ 	$344 $ $3


####$	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 7>>$ 	IdOOOOO	 	s   +AA"Ac                    | j         j        rdS t          fd| j        j        D                       rdS t          fd| j        j        D                       S )NFc              3  8   K   | ]}t          |          V  d S r   ra   r  dirr   s     r   r  z*is_silent_import_module.<locals>.<genexpr>  s.      
W
WctS))
W
W
W
W
W
Wr   Tc              3  8   K   | ]}t          |          V  d S r   rx  ry  s     r   r  z*is_silent_import_module.<locals>.<genexpr>  s.      \\#"4--\\\\\\r   )r   no_silence_site_packagesr  rr  package_pathtypeshed_path)r   r   s    `r   r  r    sn    / u

W
W
W
WW5I5V
W
W
WWW t\\\\9M9[\\\\\\r   r  rb  rq  rr  c                ^   ddl m} | j        sd S t          | j        | j        |          \  }}}d                    |                    d          d d                   dz   }|                    d          rJ  || j        |          }|	                    |t          |                     d S )Nr   )get_undocumented_ref_info_jsonr-  z
.refs.json)mypy.refinfor  rd  r  r   r  r2  r3  r  r'  r   )	r  rb  r   rq  r  rI  rT  ref_info_filer  s	            r   r4  r4    s     <;;;;;: %ehWEEOAy!HHY__S11#2#677,FM'',,,,,..uz8DDIOOM:i#8#899999r   e   z
Final[Tag]ACK_MESSAGEf   SCC_REQUEST_MESSAGEg   SCC_RESPONSE_MESSAGEh   SOURCES_DATA_MESSAGEi   SCCS_DATA_MESSAGEj   GRAPH_MESSAGEc                  2    e Zd ZdZed
d            ZddZd	S )r  z4An empty message used primarily for synchronization.r0  r(   r   c                R    t          |          t          k    sJ t                      S r   )r   r  r  r  r0  s     r   rP  zAckMessage.read  s#    }}++++||r   r*   r   c                0    t          |t                     d S r   )r    r  )r   r0  s     r   r'  zAckMessage.write  s    #{#####r   N)r0  r(   r   r  rm  )r   r   r   r   rq  rP  r'  r   r   r   r  r    sL        >>   [$ $ $ $ $ $r   r  c                  :    e Zd ZdZdd
Zedd            ZddZdS )r*  z
    A message representing a request to type check an SCC.

    If scc_id is None, then it means that the coordinator requested a shutdown.
    r   r   r  dict[str, list[ErrorInfo]]r  +dict[str, tuple[bytes, FileRawData | None]]r   r   c               0    || _         || _        || _        d S r   r  )r   r   r  r  s       r   r   zSccRequestMessage.__init__  s     * r   r0  r(   c           
        t                    t          k    sJ t          t                    fdt	          t                              D             fdt	          t                              D                       S )Nc           	     |    i | ]8}t                    fd t          t                              D             9S )c                8    g | ]}t          j                  S r   )r@   rP  r  s     r   r  z5SccRequestMessage.read.<locals>.<dictcomp>.<listcomp>  s#    WWW	s 3 3WWWr   )r   r%  r  r  s     r   rl  z*SccRequestMessage.read.<locals>.<dictcomp>  sW        WWWWU=QTCUCU=V=VWWW  r   c                    i | ]D}t                    t                    t                    rt          j                  nd fES r   )r  r+   r   rP   rP  r  s     r   rl  z*SccRequestMessage.read.<locals>.<dictcomp>  s_       
 	 c""sOO-6s^^EK$S)))%  r   r  )r   r  r*  r.   r%  r  r  s    `r   rP  zSccRequestMessage.read  s    }} 33333 $$   }S1122     
 }S1122  
 
 
 	
r   r*   c                   t          |t                     t          || j                   t	          |t          | j                             | j                                        D ]L\  }}t          ||           t	          |t          |                     |D ]}|	                    |           Mt	          |t          | j
                             | j
                                        D ]`\  }\  }}t          ||           t          ||           |t          |d           ;t          |d           |	                    |           ad S )NFT)r    r  r3   r   r  rg  r  r  r   r'  r  r  r   r   )r   r0  r   r   r5  r  r  rV  s           r   r'  zSccRequestMessage.write  s\   #*+++c4;'''sC 233444 .4466 	! 	!LD&c4   3F,,, ! !C    !sC..///59]5H5H5J5J 	$ 	$1C1&3$$$12223&&&&3%%%s####	$ 	$r   N)r   r   r  r  r  r  r   r   )r0  r(   r   r*  rm  r   r   r   r   r   rq  rP  r'  r   r   r   r*  r*    sf         	! 	! 	! 	! 
 
 
 [
"$ $ $ $ $ $r   r*  c                  B    e Zd ZdZdddddZedd            ZddZdS )r  z
    A message representing a result of type checking an SCC.

    Only one of `result` or `blocker` can be non-None. The latter means there was
    a blocking error while type checking the SCC.
    N)r3  r/  r   r   r3  'dict[str, tuple[str, list[str]]] | Noner/  CompileError | Noner   r   c               H    ||J ||J || _         || _        || _        d S r   )r   r3  r/  )r   r   r3  r/  s       r   r   zSccResponseMessage.__init__0  s;     ???>>>r   r0  r(   c           
        t                    t          k    sJ t                    }t                    }|t          k    rGt	          |t          t                    t                    t                                        S |t          k    sJ t	          |fdt          t                              D                       S )N)r   r/  c                h    i | ].}t                    t                    t                    f/S r   )r  r   r/   r  s     r   rl  z+SccResponseMessage.read.<locals>.<dictcomp>M  sF        "#&&#c8J8J(K  r   )r   r3  )r   r  r   r$   r  r?   r/   r   r0   r"   r%  r  )r  r0  r   tags    `  r   rP  zSccResponseMessage.read?  s    }} 44444#smm,%$]3%7%73VYIZIZ[[   
 ,&&&&%   "=#5#566     r   r*   c                `   t          |t                     t          || j                   | j        n| j        J t          |t                     t          || j        j                   t          || j        j
                   t          || j        j                   d S t          |t                     t          |t          | j                             t!          | j                  D ]B}t#          ||           | j        |         \  }}t%          ||           t          ||           Cd S r   )r    r  r   r   r3  r/  r$   r5   r  r   r,  r6   r  r"   r  rg  r  r  r   )r   r0  r  hex_hasherrss        r   r'  zSccResponseMessage.writeS  s    #+,,,#t{###;<+++c<(((3 5666sDL3444#t|?@@@@@c<(((3DK 0 0111 -- * *sF+++!%V!4$#x(((sD))))	* *r   )r   r   r3  r  r/  r  r   r   )r0  r(   r   r  rm  r  r   r   r   r  r  (  sx          ;?'+         [&* * * * * *r   r  c                  :    e Zd ZdZddZedd	            ZddZdS )r&  z+A message wrapping a list of build sources.r   r   r   r   c                   || _         d S r   r  )r   r   s     r   r   zSourcesDataMessage.__init__i  s    r   r0  r(   c                    t                    t          k    sJ fdt          t                              D             }t	          |          S )Nc                    g | ]V}t          t                    t                    t                    t                    t                              WS r   )rs   r0   r   r  s     r   r  z+SourcesDataMessage.read.<locals>.<listcomp>o  sj     	
 	
 	
  S!!S!!S!!S!!# 	
 	
 	
r   r  )r   r  r%  r  r&  )r  r0  r   s    ` r   rP  zSourcesDataMessage.readl  sh    }} 44444	
 	
 	
 	
 =--..	
 	
 	
 "'2222r   r*   c                Z   t          |t                     t          |t          | j                             | j        D ]k}t          ||j                   t          ||j                   t          ||j                   t          ||j	                   t          ||j                   ld S r   )r    r  r  rg  r   r6   r   r  rs  base_dirr   r  )r   r0  r  s      r   r'  zSourcesDataMessage.write{  s    #+,,,sC--..., 	) 	)B#rw'''#ry)))#rw'''#r{+++sBK((((	) 	)r   N)r   r   r   r   )r0  r(   r   r&  rm  r  r   r   r   r&  r&  f  sb        55    3 3 3 [3) ) ) ) ) )r   r&  c                  :    e Zd ZdZddZedd	            ZddZdS )r  zAA message wrapping the SCC structure computed by the coordinator.r  r  r   r   c                   || _         d S r   r  )r   r  s     r   r   zSccsDataMessage.__init__  s    			r   r0  r(   c                    t                    t          k    sJ fdt          t                              D             }t	          |          S )Nc           	         g | ]G}t          t          t                              t                    t	                              HS r   )r   r   r/   r   r-   r  s     r   r  z(SccsDataMessage.read.<locals>.<listcomp>  sS     
 
 
 M#&&''#c8J8JKK
 
 
r   r  )r   r  r%  r  r  )r  r0  r  s    ` r   rP  zSccsDataMessage.read  sf    }} 11111
 
 
 
=--..
 
 
 D))))r   r*   c                :   t          |t                     t          |t          | j                             | j        D ][}t          |t          |j                             t          ||j	                   t          |t          |j                             \d S r   )r    r  r  rg  r  r5   r  r   r   r   r2   r   )r   r0  r  s      r   r'  zSccsDataMessage.write  s    #()))sC	NN+++9 	2 	2C3s{ 3 3444c36"""3sx 0 01111	2 	2r   N)r  r  r   r   )r0  r(   r   r  rm  r  r   r   r   r  r    sb        KK    * * * [*2 2 2 2 2 2r   r  c                  <    e Zd ZdZddZeddd            ZddZd	S )r  z?A message wrapping the build graph computed by the coordinator.r   r   r  r  r   r   c               J    | _         || _        fdD             | _        d S )Nc                .    h | ]}|         j         |S r   )r  )r  r  r   s     r   r  z(GraphMessage.__init__.<locals>.<setcomp>  s%    LLLfv9KL6LLLr   )r   r  r/  )r   r   r  s    ` r   r   zGraphMessage.__init__  s1    
.LLLLLLLr   Nr0  r(   r   BuildManager | Nonec                d   J t                    t          k    sJ fdt          t                              D             }fdt          t                              D             }t	          ||          }fdt          t                              D             |_        |S )Nc                b    i | ]+}t                    t                                        ,S r   )r  r   rP  )r  rI  r0  r   s     r   rl  z%GraphMessage.read.<locals>.<dictcomp>  s1    aaa!s##UZZW%=%=aaar   c                J    i | ]}t                    t                     S r   r  r  s     r   rl  z%GraphMessage.read.<locals>.<dictcomp>  s)    ```=--x}}```r   r	  c                .    h | ]}t                    S r   )r  r  s     r   r  z$GraphMessage.read.<locals>.<setcomp>  s!    TTTQmC00TTTr   )r   r  r%  r  r  r/  )r  r0  r   r   r  r  s    ``   r   rP  zGraphMessage.read  s    """}}----aaaaau][^M_M_G`G`aaa````eMZ]L^L^F_F_```UOLLLTTTT%c@R@R:S:STTTr   r*   c                6   t          |t                     t          |t          | j                             | j                                        D ]*\  }}t          ||           |                    |           +t          |t          | j                             | j                                        D ]%\  }}t          ||           t          ||           &t          |t          | j
                             | j
        D ]}t          ||           d S r   )r    r  r  rg  r   r  r  r'  r  r   r/  )r   r0  r  r  r  r  s         r   r'  zGraphMessage.write  s   #}%%%sC
OO,,,!Z--// 	 	MFE3'''KKsC 455666"288:: 	# 	#NFF3'''c6""""sC00111o 	( 	(F3''''	( 	(r   )r   r   r  r  r   r   r   )r0  r(   r   r  r   r  rm  r  r   r   r   r  r    sk        IIM M M M     [( ( ( ( ( (r   r  )r   r   r   r   )NNNNNNN)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  r7  r  r  r  r   r  r   r  r8  r-  r9  r   r   )r   r{   r  r7  r   r   r  )r   r   r   r{   r   r   )r  rS   r  r   r   r   )r   r{   r   rA   r  r   r   r  )
r   r{   r   rA   r  r   r  r8  r   r  )r  r  r   r   )r   r   r  r   r  r   r   r   )r?  rf  r   r  )r  r  r   r   r   r   r   r   )r   rf  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   r  r   r  r   r   r
  )r   r{   r   r   )r  r   r   r   rn  )r   r{   r  r  r   rq   )r!  r   r   r   )r   r   r   r   r   r{   r   r(  )r   r   r   r   r   r4  )
r   r   r   r   r   r   r=  r  r   r>  )r  r]  r   r   r   r   r^  r  r   r   r   r]  )rs  r   r   r   )r   r   r   r   rd  rU   rM  r  rN  r  r  r  rw  rx  rO  ry  rP  ry  rz  r  r{  r  r  r   r^  r  r   r   r   r|  )r  r%   r   r   rS  r   r   r   )rS  r   rI  r  r   r   r   r   rl  )r   r   r   r   r   r{   r  r  r  r   r  r  r  r  r  r  r   rt  )rN  r  r   r   r   r  )rM  r  r   r   r   r  )r   r   r   r   r   r   )r   r   r   r   r   rw   )r   r   r   r   r   r  )r   r   r  r   r  r   rB  r   r  rv   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   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   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/  r0  r   r1  )rO  rP  rQ  rR  r   rS  )r   r   r   r  )r   r   r^  r!  r"  r   r   rg  )
r   r   r^  r!  r   r   r"  r   r   r  )r  r   r   r   r   r  )rl  r   r   r   )rl  r   rp  r   r   r   )r   r   r   r   r   r  )
r  r   rb  rq   r   r{   rq  rr  r   r   (3  r   
__future__r   r   rr  rK  r  r   r!  r   r  re  r   r   r   r   collections.abcr   r   r   r   r   AbstractSetheapqr	   r
   textwrapr   r   r   r   r   r   r   r   r   r   r   r   r   librt.base64r   librt.internalr   r   r   r  r   r  r   r   r   rG  r   r  r   r  r    mypy.semanal_mainr  
mypy.cacher!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   mypy.checkerr7   mypy.defaultsr8   r9   r:   r;   mypy.error_formatterr<   r=   mypy.errorcodesr>   mypy.errorsr?   r@   rA   rB   mypy.graph_utilsrC   rD   rE   mypy.indirectionrF   mypy.ipcrG   rH   rI   rJ   rK   rL   rM   rN   mypy.messagesrO   
mypy.nodesrP   rQ   rR   rS   rT   rU   rV   mypy.optionsrW   mypy.partially_definedrX   mypy.semanalrY   mypy.semanal_pass1rZ   	mypy.utilr[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rO  ri   rj   r  mypy.config_parserrk   rl   
mypy.fixuprm   mypy.freetreern   mypy.fscachero   mypy.metastorerp   rq   rr   mypy.modulefinderrs   rt   ru   rv   rw   rx   ry   rz   r{   
mypy.parser|   r}   mypy.pluginr~   r   r   mypy.plugins.defaultr   mypy.renamingr   r   
mypy.statsr   mypy.stubinfor   r   
mypy.typesr   r   mypy.typestater   r   r   r   mypy.versionr   r   r   r   r   r  r  r   r   r   r   r   r   r   r6  r)  ra  rM  r  r  r  r  r  r  r  r  r  r  rR  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  rm  rn  r  r'  r  r<  r\  rr  rv  r  rm  r  r  r   r  r   r  r  r  rT  rz  r  r  r}  r|  r  rZ  r  r^  r`  r  r  r  r  r  r  r  r.  r  rZ  r  r)  r]  rd  rs  ro  r  r4  r  r  r  r  r  r  r  r*  r  r&  r  r  r   r   r   <module>r     s  	 	 	 # " " " " "         				  				   				      



   U U U U U U U U U U U U U U # # # # # # # #                              # " " " " "                                                                                    : % $ $ $ $ $            @ ? ? ? ? ? ? ? % % % % % % N N N N N N N N N N N N Q Q Q Q Q Q Q Q Q Q 3 3 3 3 3 3	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ) ( ( ( ( (                  = < < < < < C C C C C C ) ) ) ) ) ) : : : : : :                                $###### $ $ $ $ $ $ K K K K K K K K # # # # # # # # # # # # ( ( ( ( ( ( V V V V V V V V V V                  " ! ! ! ! !             + + + + + + + + B B B B B B B B B B . . . . . . M M M M M M M M & & & & & & W W W W W W W W + + + + + + + + 9 9 9 9 9 9 9 9 , , , , , , , , $ $ $ $ $ $ "  ! ! ! !                g& & & & & \     
               >$ $ $ $ $ $ $ $(6( 6( 6( 6( 6( 6( 6( 6(r0 0 0 0  $IM&*  -1+/b b b b bJ^[ ^[ ^[ ^[B

 

 

 

% % % %
% % % %*    	                            	 	 	 	Y$ Y$ Y$ Y$xO O O O,       .hA hA hA hA hA hA hA hAV: : : :
 * ) ) ) )) ) ) ) ) "  ! ! ! !?[ ?[ ?[ ?[D   4   8 7  6 6 6 6L L L L       (* * * *Z   (   D          	 	 	 	 	   &A &A &A &ART T T T( HM~ ~ ~ ~ ~BC C C CL- - - -H- H- H- H-VB B B B&@ @ @ @"DN       
    Y    @ @ @ @ @ @ @ @T  "&!%e! e! e! e! e!P   @   (	 	 	 	      @,3 ,3 ,3 ,3^; ; ; ;   $( $( $( $(Th h h hV
 
 
 
 
 
 
 
*9 9 9 9	> 	> 	> 	>$R $R $R $R $RT #&*	] ] ] ] ]@   .   *O" O" O" O"dPa Pa Pa Paf EQ ,F ,F ,F ,F ,F^J J J J" SWL L L L L^   ,       F   "	 	 	 	- - - -$4 4 4 4    ] ] ] ]: : : :<     "%  % % % %#&  & & & &#&  & & & & #  # # # #    	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$5$ 5$ 5$ 5$ 5$
 5$ 5$ 5$p;* ;* ;* ;* ;* ;* ;* ;*|) ) ) ) ) ) ) )@2 2 2 2 2j 2 2 20( ( ( ( (: ( ( ( ( (r   