elfsong Claude Fable 5 commited on
Commit ·
33e41e3
1
Parent(s): 120bcb2
Remove .venv from version control and add .gitignore
Browse filesCo-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .gitignoreAdded+9
- .venv/.gitignoreDeleted-1
- .venv/.lockDeleted
- .venv/CACHEDIR.TAGDeleted-1
- .venv/bin/activateDeleted-130
- .venv/bin/activate.batDeleted-71
- .venv/bin/activate.cshDeleted-76
- .venv/bin/activate.fishDeleted-124
- .venv/bin/activate.nuDeleted-102
- .venv/bin/activate.ps1Deleted-82
- .venv/bin/activate_this.pyDeleted-59
- .venv/bin/deactivate.batDeleted-39
- .venv/bin/hfDeleted-10
- .venv/bin/httpxDeleted-10
- .venv/bin/huggingface-cliDeleted-10
- .venv/bin/idnaDeleted-10
- .venv/bin/pydoc.batDeleted-22
- .venv/bin/pythonDeleted
- .venv/bin/python3Deleted
- .venv/bin/python3.14Deleted
- .venv/bin/tiny-agentsDeleted-10
- .venv/bin/tqdmDeleted-10
- .venv/lib/python3.14/site-packages/__pycache__/_virtualenv.cpython-314.pycDeleted
- .venv/lib/python3.14/site-packages/__pycache__/typing_extensions.cpython-314.pycDeleted-3
- .venv/lib/python3.14/site-packages/_virtualenv.pthDeleted-3
- .venv/lib/python3.14/site-packages/_virtualenv.pyDeleted-101
- .venv/lib/python3.14/site-packages/_yaml/__init__.pyDeleted-33
- .venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/INSTALLERDeleted-1
- .venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/METADATADeleted-107
- .venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/RECORDDeleted-54
- .venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/REQUESTEDDeleted
- .venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/WHEELDeleted-5
- .venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/entry_points.txtDeleted-2
- .venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/licenses/LICENSEDeleted-20
- .venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/scm_file_list.jsonDeleted-119
- .venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/scm_version.jsonDeleted-8
- .venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/top_level.txtDeleted-1
- .venv/lib/python3.14/site-packages/anyio/__init__.pyDeleted-115
- .venv/lib/python3.14/site-packages/anyio/__pycache__/__init__.cpython-314.pycDeleted
- .venv/lib/python3.14/site-packages/anyio/__pycache__/from_thread.cpython-314.pycDeleted
- .venv/lib/python3.14/site-packages/anyio/__pycache__/lowlevel.cpython-314.pycDeleted
- .venv/lib/python3.14/site-packages/anyio/__pycache__/to_thread.cpython-314.pycDeleted
- .venv/lib/python3.14/site-packages/anyio/_backends/__init__.pyDeleted
- .venv/lib/python3.14/site-packages/anyio/_backends/_asyncio.pyDeleted
- .venv/lib/python3.14/site-packages/anyio/_backends/_trio.pyDeleted-1456
- .venv/lib/python3.14/site-packages/anyio/_core/__init__.pyDeleted
- .venv/lib/python3.14/site-packages/anyio/_core/__pycache__/__init__.cpython-314.pycDeleted
- .venv/lib/python3.14/site-packages/anyio/_core/__pycache__/_contextmanagers.cpython-314.pycDeleted
- .venv/lib/python3.14/site-packages/anyio/_core/__pycache__/_eventloop.cpython-314.pycDeleted
- .venv/lib/python3.14/site-packages/anyio/_core/__pycache__/_exceptions.cpython-314.pycDeleted
123456789# Python virtual environment.venv/
# Python cache__pycache__/*.pyc
# macOS.DS_Store1*1Signature: 8a477f597d28d172789f06886806bc55123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130# Copyright (c) 2020-202x The virtualenv developers## Permission is hereby granted, free of charge, to any person obtaining# a copy of this software and associated documentation files (the# "Software"), to deal in the Software without restriction, including# without limitation the rights to use, copy, modify, merge, publish,# distribute, sublicense, and/or sell copies of the Software, and to# permit persons to whom the Software is furnished to do so, subject to# the following conditions:## The above copyright notice and this permission notice shall be# included in all copies or substantial portions of the Software.## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# This file must be used with "source bin/activate" *from bash*# you cannot run it directly
if ! [ -z "${SCRIPT_PATH+_}" ] ; then _OLD_SCRIPT_PATH="$SCRIPT_PATH"fi
# Get script path (only used if environment is relocatable).if [ -n "${BASH_VERSION:+x}" ] ; then SCRIPT_PATH="${BASH_SOURCE[0]}" if [ "$SCRIPT_PATH" = "$0" ]; then # Only bash has a reasonably robust check for source'dness. echo "You must source this script: \$ source $0" >&2 exit 33 fielif [ -n "${ZSH_VERSION:+x}" ] ; then SCRIPT_PATH="${(%):-%x}"elif [ -n "${KSH_VERSION:+x}" ] ; then SCRIPT_PATH="${.sh.file}"fi
deactivate () { unset -f pydoc >/dev/null 2>&1 || true
# reset old environment variables # ! [ -z ${VAR+_} ] returns true if VAR is declared at all if ! [ -z "${_OLD_VIRTUAL_PATH:+_}" ] ; then PATH="$_OLD_VIRTUAL_PATH" export PATH unset _OLD_VIRTUAL_PATH fi if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME" export PYTHONHOME unset _OLD_VIRTUAL_PYTHONHOME fi
# The hash command must be called to get it to forget past # commands. Without forgetting past commands the $PATH changes # we made may not be respected hash -r 2>/dev/null
if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then PS1="$_OLD_VIRTUAL_PS1" export PS1 unset _OLD_VIRTUAL_PS1 fi
unset VIRTUAL_ENV unset VIRTUAL_ENV_PROMPT if [ ! "${1-}" = "nondestructive" ] ; then # Self destruct! unset -f deactivate fi}
# unset irrelevant variablesdeactivate nondestructive
VIRTUAL_ENV='/Users/mingzhe/Projects/anticoding/.venv'if ([ "$OSTYPE" = "cygwin" ] || [ "$OSTYPE" = "msys" ]) && $(command -v cygpath &> /dev/null) ; then VIRTUAL_ENV=$(cygpath -u "$VIRTUAL_ENV")fiexport VIRTUAL_ENV
# Unset the `SCRIPT_PATH` variable, now that the `VIRTUAL_ENV` variable# has been set. This is important for relocatable environments.if ! [ -z "${_OLD_SCRIPT_PATH+_}" ] ; then SCRIPT_PATH="$_OLD_SCRIPT_PATH" export SCRIPT_PATH unset _OLD_SCRIPT_PATHelse unset SCRIPT_PATHfi
_OLD_VIRTUAL_PATH="$PATH"PATH="$VIRTUAL_ENV/bin:$PATH"export PATH
if [ "xanticoding" != x ] ; then VIRTUAL_ENV_PROMPT="anticoding"else VIRTUAL_ENV_PROMPT=$(basename "$VIRTUAL_ENV")fiexport VIRTUAL_ENV_PROMPT
# unset PYTHONHOME if setif ! [ -z "${PYTHONHOME+_}" ] ; then _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME" unset PYTHONHOMEfi
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then _OLD_VIRTUAL_PS1="${PS1-}" PS1="(${VIRTUAL_ENV_PROMPT}) ${PS1-}" export PS1fi
# Make sure to unalias pydoc if it's already therealias pydoc 2>/dev/null >/dev/null && unalias pydoc || true
pydoc () { python -m pydoc "$@"}
# The hash command must be called to get it to forget past# commands. Without forgetting past commands the $PATH changes# we made may not be respectedhash -r 2>/dev/null || true1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071@REM Copyright (c) 2020-202x The virtualenv developers
@REM
@REM Permission is hereby granted, free of charge, to any person obtaining
@REM a copy of this software and associated documentation files (the
@REM "Software"), to deal in the Software without restriction, including
@REM without limitation the rights to use, copy, modify, merge, publish,
@REM distribute, sublicense, and/or sell copies of the Software, and to
@REM permit persons to whom the Software is furnished to do so, subject to
@REM the following conditions:
@REM
@REM The above copyright notice and this permission notice shall be
@REM included in all copies or substantial portions of the Software.
@REM
@REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
@REM EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
@REM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@REM NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
@REM LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
@REM OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
@REM WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@REM This file is UTF-8 encoded, so we need to update the current code page while executing it
@for /f "tokens=2 delims=:." %%a in ('"%SystemRoot%\System32\chcp.com"') do @set _OLD_CODEPAGE=%%a
@if defined _OLD_CODEPAGE (
"%SystemRoot%\System32\chcp.com" 65001 > nul
)
@for %%i in ("/Users/mingzhe/Projects/anticoding/.venv") do @set "VIRTUAL_ENV=%%~fi"
@set "VIRTUAL_ENV_PROMPT=anticoding"
@if NOT DEFINED VIRTUAL_ENV_PROMPT (
@for %%d in ("%VIRTUAL_ENV%") do @set "VIRTUAL_ENV_PROMPT=%%~nxd"
)
@if defined _OLD_VIRTUAL_PROMPT (
@set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
) else (
@if not defined PROMPT (
@set "PROMPT=$P$G"
)
@if not defined VIRTUAL_ENV_DISABLE_PROMPT (
@set "_OLD_VIRTUAL_PROMPT=%PROMPT%"
)
)
@if not defined VIRTUAL_ENV_DISABLE_PROMPT (
@set "PROMPT=(%VIRTUAL_ENV_PROMPT%) %PROMPT%"
)
@REM Don't use () to avoid problems with them in %PATH%
@if defined _OLD_VIRTUAL_PYTHONHOME @goto ENDIFVHOME
@set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%"
:ENDIFVHOME
@set PYTHONHOME=
@REM if defined _OLD_VIRTUAL_PATH (
@if not defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH1
@set "PATH=%_OLD_VIRTUAL_PATH%"
:ENDIFVPATH1
@REM ) else (
@if defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH2
@set "_OLD_VIRTUAL_PATH=%PATH%"
:ENDIFVPATH2
@set "PATH=%VIRTUAL_ENV%\bin;%PATH%"
@if defined _OLD_CODEPAGE (
"%SystemRoot%\System32\chcp.com" %_OLD_CODEPAGE% > nul
@set _OLD_CODEPAGE=
)12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576# Copyright (c) 2020-202x The virtualenv developers## Permission is hereby granted, free of charge, to any person obtaining# a copy of this software and associated documentation files (the# "Software"), to deal in the Software without restriction, including# without limitation the rights to use, copy, modify, merge, publish,# distribute, sublicense, and/or sell copies of the Software, and to# permit persons to whom the Software is furnished to do so, subject to# the following conditions:## The above copyright notice and this permission notice shall be# included in all copies or substantial portions of the Software.## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# This file must be used with "source bin/activate.csh" *from csh*.# You cannot run it directly.# Created by Davide Di Blasi <davidedb@gmail.com>.
set newline='\'
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH:q" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT:q" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'
# Unset irrelevant variables.deactivate nondestructive
setenv VIRTUAL_ENV '/Users/mingzhe/Projects/anticoding/.venv'
set _OLD_VIRTUAL_PATH="$PATH:q"setenv PATH "$VIRTUAL_ENV:q/bin:$PATH:q"
if ('anticoding' != "") then setenv VIRTUAL_ENV_PROMPT 'anticoding'else setenv VIRTUAL_ENV_PROMPT "$VIRTUAL_ENV:t:q"endif
if ( $?VIRTUAL_ENV_DISABLE_PROMPT ) then if ( $VIRTUAL_ENV_DISABLE_PROMPT == "" ) then set do_prompt = "1" else set do_prompt = "0" endifelse set do_prompt = "1"endif
if ( $do_prompt == "1" ) then # Could be in a non-interactive environment, # in which case, $prompt is undefined and we wouldn't # care about the prompt anyway. if ( $?prompt ) then set _OLD_VIRTUAL_PROMPT="$prompt:q" if ( "$prompt:q" =~ *"$newline:q"* ) then : else set prompt = '('"$VIRTUAL_ENV_PROMPT:q"') '"$prompt:q" endif endifendif
unset env_nameunset do_prompt
alias pydoc python -m pydoc
rehash123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124# Copyright (c) 2020-202x The virtualenv developers## Permission is hereby granted, free of charge, to any person obtaining# a copy of this software and associated documentation files (the# "Software"), to deal in the Software without restriction, including# without limitation the rights to use, copy, modify, merge, publish,# distribute, sublicense, and/or sell copies of the Software, and to# permit persons to whom the Software is furnished to do so, subject to# the following conditions:## The above copyright notice and this permission notice shall be# included in all copies or substantial portions of the Software.## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# This file must be used using `source bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.# Do not run it directly.
function _bashify_path -d "Converts a fish path to something bash can recognize" set fishy_path $argv set bashy_path $fishy_path[1] for path_part in $fishy_path[2..-1] set bashy_path "$bashy_path:$path_part" end echo $bashy_pathend
function _fishify_path -d "Converts a bash path to something fish can recognize" echo $argv | tr ':' '\n'end
function deactivate -d 'Exit virtualenv mode and return to the normal environment.' # reset old environment variables if test -n "$_OLD_VIRTUAL_PATH" # https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling if test (string sub -s 1 -l 1 $FISH_VERSION) -lt 3 set -gx PATH (_fishify_path "$_OLD_VIRTUAL_PATH") else set -gx PATH $_OLD_VIRTUAL_PATH end set -e _OLD_VIRTUAL_PATH end
if test -n "$_OLD_VIRTUAL_PYTHONHOME" set -gx PYTHONHOME "$_OLD_VIRTUAL_PYTHONHOME" set -e _OLD_VIRTUAL_PYTHONHOME end
if test -n "$_OLD_FISH_PROMPT_OVERRIDE" and functions -q _old_fish_prompt # Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`. set -l fish_function_path
# Erase virtualenv's `fish_prompt` and restore the original. functions -e fish_prompt functions -c _old_fish_prompt fish_prompt functions -e _old_fish_prompt set -e _OLD_FISH_PROMPT_OVERRIDE end
set -e VIRTUAL_ENV set -e VIRTUAL_ENV_PROMPT
if test "$argv[1]" != 'nondestructive' # Self-destruct! functions -e pydoc functions -e deactivate functions -e _bashify_path functions -e _fishify_path endend
# Unset irrelevant variables.deactivate nondestructive
set -gx VIRTUAL_ENV '/Users/mingzhe/Projects/anticoding/.venv'
# https://github.com/fish-shell/fish-shell/issues/436 altered PATH handlingif test (string sub -s 1 -l 1 $FISH_VERSION) -lt 3 set -gx _OLD_VIRTUAL_PATH (_bashify_path $PATH)else set -gx _OLD_VIRTUAL_PATH $PATHendset -gx PATH "$VIRTUAL_ENV"'/bin' $PATH
# Prompt override provided?# If not, just use the environment name.if test -n 'anticoding' set -gx VIRTUAL_ENV_PROMPT 'anticoding'else set -gx VIRTUAL_ENV_PROMPT (basename "$VIRTUAL_ENV")end
# Unset `$PYTHONHOME` if set.if set -q PYTHONHOME set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME set -e PYTHONHOMEend
function pydoc python -m pydoc $argvend
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" # Copy the current `fish_prompt` function as `_old_fish_prompt`. functions -c fish_prompt _old_fish_prompt
function fish_prompt # Run the user's prompt first; it might depend on (pipe)status. set -l prompt (_old_fish_prompt)
printf '(%s) ' $VIRTUAL_ENV_PROMPT
string join -- \n $prompt # handle multi-line prompts end
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"end123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102# Copyright (c) 2020-202x The virtualenv developers## Permission is hereby granted, free of charge, to any person obtaining# a copy of this software and associated documentation files (the# "Software"), to deal in the Software without restriction, including# without limitation the rights to use, copy, modify, merge, publish,# distribute, sublicense, and/or sell copies of the Software, and to# permit persons to whom the Software is furnished to do so, subject to# the following conditions:## The above copyright notice and this permission notice shall be# included in all copies or substantial portions of the Software.## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# virtualenv activation module:# - Activate with `overlay use activate.nu`# - Deactivate with `deactivate`, as usual## To customize the overlay name, you can call `overlay use activate.nu as foo`, but then simply `deactivate` won't work# because it is just an alias to hide the "activate" overlay. You'd need to call `overlay hide foo` manually.
module warning { export-env { const file = path self error make -u { msg: $"`($file | path basename)` is meant to be used with `overlay use`, not `source`" } }
}
use warning
export-env {
let nu_ver = (version | get version | split row '.' | take 2 | each { into int }) if $nu_ver.0 == 0 and $nu_ver.1 < 106 { error make { msg: 'virtualenv Nushell activation requires Nushell 0.106 or greater.' } }
def is-string [x] { ($x | describe) == 'string' }
def has-env [...names] { $names | each {|n| $n in $env } | all {|i| $i } }
def is-env-true [name: string] { if (has-env $name) { let val = ($env | get --optional $name) if ($val | describe) == 'bool' { $val } else { not ($val | is-empty) } } else { false } }
let virtual_env = '/Users/mingzhe/Projects/anticoding/.venv' let bin = 'bin' let path_name = if (has-env 'Path') { 'Path' } else { 'PATH' } let venv_path = ([$virtual_env $bin] | path join) let new_path = ($env | get $path_name | prepend $venv_path) let virtual_env_prompt = if ('anticoding' | is-empty) { ($virtual_env | path basename) } else { 'anticoding' } let new_env = { $path_name: $new_path VIRTUAL_ENV: $virtual_env VIRTUAL_ENV_PROMPT: $virtual_env_prompt } let old_prompt_command = if (has-env 'PROMPT_COMMAND') { $env.PROMPT_COMMAND } else { '' } let new_env = if (is-env-true 'VIRTUAL_ENV_DISABLE_PROMPT') { $new_env } else { let virtual_prefix = $'(char lparen)($virtual_env_prompt)(char rparen) ' let new_prompt = if (has-env 'PROMPT_COMMAND') { if ('closure' in ($old_prompt_command | describe)) { {|| $'($virtual_prefix)(do $old_prompt_command)' } } else { {|| $'($virtual_prefix)($old_prompt_command)' } } } else { {|| $'($virtual_prefix)' } } $new_env | merge { PROMPT_COMMAND: $new_prompt VIRTUAL_PREFIX: $virtual_prefix } } load-env $new_env}
export alias pydoc = python -m pydocexport alias deactivate = overlay hide activate12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182# Copyright (c) 2020-202x The virtualenv developers## Permission is hereby granted, free of charge, to any person obtaining# a copy of this software and associated documentation files (the# "Software"), to deal in the Software without restriction, including# without limitation the rights to use, copy, modify, merge, publish,# distribute, sublicense, and/or sell copies of the Software, and to# permit persons to whom the Software is furnished to do so, subject to# the following conditions:## The above copyright notice and this permission notice shall be# included in all copies or substantial portions of the Software.## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
$script:THIS_PATH = $myinvocation.mycommand.path$script:BASE_DIR = Split-Path (Resolve-Path "$THIS_PATH/..") -Parent
function global:deactivate([switch] $NonDestructive) { if (Test-Path variable:_OLD_VIRTUAL_PATH) { $env:PATH = $variable:_OLD_VIRTUAL_PATH Remove-Variable "_OLD_VIRTUAL_PATH" -Scope global }
if (Test-Path function:_old_virtual_prompt) { $function:prompt = $function:_old_virtual_prompt Remove-Item function:\_old_virtual_prompt }
if ($env:VIRTUAL_ENV) { Remove-Item env:VIRTUAL_ENV -ErrorAction SilentlyContinue }
if ($env:VIRTUAL_ENV_PROMPT) { Remove-Item env:VIRTUAL_ENV_PROMPT -ErrorAction SilentlyContinue }
if (!$NonDestructive) { # Self destruct! Remove-Item function:deactivate Remove-Item function:pydoc }}
function global:pydoc { python -m pydoc $args}
# unset irrelevant variablesdeactivate -nondestructive
$VIRTUAL_ENV = $BASE_DIR$env:VIRTUAL_ENV = $VIRTUAL_ENV
if ("anticoding" -ne "") { $env:VIRTUAL_ENV_PROMPT = "anticoding"}else { $env:VIRTUAL_ENV_PROMPT = $( Split-Path $env:VIRTUAL_ENV -Leaf )}
New-Variable -Scope global -Name _OLD_VIRTUAL_PATH -Value $env:PATH
$env:PATH = "$env:VIRTUAL_ENV/bin:" + $env:PATHif (!$env:VIRTUAL_ENV_DISABLE_PROMPT) { function global:_old_virtual_prompt { "" } $function:_old_virtual_prompt = $function:prompt
function global:prompt { # Add the custom prefix to the existing prompt $previous_prompt_value = & $function:_old_virtual_prompt ("(" + $env:VIRTUAL_ENV_PROMPT + ") " + $previous_prompt_value) }}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859# Copyright (c) 2020-202x The virtualenv developers## Permission is hereby granted, free of charge, to any person obtaining# a copy of this software and associated documentation files (the# "Software"), to deal in the Software without restriction, including# without limitation the rights to use, copy, modify, merge, publish,# distribute, sublicense, and/or sell copies of the Software, and to# permit persons to whom the Software is furnished to do so, subject to# the following conditions:## The above copyright notice and this permission notice shall be# included in all copies or substantial portions of the Software.## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""Activate virtualenv for current interpreter:
import runpyrunpy.run_path(this_file)
This can be used when you must use an existing Python interpreter, not the virtualenv bin/python.""" # noqa: D415
from __future__ import annotations
import osimport siteimport sys
try: abs_file = os.path.abspath(__file__)except NameError as exc: msg = "You must use import runpy; runpy.run_path(this_file)" raise AssertionError(msg) from exc
bin_dir = os.path.dirname(abs_file)base = bin_dir[: -len("bin") - 1] # strip away the bin part from the __file__, plus the path separator
# prepend bin to PATH (this file is inside the bin directory)os.environ["PATH"] = os.pathsep.join([bin_dir, *os.environ.get("PATH", "").split(os.pathsep)])os.environ["VIRTUAL_ENV"] = base # virtual env is right above bin directoryos.environ["VIRTUAL_ENV_PROMPT"] = "anticoding" or os.path.basename(base) # noqa: SIM222
# add the virtual environments libraries to the host python import mechanismprev_length = len(sys.path)for lib in "../lib/python3.14/site-packages".split(os.pathsep): path = os.path.realpath(os.path.join(bin_dir, lib)) site.addsitedir(path)sys.path[:] = sys.path[prev_length:] + sys.path[0:prev_length]
sys.real_prefix = sys.prefixsys.prefix = base123456789101112131415161718192021222324252627282930313233343536373839@REM Copyright (c) 2020-202x The virtualenv developers
@REM
@REM Permission is hereby granted, free of charge, to any person obtaining
@REM a copy of this software and associated documentation files (the
@REM "Software"), to deal in the Software without restriction, including
@REM without limitation the rights to use, copy, modify, merge, publish,
@REM distribute, sublicense, and/or sell copies of the Software, and to
@REM permit persons to whom the Software is furnished to do so, subject to
@REM the following conditions:
@REM
@REM The above copyright notice and this permission notice shall be
@REM included in all copies or substantial portions of the Software.
@REM
@REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
@REM EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
@REM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@REM NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
@REM LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
@REM OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
@REM WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@set VIRTUAL_ENV=
@set VIRTUAL_ENV_PROMPT=
@REM Don't use () to avoid problems with them in %PATH%
@if not defined _OLD_VIRTUAL_PROMPT @goto ENDIFVPROMPT
@set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
@set _OLD_VIRTUAL_PROMPT=
:ENDIFVPROMPT
@if not defined _OLD_VIRTUAL_PYTHONHOME @goto ENDIFVHOME
@set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%"
@set _OLD_VIRTUAL_PYTHONHOME=
:ENDIFVHOME
@if not defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH
@set "PATH=%_OLD_VIRTUAL_PATH%"
@set _OLD_VIRTUAL_PATH=
:ENDIFVPATH12345678910#!/Users/mingzhe/Projects/anticoding/.venv/bin/python3# -*- coding: utf-8 -*-import sysfrom huggingface_hub.cli.hf import mainif __name__ == "__main__": if sys.argv[0].endswith("-script.pyw"): sys.argv[0] = sys.argv[0][:-11] elif sys.argv[0].endswith(".exe"): sys.argv[0] = sys.argv[0][:-4] sys.exit(main())12345678910#!/Users/mingzhe/Projects/anticoding/.venv/bin/python3# -*- coding: utf-8 -*-import sysfrom httpx import mainif __name__ == "__main__": if sys.argv[0].endswith("-script.pyw"): sys.argv[0] = sys.argv[0][:-11] elif sys.argv[0].endswith(".exe"): sys.argv[0] = sys.argv[0][:-4] sys.exit(main())12345678910#!/Users/mingzhe/Projects/anticoding/.venv/bin/python3# -*- coding: utf-8 -*-import sysfrom huggingface_hub.cli.deprecated_cli import mainif __name__ == "__main__": if sys.argv[0].endswith("-script.pyw"): sys.argv[0] = sys.argv[0][:-11] elif sys.argv[0].endswith(".exe"): sys.argv[0] = sys.argv[0][:-4] sys.exit(main())12345678910#!/Users/mingzhe/Projects/anticoding/.venv/bin/python3# -*- coding: utf-8 -*-import sysfrom idna.cli import mainif __name__ == "__main__": if sys.argv[0].endswith("-script.pyw"): sys.argv[0] = sys.argv[0][:-11] elif sys.argv[0].endswith(".exe"): sys.argv[0] = sys.argv[0][:-4] sys.exit(main())12345678910111213141516171819202122@REM Copyright (c) 2020-202x The virtualenv developers
@REM
@REM Permission is hereby granted, free of charge, to any person obtaining
@REM a copy of this software and associated documentation files (the
@REM "Software"), to deal in the Software without restriction, including
@REM without limitation the rights to use, copy, modify, merge, publish,
@REM distribute, sublicense, and/or sell copies of the Software, and to
@REM permit persons to whom the Software is furnished to do so, subject to
@REM the following conditions:
@REM
@REM The above copyright notice and this permission notice shall be
@REM included in all copies or substantial portions of the Software.
@REM
@REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
@REM EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
@REM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@REM NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
@REM LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
@REM OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
@REM WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
python.exe -m pydoc %*12345678910#!/Users/mingzhe/Projects/anticoding/.venv/bin/python3# -*- coding: utf-8 -*-import sysfrom huggingface_hub.inference._mcp.cli import appif __name__ == "__main__": if sys.argv[0].endswith("-script.pyw"): sys.argv[0] = sys.argv[0][:-11] elif sys.argv[0].endswith(".exe"): sys.argv[0] = sys.argv[0][:-4] sys.exit(app())12345678910#!/Users/mingzhe/Projects/anticoding/.venv/bin/python3# -*- coding: utf-8 -*-import sysfrom tqdm.cli import mainif __name__ == "__main__": if sys.argv[0].endswith("-script.pyw"): sys.argv[0] = sys.argv[0][:-11] elif sys.argv[0].endswith(".exe"): sys.argv[0] = sys.argv[0][:-4] sys.exit(main())123version https://git-lfs.github.com/spec/v1oid sha256:fa6928b8b9f92a30f9112e27276c08f1c48740977886ba95585dbf248866875dsize 179421123version https://git-lfs.github.com/spec/v1oid sha256:69ac3d8f27e679c81b94ab30b3b56e9cd138219b1ba94a1fa3606d5a76a1433dsize 18123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101"""Patches that are applied at runtime to the virtual environment."""
import osimport sys
VIRTUALENV_PATCH_FILE = os.path.join(__file__)
def patch_dist(dist): """ Distutils allows user to configure some arguments via a configuration file: https://docs.python.org/3.11/install/index.html#distutils-configuration-files.
Some of this arguments though don't make sense in context of the virtual environment files, let's fix them up. """ # noqa: D205 # we cannot allow some install config as that would get packages installed outside of the virtual environment old_parse_config_files = dist.Distribution.parse_config_files
def parse_config_files(self, *args, **kwargs): result = old_parse_config_files(self, *args, **kwargs) install = self.get_option_dict("install")
if "prefix" in install: # the prefix governs where to install the libraries install["prefix"] = VIRTUALENV_PATCH_FILE, os.path.abspath(sys.prefix) for base in ("purelib", "platlib", "headers", "scripts", "data"): key = f"install_{base}" if key in install: # do not allow global configs to hijack venv paths install.pop(key, None) return result
dist.Distribution.parse_config_files = parse_config_files
# Import hook that patches some modules to ignore configuration values that break package installation in case# of virtual environments._DISTUTILS_PATCH = "distutils.dist", "setuptools.dist"# https://docs.python.org/3/library/importlib.html#setting-up-an-importer
class _Finder: """A meta path finder that allows patching the imported distutils modules."""
fullname = None
# lock[0] is threading.Lock(), but initialized lazily to avoid importing threading very early at startup, # because there are gevent-based applications that need to be first to import threading by themselves. # See https://github.com/pypa/virtualenv/issues/1895 for details. lock = [] # noqa: RUF012
def find_spec(self, fullname, path, target=None): # noqa: ARG002 if fullname in _DISTUTILS_PATCH and self.fullname is None: # initialize lock[0] lazily if len(self.lock) == 0: import threading
lock = threading.Lock() # there is possibility that two threads T1 and T2 are simultaneously running into find_spec, # observing .lock as empty, and further going into hereby initialization. However due to the GIL, # list.append() operation is atomic and this way only one of the threads will "win" to put the lock # - that every thread will use - into .lock[0]. # https://docs.python.org/3/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe self.lock.append(lock)
from functools import partial from importlib.util import find_spec
with self.lock[0]: self.fullname = fullname try: spec = find_spec(fullname, path) if spec is not None: # https://www.python.org/dev/peps/pep-0451/#how-loading-will-work is_new_api = hasattr(spec.loader, "exec_module") func_name = "exec_module" if is_new_api else "load_module" old = getattr(spec.loader, func_name) func = self.exec_module if is_new_api else self.load_module if old is not func: try: # noqa: SIM105 setattr(spec.loader, func_name, partial(func, old)) except AttributeError: pass # C-Extension loaders are r/o such as zipimporter with <3.7 return spec finally: self.fullname = None return None
@staticmethod def exec_module(old, module): old(module) if module.__name__ in _DISTUTILS_PATCH: patch_dist(module)
@staticmethod def load_module(old, name): module = old(name) if module.__name__ in _DISTUTILS_PATCH: patch_dist(module) return module
sys.meta_path.insert(0, _Finder())123456789101112131415161718192021222324252627282930313233# This is a stub package designed to roughly emulate the _yaml# extension module, which previously existed as a standalone module# and has been moved into the `yaml` package namespace.# It does not perfectly mimic its old counterpart, but should get# close enough for anyone who's relying on it even when they shouldn't.import yaml
# in some circumstances, the yaml module we imoprted may be from a different version, so we need# to tread carefully when poking at it here (it may not have the attributes we expect)if not getattr(yaml, '__with_libyaml__', False): from sys import version_info
exc = ModuleNotFoundError if version_info >= (3, 6) else ImportError raise exc("No module named '_yaml'")else: from yaml._yaml import * import warnings warnings.warn( 'The _yaml extension module is now located at yaml._yaml' ' and its location is subject to change. To use the' ' LibYAML-based parser and emitter, import from `yaml`:' ' `from yaml import CLoader as Loader, CDumper as Dumper`.', DeprecationWarning ) del warnings # Don't `del yaml` here because yaml is actually an existing # namespace member of _yaml.
__name__ = '_yaml'# If the module is top-level (i.e. not a part of any specific package)# then the attribute should be set to ''.# https://docs.python.org/3.8/library/types.html__package__ = ''1uv123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107Metadata-Version: 2.4Name: anyioVersion: 4.14.1Summary: High-level concurrency and networking framework on top of asyncio or TrioAuthor-email: Alex Grönholm <alex.gronholm@nextday.fi>License-Expression: MITProject-URL: Documentation, https://anyio.readthedocs.io/en/latest/Project-URL: Changelog, https://anyio.readthedocs.io/en/stable/versionhistory.htmlProject-URL: Source code, https://github.com/agronholm/anyioProject-URL: Issue tracker, https://github.com/agronholm/anyio/issuesClassifier: Development Status :: 5 - Production/StableClassifier: Intended Audience :: DevelopersClassifier: Framework :: AnyIOClassifier: Typing :: TypedClassifier: Programming Language :: PythonClassifier: Programming Language :: Python :: 3Classifier: Programming Language :: Python :: 3.10Classifier: Programming Language :: Python :: 3.11Classifier: Programming Language :: Python :: 3.12Classifier: Programming Language :: Python :: 3.13Classifier: Programming Language :: Python :: 3.14Classifier: Programming Language :: Python :: 3.15Requires-Python: >=3.10Description-Content-Type: text/x-rstLicense-File: LICENSERequires-Dist: exceptiongroup>=1.0.2; python_version < "3.11"Requires-Dist: idna>=2.8Requires-Dist: typing_extensions>=4.5; python_version < "3.13"Provides-Extra: trioRequires-Dist: trio>=0.32.0; extra == "trio"Dynamic: license-file
.. image:: https://github.com/agronholm/anyio/actions/workflows/test.yml/badge.svg :target: https://github.com/agronholm/anyio/actions/workflows/test.yml :alt: Build Status.. image:: https://coveralls.io/repos/github/agronholm/anyio/badge.svg?branch=master :target: https://coveralls.io/github/agronholm/anyio?branch=master :alt: Code Coverage.. image:: https://readthedocs.org/projects/anyio/badge/?version=latest :target: https://anyio.readthedocs.io/en/latest/?badge=latest :alt: Documentation.. image:: https://badges.gitter.im/gitterHQ/gitter.svg :target: https://gitter.im/python-trio/AnyIO :alt: Gitter chat.. image:: https://tidelift.com/badges/package/pypi/anyio :target: https://tidelift.com/subscription/pkg/pypi-anyio :alt: Tidelift
AnyIO is an asynchronous networking and concurrency library that works on top of either asyncio_ orTrio_. It implements Trio-like `structured concurrency`_ (SC) on top of asyncio and works in harmonywith the native SC of Trio itself.
Applications and libraries written against AnyIO's API will run unmodified on either asyncio_ orTrio_. AnyIO can also be adopted into a library or application incrementally – bit by bit, no fullrefactoring necessary. It will blend in with the native libraries of your chosen backend.
To find out why you might want to use AnyIO's APIs instead of asyncio's, you can read about it`here <https://anyio.readthedocs.io/en/stable/why.html>`_.
Documentation-------------
View full documentation at: https://anyio.readthedocs.io/
Features--------
AnyIO offers the following functionality:
* Task groups (nurseries_ in trio terminology)* High-level networking (TCP, UDP and UNIX sockets)
* `Happy eyeballs`_ algorithm for TCP connections (more robust than that of asyncio on Python 3.8) * async/await style UDP sockets (unlike asyncio where you still have to use Transports and Protocols)
* A versatile API for byte streams and object streams* Inter-task synchronization and communication (locks, conditions, events, semaphores, object streams)* Worker threads* Subprocesses* Subinterpreter support for code parallelization (on Python 3.13 and later)* Asynchronous file I/O (using worker threads)* Signal handling* Asynchronous versions of the functools_ and itertools_ modules
AnyIO also comes with its own pytest_ plugin which also supports asynchronous fixtures.It even works with the popular Hypothesis_ library.
.. _asyncio: https://docs.python.org/3/library/asyncio.html.. _Trio: https://github.com/python-trio/trio.. _structured concurrency: https://en.wikipedia.org/wiki/Structured_concurrency.. _nurseries: https://trio.readthedocs.io/en/stable/reference-core.html#nurseries-and-spawning.. _Happy eyeballs: https://en.wikipedia.org/wiki/Happy_Eyeballs.. _pytest: https://docs.pytest.org/en/latest/.. _functools: https://docs.python.org/3/library/functools.html.. _itertools: https://docs.python.org/3/library/itertools.html.. _Hypothesis: https://hypothesis.works/
Security contact information----------------------------
To report a security vulnerability, please use the `Tidelift security contact`_.Tidelift will coordinate the fix and disclosure.
.. _Tidelift security contact: https://tidelift.com/security123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354anyio-4.14.1.dist-info/INSTALLER,sha256=5hhM4Q4mYTT9z6QB6PGpUAW81PGNFrYrdXMj4oM_6ak,2anyio-4.14.1.dist-info/METADATA,sha256=bfkjYaZLYPsPI5JV_Gn7HYF65mteyE8nhjaI0ZqC4L4,4645anyio-4.14.1.dist-info/RECORD,,anyio-4.14.1.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0anyio-4.14.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91anyio-4.14.1.dist-info/entry_points.txt,sha256=_d6Yu6uiaZmNe0CydowirE9Cmg7zUL2g08tQpoS3Qvc,39anyio-4.14.1.dist-info/licenses/LICENSE,sha256=U2GsncWPLvX9LpsJxoKXwX8ElQkJu8gCO9uC6s8iwrA,1081anyio-4.14.1.dist-info/scm_file_list.json,sha256=wDSXGv8Ehn5ZW5BhB-RlaAc16zY_OfO27qrlMfMMZy8,3654anyio-4.14.1.dist-info/scm_version.json,sha256=gw22Q2aBbdiYhyMbObTYNN7BN-wSpzOCktNiAuulRN8,161anyio-4.14.1.dist-info/top_level.txt,sha256=QglSMiWX8_5dpoVAEIHdEYzvqFMdSYWmCj6tYw2ITkQ,6anyio/__init__.py,sha256=HitUIfzvAojSeaHVmJ9rFn8k_yI63G6s_jUL2QChf4U,6405anyio/_backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0anyio/_backends/_asyncio.py,sha256=-q-5gUYg_r5SsN-OYbQnF_lvtW0v51-dFlsU8_gduWA,102077anyio/_backends/_trio.py,sha256=vR0ZgxVnOo4AHhHcHVG0worMc-3ZNpAZ6Vxh0m0ZZC0,45189anyio/_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0anyio/_core/_asyncio_selector_thread.py,sha256=2PdxFM3cs02Kp6BSppbvmRT7q7asreTW5FgBxEsflBo,5626anyio/_core/_contextmanagers.py,sha256=YInBCabiEeS-UaP_Jdxa1CaFC71ETPW8HZTHIM8Rsc8,7215anyio/_core/_eventloop.py,sha256=ByZUeJD9alMfcyTseRo5IzTO0IltEul_Gyq9iqSjqDk,6658anyio/_core/_exceptions.py,sha256=OfzLO4Z3Hog1TnipbIn72YNtkoYxS4lHW9MqKDeGc88,4936anyio/_core/_fileio.py,sha256=hHfyV0bXDL-R2ZNnInwse3nmTAd36AIz1cBxgmAwzAQ,31358anyio/_core/_resources.py,sha256=NbmU5O5UX3xEyACnkmYX28Fmwdl-f-ny0tHym26e0w0,435anyio/_core/_signals.py,sha256=mjTBB2hTKNPRlU0IhnijeQedpWOGERDiMjSlJQsFrug,1016anyio/_core/_sockets.py,sha256=9FU423j52XBBfGVr6MdzPTdyw8bGrzApZ5m338-AtsY,35286anyio/_core/_streams.py,sha256=FczFwIgDpnkK0bODWJXMpsUJYdvAD04kaUaGzJU8DK0,1806anyio/_core/_subprocesses.py,sha256=tkmkPKEkEaiMD8C9WRZBlmgjOYRDRbZdte6e-unay2E,7916anyio/_core/_synchronization.py,sha256=jn2nIbTRlBAUXL-mx_a3I_VnasF8GbVFpBRp2-YwCx0,21591anyio/_core/_tasks.py,sha256=ELL2jscaSW0Jw_xA6MtQlm3xwvFEzjTbc1u9Tteyt0I,13244anyio/_core/_tempfile.py,sha256=jE2w59FRF3yRo4vjkjfZF2YcqsBZvc66VWRwrJGDYGk,19624anyio/_core/_testing.py,sha256=u7MPqGXwpTxqI7hclSdNA30z2GH1Nw258uwKvy_RfBg,2340anyio/_core/_typedattr.py,sha256=P4ozZikn3-DbpoYcvyghS_FOYAgbmUxeoU8-L_07pZM,2508anyio/abc/__init__.py,sha256=6mWhcl_pGXhrgZVHP_TCfMvIXIOp9mroEFM90fYCU_U,2869anyio/abc/_eventloop.py,sha256=OqWYSEj0TmwL_xniCJt3_jHFWsuMk9THk8tCTGsKapI,10681anyio/abc/_resources.py,sha256=DrYvkNN1hH6Uvv5_5uKySvDsnknGVDe8FCKfko0VtN8,783anyio/abc/_sockets.py,sha256=OmVDrfemVvF9c5K1tpBgQyV6fn5v0XyCExLAqBOGz9o,13124anyio/abc/_streams.py,sha256=HYvna1iZbWcwLROTO6IhLX79RTRLPShZMWe0sG1q54I,7481anyio/abc/_subprocesses.py,sha256=cumAPJTktOQtw63IqG0lDpyZqu_l1EElvQHMiwJgL08,2067anyio/abc/_tasks.py,sha256=m-FtE4phxeNIELSG7A3H7VUz3jA2Ib5J2JIew8-PS6o,6642anyio/abc/_testing.py,sha256=9YYM2AXsYFvf4PLjUEr6yRxDiUeB5QbY_gOg0X_C6lY,2034anyio/from_thread.py,sha256=JYsbaCaIB_Iit6kNhtXSteJGt4PcQ7ncq0nIpcelIrg,19265anyio/functools.py,sha256=T4JS8IXq-x1S0Lbo2owF8l9fza2KypO147QLeyz4cjs,11797anyio/itertools.py,sha256=QV-9mnRCr2yBph8g01QFvN-bQ_Yle-8Sl13YSydBlMI,16168anyio/lowlevel.py,sha256=WPtppHfI2qs1nokzjn8elL8LvyqI05AK5Zslhlo71A4,6242anyio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0anyio/pytest_plugin.py,sha256=paMpI_VMNQf2bir0LfvgMpXSiYJoHDzWdKUVTyoHmvQ,13609anyio/streams/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0anyio/streams/buffered.py,sha256=v3xKtjFHgNV41g2SvMAkA_qd2t9WYlCI1_lNGCAatw0,6650anyio/streams/file.py,sha256=msnrotVKGMQomUu_Rj2qz9MvIdUp6d3JGr7MOEO8kV4,4428anyio/streams/memory.py,sha256=F0zwzvFJKAhX_LRZGoKzzqDC2oMM-f-yyTBrEYEGOaU,10740anyio/streams/stapled.py,sha256=T8Xqwf8K6EgURPxbt1N4i7A8BAk-gScv-GRhjLXIf_o,4390anyio/streams/text.py,sha256=BcVAGJw1VRvtIqnv-o0Rb0pwH7p8vwlvl21xHq522ag,5765anyio/streams/tls.py,sha256=DQVkXUvsTEYKkBO8dlVU7j_5H8QOtLy4sGi1Wrjqevo,15303anyio/to_interpreter.py,sha256=_mLngrMy97TMR6VbW4Y6YzDUk9ZuPcQMPlkuyRh3C9k,7100anyio/to_process.py,sha256=68qhLfce7MeXysid4fOpmhfWkgdo7Z7-9BC0VyUciIE,9809anyio/to_thread.py,sha256=f6h_k2d743GBv9FhAnhM_YpTvWgIrzBy9cOE0eJ1UJw,269312345Wheel-Version: 1.0Generator: setuptools (82.0.1)Root-Is-Purelib: trueTag: py3-none-any
12[pytest11]anyio = anyio.pytest_plugin1234567891011121314151617181920The MIT License (MIT)
Copyright (c) 2018 Alex Grönholm
Permission is hereby granted, free of charge, to any person obtaining a copy ofthis software and associated documentation files (the "Software"), to deal inthe Software without restriction, including without limitation the rights touse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies ofthe Software, and to permit persons to whom the Software is furnished to do so,subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESSFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS ORCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHERIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR INCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119{ "files": [ ".pre-commit-config.yaml", "LICENSE", "pyproject.toml", "AGENTS.md", "README.rst", "CLAUDE.md", ".readthedocs.yml", ".gitignore", "docs/tempfile.rst", "docs/signals.rst", "docs/synchronization.rst", "docs/contextmanagers.rst", "docs/testing.rst", "docs/networking.rst", "docs/contributing.rst", "docs/index.rst", "docs/versionhistory.rst", "docs/threads.rst", "docs/api.rst", "docs/typedattrs.rst", "docs/basics.rst", "docs/fileio.rst", "docs/cancellation.rst", "docs/support.rst", "docs/streams.rst", "docs/why.rst", "docs/tasks.rst", "docs/migration.rst", "docs/conf.py", "docs/subprocesses.rst", "docs/faq.rst", "docs/subinterpreters.rst", "src/anyio/functools.py", "src/anyio/py.typed", "src/anyio/__init__.py", "src/anyio/pytest_plugin.py", "src/anyio/itertools.py", "src/anyio/to_interpreter.py", "src/anyio/from_thread.py", "src/anyio/to_process.py", "src/anyio/to_thread.py", "src/anyio/lowlevel.py", "src/anyio/_backends/_trio.py", "src/anyio/_backends/__init__.py", "src/anyio/_backends/_asyncio.py", "src/anyio/streams/memory.py", "src/anyio/streams/__init__.py", "src/anyio/streams/tls.py", "src/anyio/streams/file.py", "src/anyio/streams/text.py", "src/anyio/streams/stapled.py", "src/anyio/streams/buffered.py", "src/anyio/abc/_eventloop.py", "src/anyio/abc/__init__.py", "src/anyio/abc/_sockets.py", "src/anyio/abc/_tasks.py", "src/anyio/abc/_subprocesses.py", "src/anyio/abc/_resources.py", "src/anyio/abc/_streams.py", "src/anyio/abc/_testing.py", "src/anyio/_core/_typedattr.py", "src/anyio/_core/_eventloop.py", "src/anyio/_core/__init__.py", "src/anyio/_core/_tempfile.py", "src/anyio/_core/_sockets.py", "src/anyio/_core/_tasks.py", "src/anyio/_core/_fileio.py", "src/anyio/_core/_synchronization.py", "src/anyio/_core/_subprocesses.py", "src/anyio/_core/_resources.py", "src/anyio/_core/_contextmanagers.py", "src/anyio/_core/_exceptions.py", "src/anyio/_core/_streams.py", "src/anyio/_core/_signals.py", "src/anyio/_core/_asyncio_selector_thread.py", "src/anyio/_core/_testing.py", "tests/test_itertools.py", "tests/test_functools.py", "tests/test_eventloop.py", "tests/__init__.py", "tests/test_to_thread.py", "tests/test_from_thread.py", "tests/test_lowlevel.py", "tests/test_to_interpreter.py", "tests/test_sockets.py", "tests/test_typedattr.py", "tests/test_to_process.py", "tests/test_all_attributes.py", "tests/test_synchronization.py", "tests/test_debugging.py", "tests/test_contextmanagers.py", "tests/test_fileio.py", "tests/conftest.py", "tests/test_signals.py", "tests/test_deprecations.py", "tests/test_tempfile.py", "tests/test_taskgroups.py", "tests/test_pytest_plugin.py", "tests/test_subprocesses.py", "tests/streams/test_text.py", "tests/streams/test_memory.py", "tests/streams/__init__.py", "tests/streams/test_file.py", "tests/streams/test_stapled.py", "tests/streams/test_tls.py", "tests/streams/test_buffered.py", ".github/pull_request_template.md", ".github/dependabot.yml", ".github/FUNDING.yml", ".github/ISSUE_TEMPLATE/features_request.yaml", ".github/ISSUE_TEMPLATE/bug_report.yaml", ".github/ISSUE_TEMPLATE/config.yml", ".github/workflows/test.yml", ".github/workflows/test-downstream.yml", ".github/workflows/publish.yml" ]}12345678{ "tag": "4.14.1", "distance": 0, "node": "g149b9e907618fadf6840a4d3cebad533b0c7d033", "dirty": false, "branch": "HEAD", "node_date": "2026-06-24"}1anyio123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115from __future__ import annotations
from ._core._contextmanagers import AsyncContextManagerMixin as AsyncContextManagerMixinfrom ._core._contextmanagers import ContextManagerMixin as ContextManagerMixinfrom ._core._eventloop import current_time as current_timefrom ._core._eventloop import get_all_backends as get_all_backendsfrom ._core._eventloop import get_available_backends as get_available_backendsfrom ._core._eventloop import get_cancelled_exc_class as get_cancelled_exc_classfrom ._core._eventloop import run as runfrom ._core._eventloop import sleep as sleepfrom ._core._eventloop import sleep_forever as sleep_foreverfrom ._core._eventloop import sleep_until as sleep_untilfrom ._core._exceptions import BrokenResourceError as BrokenResourceErrorfrom ._core._exceptions import BrokenWorkerInterpreter as BrokenWorkerInterpreterfrom ._core._exceptions import BrokenWorkerProcess as BrokenWorkerProcessfrom ._core._exceptions import BusyResourceError as BusyResourceErrorfrom ._core._exceptions import ClosedResourceError as ClosedResourceErrorfrom ._core._exceptions import ConnectionFailed as ConnectionFailedfrom ._core._exceptions import DelimiterNotFound as DelimiterNotFoundfrom ._core._exceptions import EndOfStream as EndOfStreamfrom ._core._exceptions import IncompleteRead as IncompleteReadfrom ._core._exceptions import NoEventLoopError as NoEventLoopErrorfrom ._core._exceptions import RunFinishedError as RunFinishedErrorfrom ._core._exceptions import TaskCancelled as TaskCancelledfrom ._core._exceptions import TaskFailed as TaskFailedfrom ._core._exceptions import TaskNotFinished as TaskNotFinishedfrom ._core._exceptions import TypedAttributeLookupError as TypedAttributeLookupErrorfrom ._core._exceptions import WouldBlock as WouldBlockfrom ._core._fileio import AsyncFile as AsyncFilefrom ._core._fileio import Path as Pathfrom ._core._fileio import open_file as open_filefrom ._core._fileio import wrap_file as wrap_filefrom ._core._resources import aclose_forcefully as aclose_forcefullyfrom ._core._signals import open_signal_receiver as open_signal_receiverfrom ._core._sockets import TCPConnectable as TCPConnectablefrom ._core._sockets import UNIXConnectable as UNIXConnectablefrom ._core._sockets import as_connectable as as_connectablefrom ._core._sockets import connect_tcp as connect_tcpfrom ._core._sockets import connect_unix as connect_unixfrom ._core._sockets import create_connected_udp_socket as create_connected_udp_socketfrom ._core._sockets import ( create_connected_unix_datagram_socket as create_connected_unix_datagram_socket,)from ._core._sockets import create_tcp_listener as create_tcp_listenerfrom ._core._sockets import create_udp_socket as create_udp_socketfrom ._core._sockets import create_unix_datagram_socket as create_unix_datagram_socketfrom ._core._sockets import create_unix_listener as create_unix_listenerfrom ._core._sockets import getaddrinfo as getaddrinfofrom ._core._sockets import getnameinfo as getnameinfofrom ._core._sockets import notify_closing as notify_closingfrom ._core._sockets import wait_readable as wait_readablefrom ._core._sockets import wait_socket_readable as wait_socket_readablefrom ._core._sockets import wait_socket_writable as wait_socket_writablefrom ._core._sockets import wait_writable as wait_writablefrom ._core._streams import create_memory_object_stream as create_memory_object_streamfrom ._core._subprocesses import open_process as open_processfrom ._core._subprocesses import run_process as run_processfrom ._core._synchronization import CapacityLimiter as CapacityLimiterfrom ._core._synchronization import ( CapacityLimiterStatistics as CapacityLimiterStatistics,)from ._core._synchronization import Condition as Conditionfrom ._core._synchronization import ConditionStatistics as ConditionStatisticsfrom ._core._synchronization import Event as Eventfrom ._core._synchronization import EventStatistics as EventStatisticsfrom ._core._synchronization import Lock as Lockfrom ._core._synchronization import LockStatistics as LockStatisticsfrom ._core._synchronization import ResourceGuard as ResourceGuardfrom ._core._synchronization import Semaphore as Semaphorefrom ._core._synchronization import SemaphoreStatistics as SemaphoreStatisticsfrom ._core._tasks import TASK_STATUS_IGNORED as TASK_STATUS_IGNOREDfrom ._core._tasks import CancelScope as CancelScopefrom ._core._tasks import TaskHandle as TaskHandlefrom ._core._tasks import create_task_group as create_task_groupfrom ._core._tasks import current_effective_deadline as current_effective_deadlinefrom ._core._tasks import fail_after as fail_afterfrom ._core._tasks import move_on_after as move_on_afterfrom ._core._tempfile import NamedTemporaryFile as NamedTemporaryFilefrom ._core._tempfile import SpooledTemporaryFile as SpooledTemporaryFilefrom ._core._tempfile import TemporaryDirectory as TemporaryDirectoryfrom ._core._tempfile import TemporaryFile as TemporaryFilefrom ._core._tempfile import gettempdir as gettempdirfrom ._core._tempfile import gettempdirb as gettempdirbfrom ._core._tempfile import mkdtemp as mkdtempfrom ._core._tempfile import mkstemp as mkstempfrom ._core._testing import TaskInfo as TaskInfofrom ._core._testing import get_current_task as get_current_taskfrom ._core._testing import get_running_tasks as get_running_tasksfrom ._core._testing import wait_all_tasks_blocked as wait_all_tasks_blockedfrom ._core._typedattr import TypedAttributeProvider as TypedAttributeProviderfrom ._core._typedattr import TypedAttributeSet as TypedAttributeSetfrom ._core._typedattr import typed_attribute as typed_attribute
# Re-export imports so they look like they live directly in this packagefor __value in list(locals().values()): if getattr(__value, "__module__", "").startswith("anyio."): __value.__module__ = __name__
del __value
def __getattr__(attr: str) -> type[BrokenWorkerInterpreter]: """Support deprecated aliases.""" if attr == "BrokenWorkerIntepreter": import warnings
warnings.warn( "The 'BrokenWorkerIntepreter' alias is deprecated, use 'BrokenWorkerInterpreter' instead.", DeprecationWarning, stacklevel=2, ) return BrokenWorkerInterpreter
raise AttributeError(f"module {__name__!r} has no attribute {attr!r}")1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456from __future__ import annotations
import arrayimport mathimport osimport socketimport sysimport typesimport weakreffrom collections.abc import ( AsyncGenerator, AsyncIterator, Awaitable, Callable, Collection, Coroutine, Iterable, Sequence,)from contextlib import AbstractContextManagerfrom contextvars import Contextfrom dataclasses import dataclassfrom functools import partial, wrapsfrom io import IOBasefrom os import PathLikefrom signal import Signalsfrom socket import AddressFamily, SocketKindfrom types import TracebackTypefrom typing import ( IO, TYPE_CHECKING, Any, Generic, Literal, NoReturn, ParamSpec, TypeVar, cast, overload,)
import trio.from_threadimport trio.lowlevelfrom outcome import Error, Outcome, Valuefrom trio.lowlevel import ( current_root_task, current_task, notify_closing, wait_readable, wait_writable,)from trio.socket import SocketType as TrioSocketTypefrom trio.to_thread import run_sync
from .. import ( CapacityLimiterStatistics, EventStatistics, LockStatistics, RunFinishedError, TaskInfo, WouldBlock, abc,)from .._core._eventloop import claim_worker_threadfrom .._core._exceptions import ( BrokenResourceError, BusyResourceError, ClosedResourceError, EndOfStream,)from .._core._sockets import convert_ipv6_sockaddrfrom .._core._streams import create_memory_object_streamfrom .._core._synchronization import ( CapacityLimiter as BaseCapacityLimiter,)from .._core._synchronization import Event as BaseEventfrom .._core._synchronization import Lock as BaseLockfrom .._core._synchronization import ( ResourceGuard, SemaphoreStatistics,)from .._core._synchronization import Semaphore as BaseSemaphorefrom .._core._tasks import CancelScope as BaseCancelScopefrom .._core._tasks import TaskHandlefrom ..abc import IPSockAddrType, UDPPacketType, UNIXDatagramPacketTypefrom ..abc._eventloop import AsyncBackend, StrOrBytesPathfrom ..abc._tasks import T_contra, call_for_coroutine, get_callable_namefrom ..streams.memory import MemoryObjectSendStream
if TYPE_CHECKING: from _typeshed import FileDescriptorLike
if sys.version_info >= (3, 11): from typing import TypeVarTuple, Unpackelse: from exceptiongroup import BaseExceptionGroup from typing_extensions import TypeVarTuple, Unpack
T = TypeVar("T")T_Retval = TypeVar("T_Retval")T_co = TypeVar("T_co", covariant=True)T_SockAddr = TypeVar("T_SockAddr", str, IPSockAddrType)PosArgsT = TypeVarTuple("PosArgsT")P = ParamSpec("P")
def ensure_returns_coro( func: Callable[P, Awaitable[T_Retval]],) -> Callable[P, Coroutine[Any, Any, T_Retval]]: @wraps(func) def wrapper(*args: P.args, **kwargs: P.kwargs) -> Coroutine[Any, Any, T_Retval]: awaitable = func(*args, **kwargs) # Check the common case first. if isinstance(awaitable, Coroutine): return awaitable elif not isinstance(awaitable, Awaitable): # The user violated the type annotations. Still, we should pass this on to # Trio so it can raise with an appropriate message. return awaitable else:
@wraps(func) async def inner_wrapper() -> T_Retval: return await awaitable
return inner_wrapper()
return wrapper
## Event loop#
RunVar = trio.lowlevel.RunVar
## Timeouts and cancellation#
class CancelScope(BaseCancelScope): __slots__ = ("__original",)
def __new__( cls, original: trio.CancelScope | None = None, **kwargs: object ) -> CancelScope: return object.__new__(cls)
def __init__(self, original: trio.CancelScope | None = None, **kwargs: Any) -> None: self.__original = original or trio.CancelScope(**kwargs)
def __enter__(self) -> CancelScope: self.__original.__enter__() return self
def __exit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None, ) -> bool: return self.__original.__exit__(exc_type, exc_val, exc_tb)
def cancel(self, reason: str | None = None) -> None: self.__original.cancel(reason)
@property def deadline(self) -> float: return self.__original.deadline
@deadline.setter def deadline(self, value: float) -> None: self.__original.deadline = value
@property def cancel_called(self) -> bool: return self.__original.cancel_called
@property def cancelled_caught(self) -> bool: return self.__original.cancelled_caught
@property def shield(self) -> bool: return self.__original.shield
@shield.setter def shield(self, value: bool) -> None: self.__original.shield = value
## Task groups#
empty_start_value = object()
class _TrioTaskStatus(Generic[T_contra], abc.TaskStatus[T_contra]): early_start_value: T_contra | object = empty_start_value real_task_status: trio.TaskStatus[T_contra | None] | None = None
def started(self, value: T_contra | None = None) -> None: if self.real_task_status is None: if self.early_start_value is not empty_start_value: raise RuntimeError("called 'started' twice on the same task status")
self.early_start_value = value else: self.real_task_status.started(value)
class TaskGroup(abc.TaskGroup): def __init__(self) -> None: self._entered = False self._active = False self._nursery_manager = trio.open_nursery(strict_exception_groups=True) self.cancel_scope = None # type: ignore[assignment]
async def __aenter__(self) -> TaskGroup: if self._entered: raise RuntimeError("TaskGroup cannot be entered more than once")
self._entered = True self._active = True self._nursery = await self._nursery_manager.__aenter__() self.cancel_scope = CancelScope(self._nursery.cancel_scope) return self
async def __aexit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None, ) -> bool: try: # trio.Nursery.__exit__ returns bool; .open_nursery has wrong type return await self._nursery_manager.__aexit__(exc_type, exc_val, exc_tb) # type: ignore[return-value] except BaseExceptionGroup as exc: if not exc.split(trio.Cancelled)[1]: raise trio.Cancelled._create() from exc
raise finally: del exc_val, exc_tb self._active = False
def _check_active(self, coro: Coroutine | None = None) -> None: if not self._active: if coro is not None: coro.close()
raise RuntimeError( "This task group is not active; no new tasks can be started." )
def create_task( self, coro: Coroutine[Any, Any, T_co], *, name: object = None, context: Context | None = None, ) -> TaskHandle[T_co]: if not isinstance(coro, Coroutine): raise TypeError(f"expected a coroutine, got {coro.__class__.__qualname__}")
self._check_active(coro) handle = TaskHandle(coro, name) if context is not None: context.run( partial(self._nursery.start_soon, handle._run_coro, name=handle.name) ) else: self._nursery.start_soon(handle._run_coro, name=handle.name)
return handle
async def start( self, func: Callable[[Unpack[PosArgsT]], Coroutine[Any, Any, T_co]], *args: Unpack[PosArgsT], name: object = None, return_handle: Literal[False] | Literal[True] = False, ) -> Any: handle: TaskHandle[T_co]
async def run_coro_with_task_status( *, task_status: trio.TaskStatus[Any] ) -> None: nonlocal handle wrapper_task_status = _TrioTaskStatus() coro = call_for_coroutine(func, args, task_status=wrapper_task_status) if wrapper_task_status.early_start_value is not empty_start_value: task_status.started(wrapper_task_status.early_start_value) else: wrapper_task_status.real_task_status = task_status
handle = TaskHandle(coro, name) await handle._run_coro()
self._check_active() final_name = get_callable_name(func, name) start_value = await self._nursery.start( run_coro_with_task_status, name=final_name ) if return_handle: handle._start_value = start_value return handle else: return start_value
## Subprocesses#
@dataclass(eq=False)class ReceiveStreamWrapper(abc.ByteReceiveStream): _stream: trio.abc.ReceiveStream
async def receive(self, max_bytes: int | None = None) -> bytes: try: data = await self._stream.receive_some(max_bytes) except trio.ClosedResourceError as exc: raise ClosedResourceError from exc.__cause__ except trio.BrokenResourceError as exc: raise BrokenResourceError from exc.__cause__
if data: return bytes(data) else: raise EndOfStream
async def aclose(self) -> None: await self._stream.aclose()
@dataclass(eq=False)class SendStreamWrapper(abc.ByteSendStream): _stream: trio.abc.SendStream
async def send(self, item: bytes) -> None: try: await self._stream.send_all(item) except trio.ClosedResourceError as exc: raise ClosedResourceError from exc.__cause__ except trio.BrokenResourceError as exc: raise BrokenResourceError from exc.__cause__
async def aclose(self) -> None: await self._stream.aclose()
@dataclass(eq=False)class Process(abc.Process): _process: trio.Process _stdin: abc.ByteSendStream | None _stdout: abc.ByteReceiveStream | None _stderr: abc.ByteReceiveStream | None
async def aclose(self) -> None: with CancelScope(shield=True): if self._stdin: await self._stdin.aclose() if self._stdout: await self._stdout.aclose() if self._stderr: await self._stderr.aclose()
try: await self.wait() except BaseException: self.kill() with CancelScope(shield=True): await self.wait() raise
async def wait(self) -> int: return await self._process.wait()
def terminate(self) -> None: self._process.terminate()
def kill(self) -> None: self._process.kill()
def send_signal(self, signal: Signals) -> None: self._process.send_signal(signal)
@property def pid(self) -> int: return self._process.pid
@property def returncode(self) -> int | None: return self._process.returncode
@property def stdin(self) -> abc.ByteSendStream | None: return self._stdin
@property def stdout(self) -> abc.ByteReceiveStream | None: return self._stdout
@property def stderr(self) -> abc.ByteReceiveStream | None: return self._stderr
class _ProcessPoolShutdownInstrument(trio.abc.Instrument): def after_run(self) -> None: super().after_run()
current_default_worker_process_limiter: trio.lowlevel.RunVar = RunVar( "current_default_worker_process_limiter")
async def _shutdown_process_pool(workers: set[abc.Process]) -> None: try: await trio.sleep(math.inf) except trio.Cancelled: for process in workers: if process.returncode is None: process.kill()
with CancelScope(shield=True): for process in workers: await process.aclose()
## Sockets and networking#
class _TrioSocketMixin(Generic[T_SockAddr]): def __init__(self, trio_socket: TrioSocketType) -> None: self._trio_socket = trio_socket self._closed = False
def _check_closed(self) -> None: if self._closed: raise ClosedResourceError if self._trio_socket.fileno() < 0: raise BrokenResourceError
@property def _raw_socket(self) -> socket.socket: return self._trio_socket._sock # type: ignore[attr-defined]
async def aclose(self) -> None: if self._trio_socket.fileno() >= 0: self._closed = True self._trio_socket.close()
def _convert_socket_error(self, exc: BaseException) -> NoReturn: if isinstance(exc, trio.ClosedResourceError): raise ClosedResourceError from exc elif self._trio_socket.fileno() < 0 and self._closed: raise ClosedResourceError from None elif isinstance(exc, OSError): raise BrokenResourceError from exc else: raise exc
class SocketStream(_TrioSocketMixin, abc.SocketStream): def __init__(self, trio_socket: TrioSocketType) -> None: super().__init__(trio_socket) self._receive_guard = ResourceGuard("reading from") self._send_guard = ResourceGuard("writing to")
async def receive(self, max_bytes: int = 65536) -> bytes: with self._receive_guard: try: data = await self._trio_socket.recv(max_bytes) except BaseException as exc: self._convert_socket_error(exc)
if data: return data else: raise EndOfStream
async def send(self, item: bytes) -> None: with self._send_guard: view = memoryview(item) while view: try: bytes_sent = await self._trio_socket.send(view) except BaseException as exc: self._convert_socket_error(exc)
view = view[bytes_sent:]
async def send_eof(self) -> None: self._trio_socket.shutdown(socket.SHUT_WR)
class UNIXSocketStream(SocketStream, abc.UNIXSocketStream): async def receive_fds(self, msglen: int, maxfds: int) -> tuple[bytes, list[int]]: if not isinstance(msglen, int) or msglen < 0: raise ValueError("msglen must be a non-negative integer") if not isinstance(maxfds, int) or maxfds < 1: raise ValueError("maxfds must be a positive integer")
fds = array.array("i") await trio.lowlevel.checkpoint() with self._receive_guard: while True: try: message, ancdata, flags, addr = await self._trio_socket.recvmsg( msglen, socket.CMSG_LEN(maxfds * fds.itemsize) ) except BaseException as exc: self._convert_socket_error(exc) else: if not message and not ancdata: raise EndOfStream
break
for cmsg_level, cmsg_type, cmsg_data in ancdata: if cmsg_level != socket.SOL_SOCKET or cmsg_type != socket.SCM_RIGHTS: raise RuntimeError( f"Received unexpected ancillary data; message = {message!r}, " f"cmsg_level = {cmsg_level}, cmsg_type = {cmsg_type}" )
fds.frombytes(cmsg_data[: len(cmsg_data) - (len(cmsg_data) % fds.itemsize)])
return message, list(fds)
async def send_fds(self, message: bytes, fds: Collection[int | IOBase]) -> None: if not message: raise ValueError("message must not be empty") if not fds: raise ValueError("fds must not be empty")
filenos: list[int] = [] for fd in fds: if isinstance(fd, int): filenos.append(fd) elif isinstance(fd, IOBase): filenos.append(fd.fileno())
fdarray = array.array("i", filenos) await trio.lowlevel.checkpoint() with self._send_guard: while True: try: await self._trio_socket.sendmsg( [message], [ ( socket.SOL_SOCKET, socket.SCM_RIGHTS, fdarray, ) ], ) break except BaseException as exc: self._convert_socket_error(exc)
class TCPSocketListener(_TrioSocketMixin, abc.SocketListener): def __init__(self, raw_socket: socket.socket): super().__init__(trio.socket.from_stdlib_socket(raw_socket)) self._accept_guard = ResourceGuard("accepting connections from")
async def accept(self) -> SocketStream: with self._accept_guard: try: trio_socket, _addr = await self._trio_socket.accept() except BaseException as exc: self._convert_socket_error(exc)
trio_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) return SocketStream(trio_socket)
class UNIXSocketListener(_TrioSocketMixin, abc.SocketListener): def __init__(self, raw_socket: socket.socket): super().__init__(trio.socket.from_stdlib_socket(raw_socket)) self._accept_guard = ResourceGuard("accepting connections from")
async def accept(self) -> UNIXSocketStream: with self._accept_guard: try: trio_socket, _addr = await self._trio_socket.accept() except BaseException as exc: self._convert_socket_error(exc)
return UNIXSocketStream(trio_socket)
class UDPSocket(_TrioSocketMixin[IPSockAddrType], abc.UDPSocket): def __init__(self, trio_socket: TrioSocketType) -> None: super().__init__(trio_socket) self._receive_guard = ResourceGuard("reading from") self._send_guard = ResourceGuard("writing to")
async def receive(self) -> tuple[bytes, IPSockAddrType]: with self._receive_guard: try: data, addr = await self._trio_socket.recvfrom(65536) return data, convert_ipv6_sockaddr(addr) except BaseException as exc: self._convert_socket_error(exc)
async def send(self, item: UDPPacketType) -> None: with self._send_guard: try: await self._trio_socket.sendto(*item) except BaseException as exc: self._convert_socket_error(exc)
class ConnectedUDPSocket(_TrioSocketMixin[IPSockAddrType], abc.ConnectedUDPSocket): def __init__(self, trio_socket: TrioSocketType) -> None: super().__init__(trio_socket) self._receive_guard = ResourceGuard("reading from") self._send_guard = ResourceGuard("writing to")
async def receive(self) -> bytes: with self._receive_guard: try: return await self._trio_socket.recv(65536) except BaseException as exc: self._convert_socket_error(exc)
async def send(self, item: bytes) -> None: with self._send_guard: try: await self._trio_socket.send(item) except BaseException as exc: self._convert_socket_error(exc)
class UNIXDatagramSocket(_TrioSocketMixin[str], abc.UNIXDatagramSocket): def __init__(self, trio_socket: TrioSocketType) -> None: super().__init__(trio_socket) self._receive_guard = ResourceGuard("reading from") self._send_guard = ResourceGuard("writing to")
async def receive(self) -> UNIXDatagramPacketType: with self._receive_guard: try: data, addr = await self._trio_socket.recvfrom(65536) return data, addr except BaseException as exc: self._convert_socket_error(exc)
async def send(self, item: UNIXDatagramPacketType) -> None: with self._send_guard: try: await self._trio_socket.sendto(*item) except BaseException as exc: self._convert_socket_error(exc)
class ConnectedUNIXDatagramSocket( _TrioSocketMixin[str], abc.ConnectedUNIXDatagramSocket): def __init__(self, trio_socket: TrioSocketType) -> None: super().__init__(trio_socket) self._receive_guard = ResourceGuard("reading from") self._send_guard = ResourceGuard("writing to")
async def receive(self) -> bytes: with self._receive_guard: try: return await self._trio_socket.recv(65536) except BaseException as exc: self._convert_socket_error(exc)
async def send(self, item: bytes) -> None: with self._send_guard: try: await self._trio_socket.send(item) except BaseException as exc: self._convert_socket_error(exc)
## Synchronization#
class Event(BaseEvent): __slots__ = ("__original",)
def __new__(cls) -> Event: return object.__new__(cls)
def __init__(self) -> None: self.__original = trio.Event()
def is_set(self) -> bool: return self.__original.is_set()
async def wait(self) -> None: return await self.__original.wait()
def statistics(self) -> EventStatistics: orig_statistics = self.__original.statistics() return EventStatistics(tasks_waiting=orig_statistics.tasks_waiting)
def set(self) -> None: self.__original.set()
class Lock(BaseLock): __slots__ = "_fast_acquire", "__original"
def __new__(cls, *, fast_acquire: bool = False) -> Lock: return object.__new__(cls)
def __init__(self, *, fast_acquire: bool = False) -> None: self._fast_acquire = fast_acquire self.__original = trio.Lock()
@staticmethod def _convert_runtime_error_msg(exc: RuntimeError) -> None: if exc.args == ("attempt to re-acquire an already held Lock",): exc.args = ("Attempted to acquire an already held Lock",)
async def acquire(self) -> None: if not self._fast_acquire: try: await self.__original.acquire() except RuntimeError as exc: self._convert_runtime_error_msg(exc) raise
return
# This is the "fast path" where we don't let other tasks run await trio.lowlevel.checkpoint_if_cancelled() try: self.__original.acquire_nowait() except trio.WouldBlock: await self.__original._lot.park() except RuntimeError as exc: self._convert_runtime_error_msg(exc) raise
def acquire_nowait(self) -> None: try: self.__original.acquire_nowait() except trio.WouldBlock: raise WouldBlock from None except RuntimeError as exc: self._convert_runtime_error_msg(exc) raise
def locked(self) -> bool: return self.__original.locked()
def release(self) -> None: self.__original.release()
def statistics(self) -> LockStatistics: orig_statistics = self.__original.statistics() owner = TrioTaskInfo(orig_statistics.owner) if orig_statistics.owner else None return LockStatistics( orig_statistics.locked, owner, orig_statistics.tasks_waiting )
class Semaphore(BaseSemaphore): __slots__ = ("__original",)
def __new__( cls, initial_value: int, *, max_value: int | None = None, fast_acquire: bool = False, ) -> Semaphore: return object.__new__(cls)
def __init__( self, initial_value: int, *, max_value: int | None = None, fast_acquire: bool = False, ) -> None: super().__init__(initial_value, max_value=max_value, fast_acquire=fast_acquire) self.__original = trio.Semaphore(initial_value, max_value=max_value)
async def acquire(self) -> None: if not self._fast_acquire: await self.__original.acquire() return
# This is the "fast path" where we don't let other tasks run await trio.lowlevel.checkpoint_if_cancelled() try: self.__original.acquire_nowait() except trio.WouldBlock: await self.__original._lot.park()
def acquire_nowait(self) -> None: try: self.__original.acquire_nowait() except trio.WouldBlock: raise WouldBlock from None
@property def max_value(self) -> int | None: return self.__original.max_value
@property def value(self) -> int: return self.__original.value
def release(self) -> None: self.__original.release()
def statistics(self) -> SemaphoreStatistics: orig_statistics = self.__original.statistics() return SemaphoreStatistics(orig_statistics.tasks_waiting)
class CapacityLimiter(BaseCapacityLimiter): __slots__ = ("__original",)
def __new__( cls, total_tokens: float | None = None, *, original: trio.CapacityLimiter | None = None, ) -> CapacityLimiter: return object.__new__(cls)
def __init__( self, total_tokens: float | None = None, *, original: trio.CapacityLimiter | None = None, ) -> None: if original is not None: self.__original = original else: assert total_tokens is not None self.__original = trio.CapacityLimiter(total_tokens)
async def __aenter__(self) -> None: return await self.__original.__aenter__()
async def __aexit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None, ) -> None: await self.__original.__aexit__(exc_type, exc_val, exc_tb)
@property def total_tokens(self) -> float: return self.__original.total_tokens
@total_tokens.setter def total_tokens(self, value: float) -> None: self.__original.total_tokens = value
@property def borrowed_tokens(self) -> int: return self.__original.borrowed_tokens
@property def available_tokens(self) -> float: return self.__original.available_tokens
def acquire_nowait(self) -> None: self.__original.acquire_nowait()
def acquire_on_behalf_of_nowait(self, borrower: object) -> None: self.__original.acquire_on_behalf_of_nowait(borrower)
async def acquire(self) -> None: await self.__original.acquire()
async def acquire_on_behalf_of(self, borrower: object) -> None: await self.__original.acquire_on_behalf_of(borrower)
def release(self) -> None: return self.__original.release()
def release_on_behalf_of(self, borrower: object) -> None: return self.__original.release_on_behalf_of(borrower)
def statistics(self) -> CapacityLimiterStatistics: orig = self.__original.statistics() return CapacityLimiterStatistics( borrowed_tokens=orig.borrowed_tokens, total_tokens=orig.total_tokens, borrowers=tuple(orig.borrowers), tasks_waiting=orig.tasks_waiting, )
_capacity_limiter_wrapper: trio.lowlevel.RunVar = RunVar("_capacity_limiter_wrapper")
## Signal handling#
class _SignalReceiver: _iterator: AsyncIterator[int]
def __init__(self, signals: tuple[Signals, ...]): self._signals = signals
def __enter__(self) -> _SignalReceiver: self._cm = trio.open_signal_receiver(*self._signals) self._iterator = self._cm.__enter__() return self
def __exit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None, ) -> bool | None: return self._cm.__exit__(exc_type, exc_val, exc_tb)
def __aiter__(self) -> _SignalReceiver: return self
async def __anext__(self) -> Signals: signum = await self._iterator.__anext__() return Signals(signum)
## Testing and debugging#
class TestRunner(abc.TestRunner): def __init__(self, **options: Any) -> None: from queue import Queue
self._call_queue: Queue[Callable[[], object]] = Queue() self._send_stream: ( MemoryObjectSendStream[tuple[Awaitable[Any], list[Outcome]]] | None ) = None self._options = options
def __exit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None, ) -> None: if self._send_stream: self._send_stream.close() while self._send_stream is not None: self._call_queue.get()()
def is_running(self) -> bool: return trio.lowlevel.in_trio_task()
async def _run_tests_and_fixtures(self) -> None: self._send_stream, receive_stream = create_memory_object_stream[ tuple[Awaitable[Any], list[Outcome]] ](1) with receive_stream: async for awaitable, outcome_holder in receive_stream: try: retval = await awaitable except BaseException as exc: outcome_holder.append(Error(exc)) else: outcome_holder.append(Value(retval))
def _main_task_finished(self, outcome: object) -> None: self._send_stream = None
def _call_in_runner_task( self, func: Callable[P, Awaitable[T_Retval]], /, *args: P.args, **kwargs: P.kwargs, ) -> T_Retval: if self._send_stream is None: trio.lowlevel.start_guest_run( self._run_tests_and_fixtures, run_sync_soon_threadsafe=self._call_queue.put, done_callback=self._main_task_finished, **self._options, ) while self._send_stream is None: self._call_queue.get()()
outcome_holder: list[Outcome] = [] self._send_stream.send_nowait((func(*args, **kwargs), outcome_holder)) while not outcome_holder: self._call_queue.get()()
return outcome_holder[0].unwrap()
def run_asyncgen_fixture( self, fixture_func: Callable[..., AsyncGenerator[T_Retval, Any]], kwargs: dict[str, Any], ) -> Iterable[T_Retval]: asyncgen = fixture_func(**kwargs) fixturevalue: T_Retval = self._call_in_runner_task(asyncgen.asend, None)
yield fixturevalue
try: self._call_in_runner_task(asyncgen.asend, None) except StopAsyncIteration: pass else: self._call_in_runner_task(asyncgen.aclose) raise RuntimeError("Async generator fixture did not stop")
def run_fixture( self, fixture_func: Callable[..., Coroutine[Any, Any, T_Retval]], kwargs: dict[str, Any], ) -> T_Retval: return self._call_in_runner_task(fixture_func, **kwargs)
def run_test( self, test_func: Callable[..., Coroutine[Any, Any, Any]], kwargs: dict[str, Any] ) -> None: self._call_in_runner_task(test_func, **kwargs)
class TrioTaskInfo(TaskInfo): def __init__(self, task: trio.lowlevel.Task): parent_id = None if task.parent_nursery and task.parent_nursery.parent_task: parent_id = id(task.parent_nursery.parent_task)
super().__init__(id(task), parent_id, task.name, task.coro) self._task = weakref.proxy(task)
def has_pending_cancellation(self) -> bool: try: return self._task._cancel_status.effectively_cancelled except ReferenceError: # If the task is no longer around, it surely doesn't have a cancellation # pending return False
class TrioBackend(AsyncBackend): @classmethod def run( cls, func: Callable[[Unpack[PosArgsT]], Awaitable[T_Retval]], args: tuple[Unpack[PosArgsT]], kwargs: dict[str, Any], options: dict[str, Any], ) -> T_Retval: assert not kwargs, "unreachable, and not supported by Trio" return trio.run(ensure_returns_coro(func), *args, **options)
@classmethod def current_token(cls) -> object: return trio.lowlevel.current_trio_token()
@classmethod def current_time(cls) -> float: return trio.current_time()
@classmethod def cancelled_exception_class(cls) -> type[BaseException]: return trio.Cancelled
@classmethod async def checkpoint(cls) -> None: await trio.lowlevel.checkpoint()
@classmethod async def checkpoint_if_cancelled(cls) -> None: await trio.lowlevel.checkpoint_if_cancelled()
@classmethod async def cancel_shielded_checkpoint(cls) -> None: await trio.lowlevel.cancel_shielded_checkpoint()
@classmethod async def sleep(cls, delay: float) -> None: await trio.sleep(delay)
@classmethod def create_cancel_scope( cls, *, deadline: float = math.inf, shield: bool = False ) -> abc.CancelScope: return CancelScope(deadline=deadline, shield=shield)
@classmethod def current_effective_deadline(cls) -> float: return trio.current_effective_deadline()
@classmethod def create_task_group(cls) -> abc.TaskGroup: return TaskGroup()
@classmethod def create_event(cls) -> abc.Event: return Event()
@classmethod def create_lock(cls, *, fast_acquire: bool) -> Lock: return Lock(fast_acquire=fast_acquire)
@classmethod def create_semaphore( cls, initial_value: int, *, max_value: int | None = None, fast_acquire: bool = False, ) -> abc.Semaphore: return Semaphore(initial_value, max_value=max_value, fast_acquire=fast_acquire)
@classmethod def create_capacity_limiter(cls, total_tokens: float) -> CapacityLimiter: return CapacityLimiter(total_tokens)
@classmethod async def run_sync_in_worker_thread( cls, func: Callable[[Unpack[PosArgsT]], T_Retval], args: tuple[Unpack[PosArgsT]], abandon_on_cancel: bool = False, limiter: abc.CapacityLimiter | None = None, ) -> T_Retval: def wrapper() -> T_Retval: with claim_worker_thread(TrioBackend, token): return func(*args)
token = TrioBackend.current_token() return await run_sync( wrapper, abandon_on_cancel=abandon_on_cancel, limiter=cast(trio.CapacityLimiter, limiter), )
@classmethod def check_cancelled(cls) -> None: trio.from_thread.check_cancelled()
@classmethod def run_async_from_thread( cls, func: Callable[[Unpack[PosArgsT]], Coroutine[Any, Any, T_co]], args: tuple[Unpack[PosArgsT]], token: object, ) -> T_co: trio_token = cast("trio.lowlevel.TrioToken | None", token) try: return trio.from_thread.run(func, *args, trio_token=trio_token) except trio.RunFinishedError: raise RunFinishedError from None
@classmethod def run_sync_from_thread( cls, func: Callable[[Unpack[PosArgsT]], T_Retval], args: tuple[Unpack[PosArgsT]], token: object, ) -> T_Retval: trio_token = cast("trio.lowlevel.TrioToken | None", token) try: return trio.from_thread.run_sync(func, *args, trio_token=trio_token) except trio.RunFinishedError: raise RunFinishedError from None
@classmethod async def open_process( cls, command: StrOrBytesPath | Sequence[StrOrBytesPath], *, stdin: int | IO[Any] | None, stdout: int | IO[Any] | None, stderr: int | IO[Any] | None, **kwargs: Any, ) -> Process: def convert_item(item: StrOrBytesPath) -> str: str_or_bytes = os.fspath(item) if isinstance(str_or_bytes, str): return str_or_bytes else: return os.fsdecode(str_or_bytes)
if isinstance(command, (str, bytes, PathLike)): process = await trio.lowlevel.open_process( convert_item(command), stdin=stdin, stdout=stdout, stderr=stderr, shell=True, **kwargs, ) else: process = await trio.lowlevel.open_process( [convert_item(item) for item in command], stdin=stdin, stdout=stdout, stderr=stderr, shell=False, **kwargs, )
stdin_stream = SendStreamWrapper(process.stdin) if process.stdin else None stdout_stream = ReceiveStreamWrapper(process.stdout) if process.stdout else None stderr_stream = ReceiveStreamWrapper(process.stderr) if process.stderr else None return Process(process, stdin_stream, stdout_stream, stderr_stream)
@classmethod def setup_process_pool_exit_at_shutdown(cls, workers: set[abc.Process]) -> None: trio.lowlevel.spawn_system_task(_shutdown_process_pool, workers)
@classmethod async def connect_tcp( cls, host: str, port: int, local_address: IPSockAddrType | None = None ) -> SocketStream: family = socket.AF_INET6 if ":" in host else socket.AF_INET trio_socket = trio.socket.socket(family) trio_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) if local_address: await trio_socket.bind(local_address)
try: await trio_socket.connect((host, port)) except BaseException: trio_socket.close() raise
return SocketStream(trio_socket)
@classmethod async def connect_unix(cls, path: str | bytes) -> abc.UNIXSocketStream: trio_socket = trio.socket.socket(socket.AF_UNIX) try: await trio_socket.connect(path) except BaseException: trio_socket.close() raise
return UNIXSocketStream(trio_socket)
@classmethod def create_tcp_listener(cls, sock: socket.socket) -> abc.SocketListener: return TCPSocketListener(sock)
@classmethod def create_unix_listener(cls, sock: socket.socket) -> abc.SocketListener: return UNIXSocketListener(sock)
@classmethod async def create_udp_socket( cls, family: socket.AddressFamily, local_address: IPSockAddrType | None, remote_address: IPSockAddrType | None, reuse_port: bool, ) -> UDPSocket | ConnectedUDPSocket: trio_socket = trio.socket.socket(family=family, type=socket.SOCK_DGRAM)
if reuse_port: trio_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
if local_address: await trio_socket.bind(local_address)
if remote_address: await trio_socket.connect(remote_address) return ConnectedUDPSocket(trio_socket) else: return UDPSocket(trio_socket)
@classmethod @overload async def create_unix_datagram_socket( cls, raw_socket: socket.socket, remote_path: None ) -> abc.UNIXDatagramSocket: ...
@classmethod @overload async def create_unix_datagram_socket( cls, raw_socket: socket.socket, remote_path: str | bytes ) -> abc.ConnectedUNIXDatagramSocket: ...
@classmethod async def create_unix_datagram_socket( cls, raw_socket: socket.socket, remote_path: str | bytes | None ) -> abc.UNIXDatagramSocket | abc.ConnectedUNIXDatagramSocket: trio_socket = trio.socket.from_stdlib_socket(raw_socket)
if remote_path: await trio_socket.connect(remote_path) return ConnectedUNIXDatagramSocket(trio_socket) else: return UNIXDatagramSocket(trio_socket)
@classmethod async def getaddrinfo( cls, host: bytes | str | None, port: str | int | None, *, family: int | AddressFamily = 0, type: int | SocketKind = 0, proto: int = 0, flags: int = 0, ) -> Sequence[ tuple[ AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes], ] ]: return await trio.socket.getaddrinfo(host, port, family, type, proto, flags)
@classmethod async def getnameinfo( cls, sockaddr: IPSockAddrType, flags: int = 0 ) -> tuple[str, str]: return await trio.socket.getnameinfo(sockaddr, flags)
@classmethod async def wait_readable(cls, obj: FileDescriptorLike) -> None: try: await wait_readable(obj) except trio.ClosedResourceError as exc: raise ClosedResourceError().with_traceback(exc.__traceback__) from None except trio.BusyResourceError: raise BusyResourceError("reading from") from None
@classmethod async def wait_writable(cls, obj: FileDescriptorLike) -> None: try: await wait_writable(obj) except trio.ClosedResourceError as exc: raise ClosedResourceError().with_traceback(exc.__traceback__) from None except trio.BusyResourceError: raise BusyResourceError("writing to") from None
@classmethod def notify_closing(cls, obj: FileDescriptorLike) -> None: notify_closing(obj)
@classmethod async def wrap_listener_socket(cls, sock: socket.socket) -> abc.SocketListener: if hasattr(socket, "AF_UNIX") and sock.family == socket.AF_UNIX: return UNIXSocketListener(sock)
return TCPSocketListener(sock)
@classmethod async def wrap_stream_socket(cls, sock: socket.socket) -> SocketStream: trio_sock = trio.socket.from_stdlib_socket(sock) return SocketStream(trio_sock)
@classmethod async def wrap_unix_stream_socket(cls, sock: socket.socket) -> UNIXSocketStream: trio_sock = trio.socket.from_stdlib_socket(sock) return UNIXSocketStream(trio_sock)
@classmethod async def wrap_udp_socket(cls, sock: socket.socket) -> UDPSocket: trio_sock = trio.socket.from_stdlib_socket(sock) return UDPSocket(trio_sock)
@classmethod async def wrap_connected_udp_socket(cls, sock: socket.socket) -> ConnectedUDPSocket: trio_sock = trio.socket.from_stdlib_socket(sock) return ConnectedUDPSocket(trio_sock)
@classmethod async def wrap_unix_datagram_socket(cls, sock: socket.socket) -> UNIXDatagramSocket: trio_sock = trio.socket.from_stdlib_socket(sock) return UNIXDatagramSocket(trio_sock)
@classmethod async def wrap_connected_unix_datagram_socket( cls, sock: socket.socket ) -> ConnectedUNIXDatagramSocket: trio_sock = trio.socket.from_stdlib_socket(sock) return ConnectedUNIXDatagramSocket(trio_sock)
@classmethod def current_default_thread_limiter(cls) -> CapacityLimiter: try: return _capacity_limiter_wrapper.get() except LookupError: limiter = CapacityLimiter( original=trio.to_thread.current_default_thread_limiter() ) _capacity_limiter_wrapper.set(limiter) return limiter
@classmethod def open_signal_receiver( cls, *signals: Signals ) -> AbstractContextManager[AsyncIterator[Signals]]: return _SignalReceiver(signals)
@classmethod def get_current_task(cls) -> TaskInfo: task = current_task() return TrioTaskInfo(task)
@classmethod def get_running_tasks(cls) -> Sequence[TaskInfo]: root_task = current_root_task() assert root_task task_infos = [TrioTaskInfo(root_task)] nurseries = root_task.child_nurseries while nurseries: new_nurseries: list[trio.Nursery] = [] for nursery in nurseries: for task in nursery.child_tasks: task_infos.append(TrioTaskInfo(task)) new_nurseries.extend(task.child_nurseries)
nurseries = new_nurseries
return task_infos
@classmethod async def wait_all_tasks_blocked(cls) -> None: from trio.testing import wait_all_tasks_blocked
await wait_all_tasks_blocked()
@classmethod def create_test_runner(cls, options: dict[str, Any]) -> TestRunner: return TestRunner(**options)
backend_class = TrioBackend.gitignoreAdded+9
.venv/.gitignoreDeleted-1
.venv/.lockDeleted
.venv/CACHEDIR.TAGDeleted-1
.venv/bin/activateDeleted-130
.venv/bin/activate.batDeleted-71
.venv/bin/activate.cshDeleted-76
.venv/bin/activate.fishDeleted-124
.venv/bin/activate.nuDeleted-102
.venv/bin/activate.ps1Deleted-82
.venv/bin/activate_this.pyDeleted-59
.venv/bin/deactivate.batDeleted-39
.venv/bin/hfDeleted-10
.venv/bin/httpxDeleted-10
.venv/bin/huggingface-cliDeleted-10
.venv/bin/idnaDeleted-10
.venv/bin/pydoc.batDeleted-22
.venv/bin/pythonDeleted
.venv/bin/python3Deleted
.venv/bin/python3.14Deleted
.venv/bin/tiny-agentsDeleted-10
.venv/bin/tqdmDeleted-10
.venv/lib/python3.14/site-packages/__pycache__/_virtualenv.cpython-314.pycDeleted
.venv/lib/python3.14/site-packages/__pycache__/typing_extensions.cpython-314.pycDeleted-3
.venv/lib/python3.14/site-packages/_virtualenv.pthDeleted-3
.venv/lib/python3.14/site-packages/_virtualenv.pyDeleted-101
.venv/lib/python3.14/site-packages/_yaml/__init__.pyDeleted-33
.venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/INSTALLERDeleted-1
.venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/METADATADeleted-107
.venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/RECORDDeleted-54
.venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/REQUESTEDDeleted
.venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/WHEELDeleted-5
.venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/entry_points.txtDeleted-2
.venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/licenses/LICENSEDeleted-20
.venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/scm_file_list.jsonDeleted-119
.venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/scm_version.jsonDeleted-8
.venv/lib/python3.14/site-packages/anyio-4.14.1.dist-info/top_level.txtDeleted-1
.venv/lib/python3.14/site-packages/anyio/__init__.pyDeleted-115
.venv/lib/python3.14/site-packages/anyio/__pycache__/__init__.cpython-314.pycDeleted
.venv/lib/python3.14/site-packages/anyio/__pycache__/from_thread.cpython-314.pycDeleted
.venv/lib/python3.14/site-packages/anyio/__pycache__/lowlevel.cpython-314.pycDeleted
.venv/lib/python3.14/site-packages/anyio/__pycache__/to_thread.cpython-314.pycDeleted
.venv/lib/python3.14/site-packages/anyio/_backends/__init__.pyDeleted
.venv/lib/python3.14/site-packages/anyio/_backends/_asyncio.pyDeleted
.venv/lib/python3.14/site-packages/anyio/_backends/_trio.pyDeleted-1456
.venv/lib/python3.14/site-packages/anyio/_core/__init__.pyDeleted
.venv/lib/python3.14/site-packages/anyio/_core/__pycache__/__init__.cpython-314.pycDeleted
.venv/lib/python3.14/site-packages/anyio/_core/__pycache__/_contextmanagers.cpython-314.pycDeleted
.venv/lib/python3.14/site-packages/anyio/_core/__pycache__/_eventloop.cpython-314.pycDeleted
.venv/lib/python3.14/site-packages/anyio/_core/__pycache__/_exceptions.cpython-314.pycDeleted