o
    ҷhX                  	   @  sB  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mZmZ d dl
mZ d dlmZmZ d dlZd dlZd dlZd dlZd dlmZmZ ddlmZmZ dd	lmZ erpd d
lmZm Z  da!zd dl"mZ# W n e$y   eZ#Y nw d;ddZ%d;ddZ&d<ddZ'd=ddZ(e)e(eddZ*e)e(eddZ+d d! e*D Z,ej-j.ej-j/e	j0j1d"kd#d$ej-2d%e,ej-2d&g d'ej-3d(d>d,d-Z4eej-j.ej-j/e	j0j1d"kd#d$ej-2d.e,ej-2d&d/d0gd?d1d2Z5d;d3d4Z6d;d5d6Z7ej-j/e8ej9d7 d8d$d;d9d:Z:dS )@    )annotationsN)PathPurePath)
ModuleType)TYPE_CHECKINGProtocol)RUN_SLOWskip_if_optional_else_raise   )_core_util)slow)IterableIteratorF)r   returnNonec               
   C  sr   zddl m}  W n ty } z
t| W Y d }~nd }~ww ts7| g d}|d r-J |d r3J dad S d S )Nr   )run)z--config-file=z--cache-dir=./.mypy_cachez--no-error-summaryz-czimport trio   T)mypy.apir   ImportErrorr	   mypy_cache_updated)r   errorresult r   K/var/www/html/venv/lib/python3.10/site-packages/trio/_tests/test_exports.py_ensure_mypy_cache_updated'   s   	r   c                  C  sx   t t jt jg} ttD ].}|drqd}| D ]}|t|v r-t||tt|u r-|d7 }qt|| |dks9J qd S )N_r   r   )triolowleveltestingdirr   
startswithgetattrprint)sourcessymbolfoundsourcer   r   r    test_core_is_properly_reexported@   s   

r(   clstypeboolc                 C  s*   z
t d| f W dS  ty   Y dS w )z&Check if a class cannot be subclassed.SubclassTesterTF)types	new_class	TypeError)r)   r   r   r   class_is_finalR   s   r0   moduletypes.ModuleTypeonly_publicIterator[types.ModuleType]c                 c  sf    | V  | j  D ]'\}}|dr|rq	t|tsq	|j| js#q	|| u r(q	t||E d H  q	d S )Nr   )__dict__itemsr!   
isinstancer   __name__iter_modules)r1   r3   nameclass_r   r   r   r9   ]   s   
r9   T)r3   c                 C  s   g | ]}|j qS r   )r8   ).0mr   r   r   
<listcomp>p   s    r>   alphaz<skip static introspection tools on Python dev/alpha releases)reasonmodnametool)pylintjedimypypyright_verifytypesz>ignore:module 'sre_constants' is deprecated:DeprecationWarningstrtmp_pathr   c              
     sP  t  }d+dd}|t|} dkr|d tjD ]}t||d tt|u r.|| q| d	krizd
dlm	} W n t
yQ } z
t| W Y d }~nd }~ww | }	|jd us\J |	|j }
||
}n| dkrtjjdkrxtd zd
d l}W n t
y } z
t| W Y d }~nd }~ww |d  d  d}| }|dd |D }n| dkr(tstd t d }t  t|d} d dd\}  d d   r|  n|}| r|d }n| d  }| sJ | sJ |  }t!"|# }|dd |d $ D }W d    n	1 s"w   Y  nS| dkrxts5td zd
d l%}W n t
yR } z
t| W Y d }~nd }~ww d
d l&}|j'd d!  d"gd#d$}t!"|j(} fd%d&|d' d D }nt) || }|dh8 }|rt*|  d(  d) t*  t+|D ]
}t*d*|  qt) d S ),NsymbolsIterable[str]r   set[str]c                 S     dd | D S )Nc                 S     h | ]	}| d s|qS )r   r!   r<   r%   r   r   r   	<setcomp>       zLtest_static_tool_sees_all_symbols.<locals>.no_underscores.<locals>.<setcomp>r   rI   r   r   r   no_underscores   s   z9test_static_tool_sees_all_symbols.<locals>.no_underscoresr   testsrC   r   )PyLinterrD   cpythonjedi does not support pypyzimport ; .c                 s      | ]}|j V  qd S Nr:   r<   cr   r   r   	<genexpr>       z4test_static_tool_sees_all_symbols.<locals>.<genexpr>rE   z$use --run-slow to check against mypy.mypy_cache*/trior   __init__.data.json
.data.jsonc                 s  s.    | ]\}}| d s|d dkr|V  qdS )rY   kindGdefNrN   )r<   keyvaluer   r   r   r_      s    namesrF   z'use --run-slow to check against pyrightpyrightz--verifytypes=z--outputjsonT)capture_outputc                   s2   h | ]}|d    r|d  t d d qS )r:   r   N)r!   lenr<   xrA   r   r   rP      s    z4test_static_tool_sees_all_symbols.<locals>.<setcomp>typeCompletenessz" can't see the following names in :z    rI   rJ   r   rK   ),	importlibimport_moduler    discard
__future__all_feature_namesr"   removepylint.lintrU   r   r	   __file__get_astsysimplementationr:   pytestskiprD   Scriptcompleter   r   cwdr   nextglobsplitis_direxistsis_fileopenjsonloadsreadr6   rk   
subprocessr   stdoutAssertionErrorr#   sorted)rB   rA   rH   r1   rS   runtime_namesr:   rU   r   linteraststatic_namesrD   scriptcompletionscache
trio_cacher   	mod_cache
cache_file
cache_jsonrk   r   rescurrent_resultmissing_namesr   rp   r   !test_static_tool_sees_all_symbolsw   s   
















r   module_namerD   rE   c                   sX  t t| }dOdd}| dkrtjjdkrtd	 | d
krt	 d  t
  t d}|}|d dd\}}|d d }|rG|| n|}| rR|d }n||d  }| s^J | sdJ | }	t|	 }
W d    n1 szw   Y  tjdP fdd}i }|j D ]{\}}t|tsq|dkr|ttv rq|tjju s|tjj u rqt!tt|h dB }t|tu r|"d |"d tjjdkr|h dO }|dd t#$|D | }| dkr+zdd l%}W n t&y } z
t'| W Y d }~nd }~ww |(d | d!| d"| d}|) }|d#d |D | }n\| d
kr|
d$ | }d%|vs?J d&||d' }d%|v sLJ |d% }|d(d |*d$d)D }|d* dd  D ]}||d% }||d+d |*d$d)D O }qe||8 }nt+d,|| }|| }| dkrt,|j-v rtj.d-kr|/d. | d
krt,|j-v rtj.d-kr|/d/ | d
krt01|rt2|}d0d1 |D }t2||d ksJ | d
krt3j4|j-v rtj.d2kr|/d3 | d
kr|tj5kr|/d4 tj6d5d6htj7d7d8htj8h d9tj9d:htj:d;htj;d7htj<d7htjj=d<d=htjj>h d>i	}| d
krS||v rSt2|}||| 8 }t2||t2||  ksSJ |tj?krc|/d? |/d@ | dkrtj.d-kr|tj6tj@tjAtj9tj;fv r|/dA |/dB |tj6tj@fv r|/dC |/dD |tjtjBtjCfv r|tDjE 8 }| d
krtjFdEkr|h dF8 }| dkrtjFdEkr|h dF8 }| dkrtj.dGkr|tjtjBtjCfv r|/dH tj.dGkrt01|r|/dI |s |r||dJ|| d| < q|r%ddKlGmG} tHdL|  dM| dN || |r*J d S )QNrI   rJ   r   rK   c                 S  rL   )Nc                 S  s$   h | ]}| d r| dr|qS )r   __rN   rO   r   r   r   rP     s    zItest_static_tool_sees_class_members.<locals>.no_hidden.<locals>.<setcomp>r   rR   r   r   r   	no_hidden  s   z6test_static_tool_sees_class_members.<locals>.no_hiddenrD   rV   rW   rE   ra   rb   rY   r   rc   rd   re   r%   rG   dict[str, str]c           	        s   |  d^}}}t d}|| }| s||d  }|rE|d d D ]}|| }q&||d  }| r<|d }n||d d  }n| rM|d }| }t| d | W  d    S 1 sgw   Y  d S )NrY   z3.*/re   rc   rd   rj   )r   r   r   r   r   r   r   r   )	r%   topnamerA   r:   versionr   piece
next_cachefr   r   r   lookup_symbol%  s"   


$z:test_static_tool_sees_class_members.<locals>.lookup_symbolztrio.socket>   __copy__	__final__	__order__	__slots____weakref____deepcopy____getstate____setstate____match_args____orig_bases____parameters____annotations____attrs_attrs____class_getitem____protocol_attrs____attrs_own_setattr____callable_proto_members_only____firstlineno____static_attributes__pypy>   
__sizeof____unicode____itemsize____basicsize____dictoffset____weakrefoffset__c                 s  s    | ]}|d  V  qdS )r   Nr   rn   r   r   r   r_   t  s    z6test_static_tool_sees_class_members.<locals>.<genexpr>r   zfrom z import rX   c                 s  rZ   r[   r\   r]   r   r   r   r_     r`   rj   nodezpreviously this was an 'if' but it seems it's no longer possible for this cache to contain 'node', if this assert raises for you please let us know!	cross_refc                 s      | ]
}| d s|V  qdS rY   NrN   r<   kr   r   r   r_         

r   mroc                 s  r   r   rN   r   r   r   r   r_     r   zunknown tool)      add_note	__notes__c                 S  rM   )AttrsAttributes__)endswith)r<   er   r   r   rP     rQ   z6test_static_tool_sees_class_members.<locals>.<setcomp>)r      __signature__cancel_scopepeer_addressendpointsocketincoming_packets_buffer>   pidargsstdinstdiostderrr   transport_listenertransport_stream
close_hookreceive_some_hook>   r   send_all_hook"wait_send_all_might_not_block_hookreceive_streamsend_stream
__aenter__	__aexit__	__aiter__	__anext__win32>   groupowneris_mount)r      with_segments__replace__)missingextra)pprint
z$ can't see the following symbols in rr   rs   )r%   rG   r   r   )IPUBLIC_MODULESPUBLIC_MODULE_NAMESindexr}   r~   r:   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   	functools	lru_cacher5   r6   r7   r*   r    stdlib_socketr   r   RaisesGroupMatchersetaddinspect
getmembersrD   r   r	   r   r   getr   BaseException__mro__version_infory   attrshasrm   enumEnumNurseryDTLSChannelDTLSEndpointProcessSSLListener	SSLStreamSocketListenerSocketStreamMemoryReceiveStreamMemorySendStreamStapledStreamMemoryReceiveChannelMemorySendChannelWindowsPath	PosixPathr   keysplatformr   r#   )rB   r   rH   r1   r   r   rA   r   r   r   r   r   errors
class_namer;   ignore_namesr   rD   r   r   r   r   cached_type_infor   r%   r   r   beforeEXTRASr   r   r   r   #test_static_tool_sees_class_members   s  































r#  c                  C  sD   t tjsJ tD ]} | j D ]}t|tjrt |sJ qq	dS )z6Check all NoPublicConstructor classes are also @final.N)r0   r   NoPublicConstructorALL_MODULESr5   valuesr7   )r1   r;   r   r   r   test_nopublic_is_final  s   r'  c                  C  s   t trJ t tsJ tD ]N} | j D ]F\}}t|tsq|dr%qt	
|r+qt|jv s5t|jv r6qt|tr<q|tjju sH|tjju rIq|tju rOq|drUqt |s[J qqd S )Nr   
Statistics)r0   objectr+   r   r5   r6   r7   r*   r!   r  
isabstractr   	__bases__Protocol_ext
issubclassr  r   abc
Instrumentr   
SocketTyper   r   )r1   r:   r;   r   r   r   test_classes_are_final  s.   





r1  trio_moddedzPytest plugin not installed.c                  C  s\   t D ])} | j D ]!}t|sq	t|tjrq	dd t|D }|g ks*J |q	qdS )a  Check whether we provide `alias` for all underscore prefixed attributes.

    Attrs always sets the `alias` attribute on fields, so a pytest plugin is used
    to monkeypatch `field()` to record whether an alias was defined in the metadata.
    See `_trio_check_attrs_aliases`.
    c                 S  s6   g | ]}|j r|j|j|jd i dfvr|qS )trio_original_argsalias)initr4  r:   metadatar  )r<   attrr   r   r   r>   X  s    z;test_pyright_recognizes_init_attributes.<locals>.<listcomp>N)	r   r5   r&  r  r	  r7   r   r$  fields)r1   r;   
attributesr   r   r   'test_pyright_recognizes_init_attributesF  s   
r:  )r   r   )r)   r*   r   r+   )r1   r2   r3   r+   r   r4   )rB   rG   rA   rG   rH   r   r   r   )rB   rG   r   rG   rH   r   r   r   );rw   r   r
  r   rt   r  r   r   r   r}   r-   pathlibr   r   r   typingr   r   r  r   r   trio.testingtrio._tests.pytest_pluginr   r	    r   r   _core._tests.tutilr   collections.abcr   r   r   typing_extensionsr,  r   r   r(   r0   r9   listr   r%  r   markredistributors_should_skipskipifr  releaselevelparametrizefilterwarningsr   r#  r'  r1  hasattrfieldr:  r   r   r   r   <module>   s    




o
  


)