ZL i9ddlZddlZddlZddlmZmZmZddlmZddl m Z ddl m Z ddl mZmZmZmZddlmZddlmZmZmZdd lmZmZdd lmZdd lmZej>d k\r ddl Z nddl"Z dd l#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*erddl+Z+edee e,fde-e,effdZ.ede de fdZ/e d=dee,dee,de0e e,ffdZ1 d=de0e,dfdee,dee,fdZ2edde,de-e,effdZ3de-e,efdee4e&fd Z5d!e,dee4e&fd"Z6d!e,dee4e&fd#Z7d$edefd%Z8ede fd&Z9ed'e defd(Z: d=de d'e d)ee*de;fd*Zd/e,d0ee e,de;fd1Z?d2ee d'e d3e e,d4e e,d5ee e,d6ee e,d)e*d-ee-e efd7e;d8e;dee fd9Z@d:ejdeejd;ffd<ZBy#e!$r esddl"Z YwxYw)>N)IterableIteratorSequence) lru_cache)Path)Pattern) TYPE_CHECKINGAnyOptionalUnion) mypyc_attr)InvalidSpecifier Specifier SpecifierSet)InvalidVersionVersion)PathSpec)GitWildMatchPatternError) )"jupyter_dependencies_are_installed) TargetVersion)err)Reportpathreturncpt|d5}tj|cdddS#1swYyxYw)Nrb)opentomllibload)rfs Q/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/black/files.py _load_tomlr$#s. dD Q||As,5c"|jSN)resolvers r#_cached_resolver))s <<>srcsstdin_filenamec tfd|D}|s'tttjg}|Dcgc])}tttj|+}}|Dcgc]-}t |j |jr|gngz/}}ttjd|Dd}|g|j D]p}|dz jr|dfcS|dz jr|dfcS|d z jsIt|d z }d |jd ivsl|d fcSd fScc}wcc}w) aQReturn a directory containing .git, .hg, or pyproject.toml. pyproject.toml files are only considered if they contain a [tool.black] section and are ignored otherwise. That directory will be a common parent of all files and directories passed in `srcs`. If no directory in the tree contains a marker that would specify it's the project root, the root of the file system is returned. Returns a two-tuple with the first element as the project root path and the second element as a string describing the method by which the project root was discovered. c30K|] }|dk(rn|yw)-N).0sr,s r# z$find_project_root..BsE1qCx^Q6Esc32K|]}t|ywr&)set)r1parentss r#r3z$find_project_root..OsCG3w<Cc|jSr&)partsr(s r#z#find_project_root..Ps r*)keyz.gitz.git directoryz.hgz .hg directorypyproject.tomlblacktoolzfile system root)tuplestrr)rcwdlistr6is_dirmaxr5 intersectionexistsis_filer$get) r+r,src path_srcsr src_parents common_base directorypyproject_tomls ` r#find_project_rootrO.sj&!EEE ODHHJ/01CGHCdhhj#!67HIH LUCGT\\ tf2>K C{CD #K "8K$7$78 3   & & (.. .   % % 'o- - ( ( 1 1 3' 4D(DEN.,,VR88 "222 3 ( ((3Is .E92Epath_search_start.ct||\}}|dz }|jr t|S t}|jr t|SdS#tt f$r}t d|Yd}~yd}~wwxYw)z;Find the absolute filepath to a pyproject.toml if it existsr<Nz-Ignoring user configuration directory due to )rOrGr@find_user_pyproject_tomlPermissionError RuntimeErrorr)rPr,path_project_root_path_pyproject_tomlpath_user_pyproject_tomles r#find_pyproject_tomlrZbs-->Oq+.>>""$&'' #;#= (//1 ( )  \ * ;A5 ABs$AAA?'A::A?T) patchable path_configctt|}|jdijdi}|jDcic](\}}|jddjdd|*}}}d|vr8t |}|+|Dcgc]}|j j c}|d<|Scc}}wcc}w)zParse a pyproject toml file, pulling out relevant parts for Black. If parsing fails, will raise a tomllib.TOMLDecodeError. r>r=z--r/rVtarget_version)r$rHitemsreplaceinfer_target_versionnamelower)r\rNconfigkvinferred_target_versions r#parse_pyproject_tomlrixs  ,N+//;??LFCI<<> R41aaiib!))#s3Q6 RF Rv%"6~"F " .@W'X1 'XF# $ MS (Ys -B/!B5rNc|jdi}|jdd}| t|Sy#t$rYnwxYw t|S#ttf$rYywxYw)a#Infer Black's target version from the project metadata in pyproject.toml. Supports the PyPA standard format (PEP 621): https://packaging.python.org/en/latest/specifications/declaring-project-metadata/#requires-python If the target version cannot be inferred, returns None. projectzrequires-pythonN)rHparse_req_python_versionrparse_req_python_specifierr)rNproject_metadatarequires_pythons r#rbrbs&)))R8&**+ > .1    s 4 AA AA! A!roct|}|jddk7ry t|jdgS#ttf$rYywxYw)zParse a version string (i.e. ``"3.7"``) to a list of TargetVersion. If parsing fails, will raise a packaging.version.InvalidVersion error. If the parsed version cannot be mapped to a valid TargetVersion, returns None. rrN)rreleaser IndexError ValueError)roversions r#rlrlsU o&GqQgooa0122  #s9A  A ctt|}|sytDcic]}d|j|}}t |j |}|r|Dcgc]}|| c}Sycc}wcc}w)zParse a specifier string (i.e. ``">=3.7,<3.10"``) to a list of TargetVersion. If parsing fails, will raise a packaging.specifiers.InvalidSpecifier error. If the parsed specifier cannot be mapped to a valid TargetVersion, returns None. Nz3.)strip_specifier_setrrvaluerBfilter)ro specifier_setrgtarget_version_mapcompatible_versionss r#rmrms| ( _(EFM 5BCBqwwi.!+CC%)-*>*>?Q*R%S/BC!"1%CC  DDs A) A.rzcjg}|D] }dt|vr|j|#|jdvrWt|j}t |j|j d|j}|j||jdk(rdt|j}t|jdkDr%t d|j d|j}|j||j|tdjd|DS) zStrip minor versions for some specifiers in the specifier set. For background on version specifiers, see PEP 440: https://peps.python.org/pep-0440/#version-specifiers *)z~=z==>=z===.>r,c32K|]}t|ywr&)r@)r1r2s r#r3z&strip_specifier_set..s 599 # # $ ykA3 /0 s#AA&A#& B/BBreportc t|} |j|y#t$r!}|r|j|d|Yd}~yd}~wwxYw#t$r|r|j|d|YywxYw)z Returns whether the path is a symbolic link that points outside the root directory. Also returns True if we failed to resolve the path. zcannot be read because NTz'is a symbolic link that points outside F)r)OSError path_ignored relative_tort)rrr resolved_pathrYs r#$resolves_outside_root_or_cannot_statrs'- !!$'      (?s&C D     (OPTv&V Ws% A A AA  A0/A0c |jjS#t$rYnwxYwtfd|jDd}||j|St |jS)Nc3@K|]}t|k(s|ywr&)r))r1prs r#r3z,best_effort_relative_path..sNa?13E3MNs)absoluterrtnextr6r))rr root_parents ` r#best_effort_relative_pathrsu }}**400    N4<<NPTUK ,, 4 , ,T 22s " ..root_relative_pathgitignore_dictc||z }|jD]M\}} |j|j}|jr|dz}|j |sMyy#t$rYywxYw)N/TF)r`ras_posixrCrt match_file)rrrrgitignore_pathpattern relative_paths r#_path_is_ignoredr$s $ $D$2#7#7#9  ,,^<EEGM{{} - 3    m ,       s4A'' A43A4normalized_pathrch|r|j|nd}t|xr|jdS)Nr)searchboolgroup)rrmatchs r#path_is_excludedr8s.07GNN? +DE (%++a. ))r*pathsincludeexcludeextend_exclude force_excludeverbosequietc #TK|js Jd||D]} | jsJ| j|j} |r t| ||r|j | dWd| z} | j r| dz } t | |r|j | dt | |r|j | dt | |r|j | dt| ||r| j rF|i||| z t| i} nd} t| j||||||| ||  Ed{2| jsD| jd k(rt|xs| sf|r|j| nd } | s| y7[w) a7Generate all files under `path` whose paths are not excluded by the `exclude_regex`, `extend_exclude`, or `force_exclude` regexes, but are included by the `include` regex. Symbolic links pointing outside of the `root` directory are ignored. `report` is where output about exclusions goes. z/INTERNAL ERROR: `root` must be absolute but is z!matches a .gitignore file contentrz(matches the --exclude regular expressionz/matches the --extend-exclude regular expressionz.matches the --force-exclude regular expressionN)rrz.ipynb)warnT) is_absoluterrrrrCrrrgen_python_filesiterdirrGsuffixrr)rrrrrrrrrrchildrnew_gitignore_dict include_matchs r#rr@s,    W!PQUPVWW ?  """"..t4==? . n    'J K !#55 <<> # %  . 8   'Q R  . ?   H   . >   'W X  /tV D  <<>)&$&5L-"6&" &*"' "   ]]_||x'0R)E 1BIGNN+=>tM ?V sEF( F& F(#9F( F(r"zcolorama.AnsiToWin32cL ddlm}||ddddS#t$r|cYSwxYw)at Wrap stream with colorama's wrap_stream so colors are shown on Windows. If `colorama` is unavailable, the original stream is returned unmodified. Otherwise, the `wrap_stream()` function determines whether the stream needs to be wrapped for a Windows environment and will accordingly either return an `AnsiToWin32` wrapper or the original stream. r) wrap_streamNFT)convertstrip autoresetwrap)colorama.initialiser ImportError)r"rs r#wrap_stream_for_windowsrs6U3 1d%5tTT s  ##r&)Ciorrcollections.abcrrr functoolsrpathlibrrertypingr r r r mypy_extensionsr packaging.specifiersrrrpackaging.versionrrpathspecrpathspec.patterns.gitwildmatchr version_infor rtomliblack.handle_ipynb_magicsr black.moder black.outputr black.reportrcoloramar@dictr$r)r?rOrZrirBrbrlrmrwrRrrrrrrr TextIOWrapperrr0r*r#rs 8866&JJ5Cw$ H$ U49%$sCx.   $4  9=0) 3-0))1#0) 490) 0)hIMS#X8@  c], dcd38n"cN d=!"2 c htM?R6S mAT8U">|> >2 -$- -&      " $   V  0 3D 3 3 3 x( (** gcl #* *V D>V VS\VS\ V WS\* V GCL) V VT$.12VV Vd^VrU U 2  3 34UM $ #$s)G'' G65G6