
    X-Phj                    R    d Z ddlmZ ddlZddlmZ ddlmZmZ dd
Z	ddZ
ddZdS )a  This module makes it possible to use mypy as part of a Python application.

Since mypy still changes, the API was kept utterly simple and non-intrusive.
It just mimics command line activation without starting a new interpreter.
So the normal docs about the mypy command line apply.
Changes in the command line version of mypy will be immediately usable.

Just import this module and then call the 'run' function with a parameter of
type List[str], containing what normally would have been the command line
arguments to mypy.

Function 'run' returns a Tuple[str, str, int], namely
(<normal_report>, <error_report>, <exit_status>),
in which <normal_report> is what mypy normally writes to sys.stdout,
<error_report> is what mypy normally writes to sys.stderr and exit_status is
the exit status mypy normally returns to the operating system.

Any pretty formatting is left to the caller.

The 'run_dmypy' function is similar, but instead mimics invocation of
dmypy. Note that run_dmypy is not thread-safe and modifies sys.stdout
and sys.stderr during its invocation.

Note that these APIs don't support incremental generation of error
messages.

Trivial example of code using this module:

import sys
from mypy import api

result = api.run(sys.argv[1:])

if result[0]:
    print('
Type checking report:
')
    print(result[0])  # stdout

if result[1]:
    print('
Error report:
')
    print(result[1])  # stderr

print('
Exit status:', result[2])

    )annotationsN)StringIO)CallableTextIOmain_wrapper Callable[[TextIO, TextIO], None]returntuple[str, str, int]c                    t                      }t                      }	  | ||           d}n:# t          $ r-}t          |j        t                    sJ |j        }Y d }~nd }~ww xY w|                                |                                |fS )Nr   )r   
SystemExit
isinstancecodeintgetvalue)r   stdoutstderrexit_statussystem_exits        H/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mypy/api.py_runr   5   s    ZZFZZF'VV$$$ ' ' '+*C00000!&' ??foo//<<s   - 
A$#AA$args	list[str]c                8     ddl m t           fd          S )Nr   mainc                "     | |d          S )NT)r   r   r   
clean_exit )r   r   r   r   s     r   <lambda>zrun.<locals>.<lambda>H   s    ttfVX\]]]     )	mypy.mainr   r   )r   r   s   `@r   runr"   C   s7    ]]]]]  r    c                >     ddl m d	 fd}t          |          S )
Nr   r   r   r   r   r	   Nonec                    t           j        }t           j        }	 | t           _        |t           _                    |t           _        |t           _        d S # |t           _        |t           _        w xY w)N)sysr   r   )r   r   
old_stdout
old_stderrr   r   s       r   fzrun_dmypy.<locals>.fS   s`    Z
Z
	$CJCJDJJJ#CJ#CJJJ $CJ#CJ####s   #A A2)r   r   r   r   r	   r$   )mypy.dmypy.clientr   r   )r   r)   r   s   ` @r   	run_dmypyr+   L   sF    &&&&&&	$ 	$ 	$ 	$ 	$ 	$ 	$ 77Nr    )r   r   r	   r
   )r   r   r	   r
   )__doc__
__future__r   r&   ior   typingr   r   r   r"   r+   r   r    r   <module>r0      s   + +Z # " " " " " 



       # # # # # # # #= = = =        r    