Malcolm Mielle commited on
Commit
a61d7f2
·
unverified ·
1 Parent(s): ae42cae

remove env

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .venv/.gitignore +0 -1
  2. .venv/.lock +0 -0
  3. .venv/CACHEDIR.TAG +0 -1
  4. .venv/bin/activate +0 -130
  5. .venv/bin/activate.bat +0 -71
  6. .venv/bin/activate.csh +0 -76
  7. .venv/bin/activate.fish +0 -124
  8. .venv/bin/activate.nu +0 -102
  9. .venv/bin/activate.ps1 +0 -82
  10. .venv/bin/activate_this.py +0 -59
  11. .venv/bin/deactivate.bat +0 -39
  12. .venv/bin/hf +0 -10
  13. .venv/bin/httpx +0 -10
  14. .venv/bin/huggingface-cli +0 -10
  15. .venv/bin/markdown-it +0 -10
  16. .venv/bin/pydoc.bat +0 -22
  17. .venv/bin/pygmentize +0 -10
  18. .venv/bin/python +0 -3
  19. .venv/bin/python3 +0 -3
  20. .venv/bin/python3.12 +0 -3
  21. .venv/bin/tiny-agents +0 -10
  22. .venv/bin/tqdm +0 -10
  23. .venv/bin/typer +0 -10
  24. .venv/lib/python3.12/site-packages/_virtualenv.pth +0 -3
  25. .venv/lib/python3.12/site-packages/_virtualenv.py +0 -101
  26. .venv/lib/python3.12/site-packages/_yaml/__init__.py +0 -33
  27. .venv/lib/python3.12/site-packages/annotated_doc-0.0.4.dist-info/INSTALLER +0 -1
  28. .venv/lib/python3.12/site-packages/annotated_doc-0.0.4.dist-info/METADATA +0 -145
  29. .venv/lib/python3.12/site-packages/annotated_doc-0.0.4.dist-info/RECORD +0 -10
  30. .venv/lib/python3.12/site-packages/annotated_doc-0.0.4.dist-info/REQUESTED +0 -0
  31. .venv/lib/python3.12/site-packages/annotated_doc-0.0.4.dist-info/WHEEL +0 -4
  32. .venv/lib/python3.12/site-packages/annotated_doc-0.0.4.dist-info/entry_points.txt +0 -4
  33. .venv/lib/python3.12/site-packages/annotated_doc-0.0.4.dist-info/licenses/LICENSE +0 -21
  34. .venv/lib/python3.12/site-packages/annotated_doc/__init__.py +0 -3
  35. .venv/lib/python3.12/site-packages/annotated_doc/main.py +0 -36
  36. .venv/lib/python3.12/site-packages/annotated_doc/py.typed +0 -0
  37. .venv/lib/python3.12/site-packages/anyio-4.13.0.dist-info/INSTALLER +0 -1
  38. .venv/lib/python3.12/site-packages/anyio-4.13.0.dist-info/METADATA +0 -105
  39. .venv/lib/python3.12/site-packages/anyio-4.13.0.dist-info/RECORD +0 -51
  40. .venv/lib/python3.12/site-packages/anyio-4.13.0.dist-info/REQUESTED +0 -0
  41. .venv/lib/python3.12/site-packages/anyio-4.13.0.dist-info/WHEEL +0 -5
  42. .venv/lib/python3.12/site-packages/anyio-4.13.0.dist-info/entry_points.txt +0 -2
  43. .venv/lib/python3.12/site-packages/anyio-4.13.0.dist-info/licenses/LICENSE +0 -20
  44. .venv/lib/python3.12/site-packages/anyio-4.13.0.dist-info/top_level.txt +0 -1
  45. .venv/lib/python3.12/site-packages/anyio/__init__.py +0 -111
  46. .venv/lib/python3.12/site-packages/anyio/_backends/__init__.py +0 -0
  47. .venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py +0 -0
  48. .venv/lib/python3.12/site-packages/anyio/_backends/_trio.py +0 -1343
  49. .venv/lib/python3.12/site-packages/anyio/_core/__init__.py +0 -0
  50. .venv/lib/python3.12/site-packages/anyio/_core/_asyncio_selector_thread.py +0 -167
.venv/.gitignore DELETED
@@ -1 +0,0 @@
1
- *
 
 
.venv/.lock DELETED
File without changes
.venv/CACHEDIR.TAG DELETED
@@ -1 +0,0 @@
1
- Signature: 8a477f597d28d172789f06886806bc55
 
 
.venv/bin/activate DELETED
@@ -1,130 +0,0 @@
1
- # Copyright (c) 2020-202x The virtualenv developers
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining
4
- # a copy of this software and associated documentation files (the
5
- # "Software"), to deal in the Software without restriction, including
6
- # without limitation the rights to use, copy, modify, merge, publish,
7
- # distribute, sublicense, and/or sell copies of the Software, and to
8
- # permit persons to whom the Software is furnished to do so, subject to
9
- # the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be
12
- # included in all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- # This file must be used with "source bin/activate" *from bash*
23
- # you cannot run it directly
24
-
25
- if ! [ -z "${SCRIPT_PATH+_}" ] ; then
26
- _OLD_SCRIPT_PATH="$SCRIPT_PATH"
27
- fi
28
-
29
- # Get script path (only used if environment is relocatable).
30
- if [ -n "${BASH_VERSION:+x}" ] ; then
31
- SCRIPT_PATH="${BASH_SOURCE[0]}"
32
- if [ "$SCRIPT_PATH" = "$0" ]; then
33
- # Only bash has a reasonably robust check for source'dness.
34
- echo "You must source this script: \$ source $0" >&2
35
- exit 33
36
- fi
37
- elif [ -n "${ZSH_VERSION:+x}" ] ; then
38
- SCRIPT_PATH="${(%):-%x}"
39
- elif [ -n "${KSH_VERSION:+x}" ] ; then
40
- SCRIPT_PATH="${.sh.file}"
41
- fi
42
-
43
- deactivate () {
44
- unset -f pydoc >/dev/null 2>&1 || true
45
-
46
- # reset old environment variables
47
- # ! [ -z ${VAR+_} ] returns true if VAR is declared at all
48
- if ! [ -z "${_OLD_VIRTUAL_PATH:+_}" ] ; then
49
- PATH="$_OLD_VIRTUAL_PATH"
50
- export PATH
51
- unset _OLD_VIRTUAL_PATH
52
- fi
53
- if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then
54
- PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
55
- export PYTHONHOME
56
- unset _OLD_VIRTUAL_PYTHONHOME
57
- fi
58
-
59
- # The hash command must be called to get it to forget past
60
- # commands. Without forgetting past commands the $PATH changes
61
- # we made may not be respected
62
- hash -r 2>/dev/null
63
-
64
- if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then
65
- PS1="$_OLD_VIRTUAL_PS1"
66
- export PS1
67
- unset _OLD_VIRTUAL_PS1
68
- fi
69
-
70
- unset VIRTUAL_ENV
71
- unset VIRTUAL_ENV_PROMPT
72
- if [ ! "${1-}" = "nondestructive" ] ; then
73
- # Self destruct!
74
- unset -f deactivate
75
- fi
76
- }
77
-
78
- # unset irrelevant variables
79
- deactivate nondestructive
80
-
81
- VIRTUAL_ENV='/home/malcolm/Downloads/SEAR/.venv'
82
- if ([ "$OSTYPE" = "cygwin" ] || [ "$OSTYPE" = "msys" ]) && $(command -v cygpath &> /dev/null) ; then
83
- VIRTUAL_ENV=$(cygpath -u "$VIRTUAL_ENV")
84
- fi
85
- export VIRTUAL_ENV
86
-
87
- # Unset the `SCRIPT_PATH` variable, now that the `VIRTUAL_ENV` variable
88
- # has been set. This is important for relocatable environments.
89
- if ! [ -z "${_OLD_SCRIPT_PATH+_}" ] ; then
90
- SCRIPT_PATH="$_OLD_SCRIPT_PATH"
91
- export SCRIPT_PATH
92
- unset _OLD_SCRIPT_PATH
93
- else
94
- unset SCRIPT_PATH
95
- fi
96
-
97
- _OLD_VIRTUAL_PATH="$PATH"
98
- PATH="$VIRTUAL_ENV/bin:$PATH"
99
- export PATH
100
-
101
- if [ "xsear" != x ] ; then
102
- VIRTUAL_ENV_PROMPT="sear"
103
- else
104
- VIRTUAL_ENV_PROMPT=$(basename "$VIRTUAL_ENV")
105
- fi
106
- export VIRTUAL_ENV_PROMPT
107
-
108
- # unset PYTHONHOME if set
109
- if ! [ -z "${PYTHONHOME+_}" ] ; then
110
- _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
111
- unset PYTHONHOME
112
- fi
113
-
114
- if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
115
- _OLD_VIRTUAL_PS1="${PS1-}"
116
- PS1="(${VIRTUAL_ENV_PROMPT}) ${PS1-}"
117
- export PS1
118
- fi
119
-
120
- # Make sure to unalias pydoc if it's already there
121
- alias pydoc 2>/dev/null >/dev/null && unalias pydoc || true
122
-
123
- pydoc () {
124
- python -m pydoc "$@"
125
- }
126
-
127
- # The hash command must be called to get it to forget past
128
- # commands. Without forgetting past commands the $PATH changes
129
- # we made may not be respected
130
- hash -r 2>/dev/null || true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/bin/activate.bat DELETED
@@ -1,71 +0,0 @@
1
- @REM Copyright (c) 2020-202x The virtualenv developers
2
- @REM
3
- @REM Permission is hereby granted, free of charge, to any person obtaining
4
- @REM a copy of this software and associated documentation files (the
5
- @REM "Software"), to deal in the Software without restriction, including
6
- @REM without limitation the rights to use, copy, modify, merge, publish,
7
- @REM distribute, sublicense, and/or sell copies of the Software, and to
8
- @REM permit persons to whom the Software is furnished to do so, subject to
9
- @REM the following conditions:
10
- @REM
11
- @REM The above copyright notice and this permission notice shall be
12
- @REM included in all copies or substantial portions of the Software.
13
- @REM
14
- @REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- @REM EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- @REM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- @REM NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- @REM LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- @REM OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- @REM WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- @REM This file is UTF-8 encoded, so we need to update the current code page while executing it
23
- @for /f "tokens=2 delims=:." %%a in ('"%SystemRoot%\System32\chcp.com"') do @set _OLD_CODEPAGE=%%a
24
-
25
- @if defined _OLD_CODEPAGE (
26
- "%SystemRoot%\System32\chcp.com" 65001 > nul
27
- )
28
-
29
- @for %%i in ("/home/malcolm/Downloads/SEAR/.venv") do @set "VIRTUAL_ENV=%%~fi"
30
-
31
- @set "VIRTUAL_ENV_PROMPT=sear"
32
- @if NOT DEFINED VIRTUAL_ENV_PROMPT (
33
- @for %%d in ("%VIRTUAL_ENV%") do @set "VIRTUAL_ENV_PROMPT=%%~nxd"
34
- )
35
-
36
- @if defined _OLD_VIRTUAL_PROMPT (
37
- @set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
38
- ) else (
39
- @if not defined PROMPT (
40
- @set "PROMPT=$P$G"
41
- )
42
- @if not defined VIRTUAL_ENV_DISABLE_PROMPT (
43
- @set "_OLD_VIRTUAL_PROMPT=%PROMPT%"
44
- )
45
- )
46
- @if not defined VIRTUAL_ENV_DISABLE_PROMPT (
47
- @set "PROMPT=(%VIRTUAL_ENV_PROMPT%) %PROMPT%"
48
- )
49
-
50
- @REM Don't use () to avoid problems with them in %PATH%
51
- @if defined _OLD_VIRTUAL_PYTHONHOME @goto ENDIFVHOME
52
- @set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%"
53
- :ENDIFVHOME
54
-
55
- @set PYTHONHOME=
56
-
57
- @REM if defined _OLD_VIRTUAL_PATH (
58
- @if not defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH1
59
- @set "PATH=%_OLD_VIRTUAL_PATH%"
60
- :ENDIFVPATH1
61
- @REM ) else (
62
- @if defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH2
63
- @set "_OLD_VIRTUAL_PATH=%PATH%"
64
- :ENDIFVPATH2
65
-
66
- @set "PATH=%VIRTUAL_ENV%\bin;%PATH%"
67
-
68
- @if defined _OLD_CODEPAGE (
69
- "%SystemRoot%\System32\chcp.com" %_OLD_CODEPAGE% > nul
70
- @set _OLD_CODEPAGE=
71
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/bin/activate.csh DELETED
@@ -1,76 +0,0 @@
1
- # Copyright (c) 2020-202x The virtualenv developers
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining
4
- # a copy of this software and associated documentation files (the
5
- # "Software"), to deal in the Software without restriction, including
6
- # without limitation the rights to use, copy, modify, merge, publish,
7
- # distribute, sublicense, and/or sell copies of the Software, and to
8
- # permit persons to whom the Software is furnished to do so, subject to
9
- # the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be
12
- # included in all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- # This file must be used with "source bin/activate.csh" *from csh*.
23
- # You cannot run it directly.
24
- # Created by Davide Di Blasi <davidedb@gmail.com>.
25
-
26
- set newline='\
27
- '
28
-
29
- 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'
30
-
31
- # Unset irrelevant variables.
32
- deactivate nondestructive
33
-
34
- setenv VIRTUAL_ENV '/home/malcolm/Downloads/SEAR/.venv'
35
-
36
- set _OLD_VIRTUAL_PATH="$PATH:q"
37
- setenv PATH "$VIRTUAL_ENV:q/bin:$PATH:q"
38
-
39
-
40
-
41
- if ('sear' != "") then
42
- setenv VIRTUAL_ENV_PROMPT 'sear'
43
- else
44
- setenv VIRTUAL_ENV_PROMPT "$VIRTUAL_ENV:t:q"
45
- endif
46
-
47
- if ( $?VIRTUAL_ENV_DISABLE_PROMPT ) then
48
- if ( $VIRTUAL_ENV_DISABLE_PROMPT == "" ) then
49
- set do_prompt = "1"
50
- else
51
- set do_prompt = "0"
52
- endif
53
- else
54
- set do_prompt = "1"
55
- endif
56
-
57
- if ( $do_prompt == "1" ) then
58
- # Could be in a non-interactive environment,
59
- # in which case, $prompt is undefined and we wouldn't
60
- # care about the prompt anyway.
61
- if ( $?prompt ) then
62
- set _OLD_VIRTUAL_PROMPT="$prompt:q"
63
- if ( "$prompt:q" =~ *"$newline:q"* ) then
64
- :
65
- else
66
- set prompt = '('"$VIRTUAL_ENV_PROMPT:q"') '"$prompt:q"
67
- endif
68
- endif
69
- endif
70
-
71
- unset env_name
72
- unset do_prompt
73
-
74
- alias pydoc python -m pydoc
75
-
76
- rehash
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/bin/activate.fish DELETED
@@ -1,124 +0,0 @@
1
- # Copyright (c) 2020-202x The virtualenv developers
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining
4
- # a copy of this software and associated documentation files (the
5
- # "Software"), to deal in the Software without restriction, including
6
- # without limitation the rights to use, copy, modify, merge, publish,
7
- # distribute, sublicense, and/or sell copies of the Software, and to
8
- # permit persons to whom the Software is furnished to do so, subject to
9
- # the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be
12
- # included in all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- # This file must be used using `source bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
23
- # Do not run it directly.
24
-
25
- function _bashify_path -d "Converts a fish path to something bash can recognize"
26
- set fishy_path $argv
27
- set bashy_path $fishy_path[1]
28
- for path_part in $fishy_path[2..-1]
29
- set bashy_path "$bashy_path:$path_part"
30
- end
31
- echo $bashy_path
32
- end
33
-
34
- function _fishify_path -d "Converts a bash path to something fish can recognize"
35
- echo $argv | tr ':' '\n'
36
- end
37
-
38
- function deactivate -d 'Exit virtualenv mode and return to the normal environment.'
39
- # reset old environment variables
40
- if test -n "$_OLD_VIRTUAL_PATH"
41
- # https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling
42
- if test (string sub -s 1 -l 1 $FISH_VERSION) -lt 3
43
- set -gx PATH (_fishify_path "$_OLD_VIRTUAL_PATH")
44
- else
45
- set -gx PATH $_OLD_VIRTUAL_PATH
46
- end
47
- set -e _OLD_VIRTUAL_PATH
48
- end
49
-
50
- if test -n "$_OLD_VIRTUAL_PYTHONHOME"
51
- set -gx PYTHONHOME "$_OLD_VIRTUAL_PYTHONHOME"
52
- set -e _OLD_VIRTUAL_PYTHONHOME
53
- end
54
-
55
- if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
56
- and functions -q _old_fish_prompt
57
- # Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`.
58
- set -l fish_function_path
59
-
60
- # Erase virtualenv's `fish_prompt` and restore the original.
61
- functions -e fish_prompt
62
- functions -c _old_fish_prompt fish_prompt
63
- functions -e _old_fish_prompt
64
- set -e _OLD_FISH_PROMPT_OVERRIDE
65
- end
66
-
67
- set -e VIRTUAL_ENV
68
- set -e VIRTUAL_ENV_PROMPT
69
-
70
- if test "$argv[1]" != 'nondestructive'
71
- # Self-destruct!
72
- functions -e pydoc
73
- functions -e deactivate
74
- functions -e _bashify_path
75
- functions -e _fishify_path
76
- end
77
- end
78
-
79
- # Unset irrelevant variables.
80
- deactivate nondestructive
81
-
82
- set -gx VIRTUAL_ENV '/home/malcolm/Downloads/SEAR/.venv'
83
-
84
- # https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling
85
- if test (string sub -s 1 -l 1 $FISH_VERSION) -lt 3
86
- set -gx _OLD_VIRTUAL_PATH (_bashify_path $PATH)
87
- else
88
- set -gx _OLD_VIRTUAL_PATH $PATH
89
- end
90
- set -gx PATH "$VIRTUAL_ENV"'/bin' $PATH
91
-
92
- # Prompt override provided?
93
- # If not, just use the environment name.
94
- if test -n 'sear'
95
- set -gx VIRTUAL_ENV_PROMPT 'sear'
96
- else
97
- set -gx VIRTUAL_ENV_PROMPT (basename "$VIRTUAL_ENV")
98
- end
99
-
100
- # Unset `$PYTHONHOME` if set.
101
- if set -q PYTHONHOME
102
- set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
103
- set -e PYTHONHOME
104
- end
105
-
106
- function pydoc
107
- python -m pydoc $argv
108
- end
109
-
110
- if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
111
- # Copy the current `fish_prompt` function as `_old_fish_prompt`.
112
- functions -c fish_prompt _old_fish_prompt
113
-
114
- function fish_prompt
115
- # Run the user's prompt first; it might depend on (pipe)status.
116
- set -l prompt (_old_fish_prompt)
117
-
118
- printf '(%s) ' $VIRTUAL_ENV_PROMPT
119
-
120
- string join -- \n $prompt # handle multi-line prompts
121
- end
122
-
123
- set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
124
- end
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/bin/activate.nu DELETED
@@ -1,102 +0,0 @@
1
- # Copyright (c) 2020-202x The virtualenv developers
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining
4
- # a copy of this software and associated documentation files (the
5
- # "Software"), to deal in the Software without restriction, including
6
- # without limitation the rights to use, copy, modify, merge, publish,
7
- # distribute, sublicense, and/or sell copies of the Software, and to
8
- # permit persons to whom the Software is furnished to do so, subject to
9
- # the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be
12
- # included in all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- # virtualenv activation module:
23
- # - Activate with `overlay use activate.nu`
24
- # - Deactivate with `deactivate`, as usual
25
- #
26
- # To customize the overlay name, you can call `overlay use activate.nu as foo`, but then simply `deactivate` won't work
27
- # because it is just an alias to hide the "activate" overlay. You'd need to call `overlay hide foo` manually.
28
-
29
- module warning {
30
- export-env {
31
- const file = path self
32
- error make -u {
33
- msg: $"`($file | path basename)` is meant to be used with `overlay use`, not `source`"
34
- }
35
- }
36
-
37
- }
38
-
39
- use warning
40
-
41
- export-env {
42
-
43
- let nu_ver = (version | get version | split row '.' | take 2 | each { into int })
44
- if $nu_ver.0 == 0 and $nu_ver.1 < 106 {
45
- error make {
46
- msg: 'virtualenv Nushell activation requires Nushell 0.106 or greater.'
47
- }
48
- }
49
-
50
- def is-string [x] {
51
- ($x | describe) == 'string'
52
- }
53
-
54
- def has-env [...names] {
55
- $names | each {|n| $n in $env } | all {|i| $i }
56
- }
57
-
58
- def is-env-true [name: string] {
59
- if (has-env $name) {
60
- let val = ($env | get --optional $name)
61
- if ($val | describe) == 'bool' {
62
- $val
63
- } else {
64
- not ($val | is-empty)
65
- }
66
- } else {
67
- false
68
- }
69
- }
70
-
71
- let virtual_env = '/home/malcolm/Downloads/SEAR/.venv'
72
- let bin = 'bin'
73
- let path_name = if (has-env 'Path') { 'Path' } else { 'PATH' }
74
- let venv_path = ([$virtual_env $bin] | path join)
75
- let new_path = ($env | get $path_name | prepend $venv_path)
76
- let virtual_env_prompt = if ('sear' | is-empty) {
77
- ($virtual_env | path basename)
78
- } else {
79
- 'sear'
80
- }
81
- let new_env = { $path_name: $new_path VIRTUAL_ENV: $virtual_env VIRTUAL_ENV_PROMPT: $virtual_env_prompt }
82
- let old_prompt_command = if (has-env 'PROMPT_COMMAND') { $env.PROMPT_COMMAND } else { '' }
83
- let new_env = if (is-env-true 'VIRTUAL_ENV_DISABLE_PROMPT') {
84
- $new_env
85
- } else {
86
- let virtual_prefix = $'(char lparen)($virtual_env_prompt)(char rparen) '
87
- let new_prompt = if (has-env 'PROMPT_COMMAND') {
88
- if ('closure' in ($old_prompt_command | describe)) {
89
- {|| $'($virtual_prefix)(do $old_prompt_command)' }
90
- } else {
91
- {|| $'($virtual_prefix)($old_prompt_command)' }
92
- }
93
- } else {
94
- {|| $'($virtual_prefix)' }
95
- }
96
- $new_env | merge { PROMPT_COMMAND: $new_prompt VIRTUAL_PREFIX: $virtual_prefix }
97
- }
98
- load-env $new_env
99
- }
100
-
101
- export alias pydoc = python -m pydoc
102
- export alias deactivate = overlay hide activate
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/bin/activate.ps1 DELETED
@@ -1,82 +0,0 @@
1
- # Copyright (c) 2020-202x The virtualenv developers
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining
4
- # a copy of this software and associated documentation files (the
5
- # "Software"), to deal in the Software without restriction, including
6
- # without limitation the rights to use, copy, modify, merge, publish,
7
- # distribute, sublicense, and/or sell copies of the Software, and to
8
- # permit persons to whom the Software is furnished to do so, subject to
9
- # the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be
12
- # included in all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- $script:THIS_PATH = $myinvocation.mycommand.path
23
- $script:BASE_DIR = Split-Path (Resolve-Path "$THIS_PATH/..") -Parent
24
-
25
- function global:deactivate([switch] $NonDestructive) {
26
- if (Test-Path variable:_OLD_VIRTUAL_PATH) {
27
- $env:PATH = $variable:_OLD_VIRTUAL_PATH
28
- Remove-Variable "_OLD_VIRTUAL_PATH" -Scope global
29
- }
30
-
31
- if (Test-Path function:_old_virtual_prompt) {
32
- $function:prompt = $function:_old_virtual_prompt
33
- Remove-Item function:\_old_virtual_prompt
34
- }
35
-
36
- if ($env:VIRTUAL_ENV) {
37
- Remove-Item env:VIRTUAL_ENV -ErrorAction SilentlyContinue
38
- }
39
-
40
- if ($env:VIRTUAL_ENV_PROMPT) {
41
- Remove-Item env:VIRTUAL_ENV_PROMPT -ErrorAction SilentlyContinue
42
- }
43
-
44
- if (!$NonDestructive) {
45
- # Self destruct!
46
- Remove-Item function:deactivate
47
- Remove-Item function:pydoc
48
- }
49
- }
50
-
51
- function global:pydoc {
52
- python -m pydoc $args
53
- }
54
-
55
- # unset irrelevant variables
56
- deactivate -nondestructive
57
-
58
- $VIRTUAL_ENV = $BASE_DIR
59
- $env:VIRTUAL_ENV = $VIRTUAL_ENV
60
-
61
- if ("sear" -ne "") {
62
- $env:VIRTUAL_ENV_PROMPT = "sear"
63
- }
64
- else {
65
- $env:VIRTUAL_ENV_PROMPT = $( Split-Path $env:VIRTUAL_ENV -Leaf )
66
- }
67
-
68
- New-Variable -Scope global -Name _OLD_VIRTUAL_PATH -Value $env:PATH
69
-
70
- $env:PATH = "$env:VIRTUAL_ENV/bin:" + $env:PATH
71
- if (!$env:VIRTUAL_ENV_DISABLE_PROMPT) {
72
- function global:_old_virtual_prompt {
73
- ""
74
- }
75
- $function:_old_virtual_prompt = $function:prompt
76
-
77
- function global:prompt {
78
- # Add the custom prefix to the existing prompt
79
- $previous_prompt_value = & $function:_old_virtual_prompt
80
- ("(" + $env:VIRTUAL_ENV_PROMPT + ") " + $previous_prompt_value)
81
- }
82
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/bin/activate_this.py DELETED
@@ -1,59 +0,0 @@
1
- # Copyright (c) 2020-202x The virtualenv developers
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining
4
- # a copy of this software and associated documentation files (the
5
- # "Software"), to deal in the Software without restriction, including
6
- # without limitation the rights to use, copy, modify, merge, publish,
7
- # distribute, sublicense, and/or sell copies of the Software, and to
8
- # permit persons to whom the Software is furnished to do so, subject to
9
- # the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be
12
- # included in all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- """
23
- Activate virtualenv for current interpreter:
24
-
25
- import runpy
26
- runpy.run_path(this_file)
27
-
28
- This can be used when you must use an existing Python interpreter, not the virtualenv bin/python.
29
- """ # noqa: D415
30
-
31
- from __future__ import annotations
32
-
33
- import os
34
- import site
35
- import sys
36
-
37
- try:
38
- abs_file = os.path.abspath(__file__)
39
- except NameError as exc:
40
- msg = "You must use import runpy; runpy.run_path(this_file)"
41
- raise AssertionError(msg) from exc
42
-
43
- bin_dir = os.path.dirname(abs_file)
44
- base = bin_dir[: -len("bin") - 1] # strip away the bin part from the __file__, plus the path separator
45
-
46
- # prepend bin to PATH (this file is inside the bin directory)
47
- os.environ["PATH"] = os.pathsep.join([bin_dir, *os.environ.get("PATH", "").split(os.pathsep)])
48
- os.environ["VIRTUAL_ENV"] = base # virtual env is right above bin directory
49
- os.environ["VIRTUAL_ENV_PROMPT"] = "sear" or os.path.basename(base) # noqa: SIM222
50
-
51
- # add the virtual environments libraries to the host python import mechanism
52
- prev_length = len(sys.path)
53
- for lib in "../lib/python3.12/site-packages".split(os.pathsep):
54
- path = os.path.realpath(os.path.join(bin_dir, lib))
55
- site.addsitedir(path)
56
- sys.path[:] = sys.path[prev_length:] + sys.path[0:prev_length]
57
-
58
- sys.real_prefix = sys.prefix
59
- sys.prefix = base
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/bin/deactivate.bat DELETED
@@ -1,39 +0,0 @@
1
- @REM Copyright (c) 2020-202x The virtualenv developers
2
- @REM
3
- @REM Permission is hereby granted, free of charge, to any person obtaining
4
- @REM a copy of this software and associated documentation files (the
5
- @REM "Software"), to deal in the Software without restriction, including
6
- @REM without limitation the rights to use, copy, modify, merge, publish,
7
- @REM distribute, sublicense, and/or sell copies of the Software, and to
8
- @REM permit persons to whom the Software is furnished to do so, subject to
9
- @REM the following conditions:
10
- @REM
11
- @REM The above copyright notice and this permission notice shall be
12
- @REM included in all copies or substantial portions of the Software.
13
- @REM
14
- @REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- @REM EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- @REM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- @REM NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- @REM LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- @REM OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- @REM WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- @set VIRTUAL_ENV=
23
- @set VIRTUAL_ENV_PROMPT=
24
-
25
- @REM Don't use () to avoid problems with them in %PATH%
26
- @if not defined _OLD_VIRTUAL_PROMPT @goto ENDIFVPROMPT
27
- @set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
28
- @set _OLD_VIRTUAL_PROMPT=
29
- :ENDIFVPROMPT
30
-
31
- @if not defined _OLD_VIRTUAL_PYTHONHOME @goto ENDIFVHOME
32
- @set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%"
33
- @set _OLD_VIRTUAL_PYTHONHOME=
34
- :ENDIFVHOME
35
-
36
- @if not defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH
37
- @set "PATH=%_OLD_VIRTUAL_PATH%"
38
- @set _OLD_VIRTUAL_PATH=
39
- :ENDIFVPATH
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/bin/hf DELETED
@@ -1,10 +0,0 @@
1
- #!/home/malcolm/Downloads/SEAR/.venv/bin/python
2
- # -*- coding: utf-8 -*-
3
- import sys
4
- from huggingface_hub.cli.hf import main
5
- if __name__ == "__main__":
6
- if sys.argv[0].endswith("-script.pyw"):
7
- sys.argv[0] = sys.argv[0][:-11]
8
- elif sys.argv[0].endswith(".exe"):
9
- sys.argv[0] = sys.argv[0][:-4]
10
- sys.exit(main())
 
 
 
 
 
 
 
 
 
 
 
.venv/bin/httpx DELETED
@@ -1,10 +0,0 @@
1
- #!/home/malcolm/Downloads/SEAR/.venv/bin/python
2
- # -*- coding: utf-8 -*-
3
- import sys
4
- from httpx import main
5
- if __name__ == "__main__":
6
- if sys.argv[0].endswith("-script.pyw"):
7
- sys.argv[0] = sys.argv[0][:-11]
8
- elif sys.argv[0].endswith(".exe"):
9
- sys.argv[0] = sys.argv[0][:-4]
10
- sys.exit(main())
 
 
 
 
 
 
 
 
 
 
 
.venv/bin/huggingface-cli DELETED
@@ -1,10 +0,0 @@
1
- #!/home/malcolm/Downloads/SEAR/.venv/bin/python
2
- # -*- coding: utf-8 -*-
3
- import sys
4
- from huggingface_hub.cli.deprecated_cli import main
5
- if __name__ == "__main__":
6
- if sys.argv[0].endswith("-script.pyw"):
7
- sys.argv[0] = sys.argv[0][:-11]
8
- elif sys.argv[0].endswith(".exe"):
9
- sys.argv[0] = sys.argv[0][:-4]
10
- sys.exit(main())
 
 
 
 
 
 
 
 
 
 
 
.venv/bin/markdown-it DELETED
@@ -1,10 +0,0 @@
1
- #!/home/malcolm/Downloads/SEAR/.venv/bin/python
2
- # -*- coding: utf-8 -*-
3
- import sys
4
- from markdown_it.cli.parse import main
5
- if __name__ == "__main__":
6
- if sys.argv[0].endswith("-script.pyw"):
7
- sys.argv[0] = sys.argv[0][:-11]
8
- elif sys.argv[0].endswith(".exe"):
9
- sys.argv[0] = sys.argv[0][:-4]
10
- sys.exit(main())
 
 
 
 
 
 
 
 
 
 
 
.venv/bin/pydoc.bat DELETED
@@ -1,22 +0,0 @@
1
- @REM Copyright (c) 2020-202x The virtualenv developers
2
- @REM
3
- @REM Permission is hereby granted, free of charge, to any person obtaining
4
- @REM a copy of this software and associated documentation files (the
5
- @REM "Software"), to deal in the Software without restriction, including
6
- @REM without limitation the rights to use, copy, modify, merge, publish,
7
- @REM distribute, sublicense, and/or sell copies of the Software, and to
8
- @REM permit persons to whom the Software is furnished to do so, subject to
9
- @REM the following conditions:
10
- @REM
11
- @REM The above copyright notice and this permission notice shall be
12
- @REM included in all copies or substantial portions of the Software.
13
- @REM
14
- @REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- @REM EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- @REM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- @REM NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- @REM LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- @REM OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- @REM WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- python.exe -m pydoc %*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/bin/pygmentize DELETED
@@ -1,10 +0,0 @@
1
- #!/home/malcolm/Downloads/SEAR/.venv/bin/python
2
- # -*- coding: utf-8 -*-
3
- import sys
4
- from pygments.cmdline import main
5
- if __name__ == "__main__":
6
- if sys.argv[0].endswith("-script.pyw"):
7
- sys.argv[0] = sys.argv[0][:-11]
8
- elif sys.argv[0].endswith(".exe"):
9
- sys.argv[0] = sys.argv[0][:-4]
10
- sys.exit(main())
 
 
 
 
 
 
 
 
 
 
 
.venv/bin/python DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:25cd2c9da062539ad3a31687966e07b5081e10a00d0306cb86990f4f4a475c95
3
- size 33359184
 
 
 
 
.venv/bin/python3 DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:25cd2c9da062539ad3a31687966e07b5081e10a00d0306cb86990f4f4a475c95
3
- size 33359184
 
 
 
 
.venv/bin/python3.12 DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:25cd2c9da062539ad3a31687966e07b5081e10a00d0306cb86990f4f4a475c95
3
- size 33359184
 
 
 
 
.venv/bin/tiny-agents DELETED
@@ -1,10 +0,0 @@
1
- #!/home/malcolm/Downloads/SEAR/.venv/bin/python
2
- # -*- coding: utf-8 -*-
3
- import sys
4
- from huggingface_hub.inference._mcp.cli import app
5
- if __name__ == "__main__":
6
- if sys.argv[0].endswith("-script.pyw"):
7
- sys.argv[0] = sys.argv[0][:-11]
8
- elif sys.argv[0].endswith(".exe"):
9
- sys.argv[0] = sys.argv[0][:-4]
10
- sys.exit(app())
 
 
 
 
 
 
 
 
 
 
 
.venv/bin/tqdm DELETED
@@ -1,10 +0,0 @@
1
- #!/home/malcolm/Downloads/SEAR/.venv/bin/python
2
- # -*- coding: utf-8 -*-
3
- import sys
4
- from tqdm.cli import main
5
- if __name__ == "__main__":
6
- if sys.argv[0].endswith("-script.pyw"):
7
- sys.argv[0] = sys.argv[0][:-11]
8
- elif sys.argv[0].endswith(".exe"):
9
- sys.argv[0] = sys.argv[0][:-4]
10
- sys.exit(main())
 
 
 
 
 
 
 
 
 
 
 
.venv/bin/typer DELETED
@@ -1,10 +0,0 @@
1
- #!/home/malcolm/Downloads/SEAR/.venv/bin/python
2
- # -*- coding: utf-8 -*-
3
- import sys
4
- from typer.cli import main
5
- if __name__ == "__main__":
6
- if sys.argv[0].endswith("-script.pyw"):
7
- sys.argv[0] = sys.argv[0][:-11]
8
- elif sys.argv[0].endswith(".exe"):
9
- sys.argv[0] = sys.argv[0][:-4]
10
- sys.exit(main())
 
 
 
 
 
 
 
 
 
 
 
.venv/lib/python3.12/site-packages/_virtualenv.pth DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:69ac3d8f27e679c81b94ab30b3b56e9cd138219b1ba94a1fa3606d5a76a1433d
3
- size 18
 
 
 
 
.venv/lib/python3.12/site-packages/_virtualenv.py DELETED
@@ -1,101 +0,0 @@
1
- """Patches that are applied at runtime to the virtual environment."""
2
-
3
- import os
4
- import sys
5
-
6
- VIRTUALENV_PATCH_FILE = os.path.join(__file__)
7
-
8
-
9
- def patch_dist(dist):
10
- """
11
- Distutils allows user to configure some arguments via a configuration file:
12
- https://docs.python.org/3.11/install/index.html#distutils-configuration-files.
13
-
14
- Some of this arguments though don't make sense in context of the virtual environment files, let's fix them up.
15
- """ # noqa: D205
16
- # we cannot allow some install config as that would get packages installed outside of the virtual environment
17
- old_parse_config_files = dist.Distribution.parse_config_files
18
-
19
- def parse_config_files(self, *args, **kwargs):
20
- result = old_parse_config_files(self, *args, **kwargs)
21
- install = self.get_option_dict("install")
22
-
23
- if "prefix" in install: # the prefix governs where to install the libraries
24
- install["prefix"] = VIRTUALENV_PATCH_FILE, os.path.abspath(sys.prefix)
25
- for base in ("purelib", "platlib", "headers", "scripts", "data"):
26
- key = f"install_{base}"
27
- if key in install: # do not allow global configs to hijack venv paths
28
- install.pop(key, None)
29
- return result
30
-
31
- dist.Distribution.parse_config_files = parse_config_files
32
-
33
-
34
- # Import hook that patches some modules to ignore configuration values that break package installation in case
35
- # of virtual environments.
36
- _DISTUTILS_PATCH = "distutils.dist", "setuptools.dist"
37
- # https://docs.python.org/3/library/importlib.html#setting-up-an-importer
38
-
39
-
40
- class _Finder:
41
- """A meta path finder that allows patching the imported distutils modules."""
42
-
43
- fullname = None
44
-
45
- # lock[0] is threading.Lock(), but initialized lazily to avoid importing threading very early at startup,
46
- # because there are gevent-based applications that need to be first to import threading by themselves.
47
- # See https://github.com/pypa/virtualenv/issues/1895 for details.
48
- lock = [] # noqa: RUF012
49
-
50
- def find_spec(self, fullname, path, target=None): # noqa: ARG002
51
- if fullname in _DISTUTILS_PATCH and self.fullname is None:
52
- # initialize lock[0] lazily
53
- if len(self.lock) == 0:
54
- import threading
55
-
56
- lock = threading.Lock()
57
- # there is possibility that two threads T1 and T2 are simultaneously running into find_spec,
58
- # observing .lock as empty, and further going into hereby initialization. However due to the GIL,
59
- # list.append() operation is atomic and this way only one of the threads will "win" to put the lock
60
- # - that every thread will use - into .lock[0].
61
- # https://docs.python.org/3/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe
62
- self.lock.append(lock)
63
-
64
- from functools import partial
65
- from importlib.util import find_spec
66
-
67
- with self.lock[0]:
68
- self.fullname = fullname
69
- try:
70
- spec = find_spec(fullname, path)
71
- if spec is not None:
72
- # https://www.python.org/dev/peps/pep-0451/#how-loading-will-work
73
- is_new_api = hasattr(spec.loader, "exec_module")
74
- func_name = "exec_module" if is_new_api else "load_module"
75
- old = getattr(spec.loader, func_name)
76
- func = self.exec_module if is_new_api else self.load_module
77
- if old is not func:
78
- try: # noqa: SIM105
79
- setattr(spec.loader, func_name, partial(func, old))
80
- except AttributeError:
81
- pass # C-Extension loaders are r/o such as zipimporter with <3.7
82
- return spec
83
- finally:
84
- self.fullname = None
85
- return None
86
-
87
- @staticmethod
88
- def exec_module(old, module):
89
- old(module)
90
- if module.__name__ in _DISTUTILS_PATCH:
91
- patch_dist(module)
92
-
93
- @staticmethod
94
- def load_module(old, name):
95
- module = old(name)
96
- if module.__name__ in _DISTUTILS_PATCH:
97
- patch_dist(module)
98
- return module
99
-
100
-
101
- sys.meta_path.insert(0, _Finder())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/lib/python3.12/site-packages/_yaml/__init__.py DELETED
@@ -1,33 +0,0 @@
1
- # This is a stub package designed to roughly emulate the _yaml
2
- # extension module, which previously existed as a standalone module
3
- # and has been moved into the `yaml` package namespace.
4
- # It does not perfectly mimic its old counterpart, but should get
5
- # close enough for anyone who's relying on it even when they shouldn't.
6
- import yaml
7
-
8
- # in some circumstances, the yaml module we imoprted may be from a different version, so we need
9
- # to tread carefully when poking at it here (it may not have the attributes we expect)
10
- if not getattr(yaml, '__with_libyaml__', False):
11
- from sys import version_info
12
-
13
- exc = ModuleNotFoundError if version_info >= (3, 6) else ImportError
14
- raise exc("No module named '_yaml'")
15
- else:
16
- from yaml._yaml import *
17
- import warnings
18
- warnings.warn(
19
- 'The _yaml extension module is now located at yaml._yaml'
20
- ' and its location is subject to change. To use the'
21
- ' LibYAML-based parser and emitter, import from `yaml`:'
22
- ' `from yaml import CLoader as Loader, CDumper as Dumper`.',
23
- DeprecationWarning
24
- )
25
- del warnings
26
- # Don't `del yaml` here because yaml is actually an existing
27
- # namespace member of _yaml.
28
-
29
- __name__ = '_yaml'
30
- # If the module is top-level (i.e. not a part of any specific package)
31
- # then the attribute should be set to ''.
32
- # https://docs.python.org/3.8/library/types.html
33
- __package__ = ''
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/lib/python3.12/site-packages/annotated_doc-0.0.4.dist-info/INSTALLER DELETED
@@ -1 +0,0 @@
1
- uv
 
 
.venv/lib/python3.12/site-packages/annotated_doc-0.0.4.dist-info/METADATA DELETED
@@ -1,145 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: annotated-doc
3
- Version: 0.0.4
4
- Summary: Document parameters, class attributes, return types, and variables inline, with Annotated.
5
- Author-Email: =?utf-8?q?Sebasti=C3=A1n_Ram=C3=ADrez?= <tiangolo@gmail.com>
6
- License-Expression: MIT
7
- License-File: LICENSE
8
- Classifier: Intended Audience :: Information Technology
9
- Classifier: Intended Audience :: System Administrators
10
- Classifier: Operating System :: OS Independent
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python
13
- Classifier: Topic :: Internet
14
- Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
15
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
- Classifier: Topic :: Software Development :: Libraries
17
- Classifier: Topic :: Software Development
18
- Classifier: Typing :: Typed
19
- Classifier: Development Status :: 4 - Beta
20
- Classifier: Intended Audience :: Developers
21
- Classifier: Programming Language :: Python :: 3 :: Only
22
- Classifier: Programming Language :: Python :: 3.8
23
- Classifier: Programming Language :: Python :: 3.9
24
- Classifier: Programming Language :: Python :: 3.10
25
- Classifier: Programming Language :: Python :: 3.11
26
- Classifier: Programming Language :: Python :: 3.12
27
- Classifier: Programming Language :: Python :: 3.13
28
- Classifier: Programming Language :: Python :: 3.14
29
- Project-URL: Homepage, https://github.com/fastapi/annotated-doc
30
- Project-URL: Documentation, https://github.com/fastapi/annotated-doc
31
- Project-URL: Repository, https://github.com/fastapi/annotated-doc
32
- Project-URL: Issues, https://github.com/fastapi/annotated-doc/issues
33
- Project-URL: Changelog, https://github.com/fastapi/annotated-doc/release-notes.md
34
- Requires-Python: >=3.8
35
- Description-Content-Type: text/markdown
36
-
37
- # Annotated Doc
38
-
39
- Document parameters, class attributes, return types, and variables inline, with `Annotated`.
40
-
41
- <a href="https://github.com/fastapi/annotated-doc/actions?query=workflow%3ATest+event%3Apush+branch%3Amain" target="_blank">
42
- <img src="https://github.com/fastapi/annotated-doc/actions/workflows/test.yml/badge.svg?event=push&branch=main" alt="Test">
43
- </a>
44
- <a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/annotated-doc" target="_blank">
45
- <img src="https://coverage-badge.samuelcolvin.workers.dev/fastapi/annotated-doc.svg" alt="Coverage">
46
- </a>
47
- <a href="https://pypi.org/project/annotated-doc" target="_blank">
48
- <img src="https://img.shields.io/pypi/v/annotated-doc?color=%2334D058&label=pypi%20package" alt="Package version">
49
- </a>
50
- <a href="https://pypi.org/project/annotated-doc" target="_blank">
51
- <img src="https://img.shields.io/pypi/pyversions/annotated-doc.svg?color=%2334D058" alt="Supported Python versions">
52
- </a>
53
-
54
- ## Installation
55
-
56
- ```bash
57
- pip install annotated-doc
58
- ```
59
-
60
- Or with `uv`:
61
-
62
- ```Python
63
- uv add annotated-doc
64
- ```
65
-
66
- ## Usage
67
-
68
- Import `Doc` and pass a single literal string with the documentation for the specific parameter, class attribute, return type, or variable.
69
-
70
- For example, to document a parameter `name` in a function `hi` you could do:
71
-
72
- ```Python
73
- from typing import Annotated
74
-
75
- from annotated_doc import Doc
76
-
77
- def hi(name: Annotated[str, Doc("Who to say hi to")]) -> None:
78
- print(f"Hi, {name}!")
79
- ```
80
-
81
- You can also use it to document class attributes:
82
-
83
- ```Python
84
- from typing import Annotated
85
-
86
- from annotated_doc import Doc
87
-
88
- class User:
89
- name: Annotated[str, Doc("The user's name")]
90
- age: Annotated[int, Doc("The user's age")]
91
- ```
92
-
93
- The same way, you could document return types and variables, or anything that could have a type annotation with `Annotated`.
94
-
95
- ## Who Uses This
96
-
97
- `annotated-doc` was made for:
98
-
99
- * [FastAPI](https://fastapi.tiangolo.com/)
100
- * [Typer](https://typer.tiangolo.com/)
101
- * [SQLModel](https://sqlmodel.tiangolo.com/)
102
- * [Asyncer](https://asyncer.tiangolo.com/)
103
-
104
- `annotated-doc` is supported by [griffe-typingdoc](https://github.com/mkdocstrings/griffe-typingdoc), which powers reference documentation like the one in the [FastAPI Reference](https://fastapi.tiangolo.com/reference/).
105
-
106
- ## Reasons not to use `annotated-doc`
107
-
108
- You are already comfortable with one of the existing docstring formats, like:
109
-
110
- * Sphinx
111
- * numpydoc
112
- * Google
113
- * Keras
114
-
115
- Your team is already comfortable using them.
116
-
117
- You prefer having the documentation about parameters all together in a docstring, separated from the code defining them.
118
-
119
- You care about a specific set of users, using one specific editor, and that editor already has support for the specific docstring format you use.
120
-
121
- ## Reasons to use `annotated-doc`
122
-
123
- * No micro-syntax to learn for newcomers, it’s **just Python** syntax.
124
- * **Editing** would be already fully supported by default by any editor (current or future) supporting Python syntax, including syntax errors, syntax highlighting, etc.
125
- * **Rendering** would be relatively straightforward to implement by static tools (tools that don't need runtime execution), as the information can be extracted from the AST they normally already create.
126
- * **Deduplication of information**: the name of a parameter would be defined in a single place, not duplicated inside of a docstring.
127
- * **Elimination** of the possibility of having **inconsistencies** when removing a parameter or class variable and **forgetting to remove** its documentation.
128
- * **Minimization** of the probability of adding a new parameter or class variable and **forgetting to add its documentation**.
129
- * **Elimination** of the possibility of having **inconsistencies** between the **name** of a parameter in the **signature** and the name in the docstring when it is renamed.
130
- * **Access** to the documentation string for each symbol at **runtime**, including existing (older) Python versions.
131
- * A more formalized way to document other symbols, like type aliases, that could use Annotated.
132
- * **Support** for apps using FastAPI, Typer and others.
133
- * **AI Accessibility**: AI tools will have an easier way understanding each parameter as the distance from documentation to parameter is much closer.
134
-
135
- ## History
136
-
137
- I ([@tiangolo](https://github.com/tiangolo)) originally wanted for this to be part of the Python standard library (in [PEP 727](https://peps.python.org/pep-0727/)), but the proposal was withdrawn as there was a fair amount of negative feedback and opposition.
138
-
139
- The conclusion was that this was better done as an external effort, in a third-party library.
140
-
141
- So, here it is, with a simpler approach, as a third-party library, in a way that can be used by others, starting with FastAPI and friends.
142
-
143
- ## License
144
-
145
- This project is licensed under the terms of the MIT license.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/lib/python3.12/site-packages/annotated_doc-0.0.4.dist-info/RECORD DELETED
@@ -1,10 +0,0 @@
1
- annotated_doc-0.0.4.dist-info/INSTALLER,sha256=5hhM4Q4mYTT9z6QB6PGpUAW81PGNFrYrdXMj4oM_6ak,2
2
- annotated_doc-0.0.4.dist-info/METADATA,sha256=Irm5KJua33dY2qKKAjJ-OhKaVBVIfwFGej_dSe3Z1TU,6566
3
- annotated_doc-0.0.4.dist-info/RECORD,,
4
- annotated_doc-0.0.4.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- annotated_doc-0.0.4.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
6
- annotated_doc-0.0.4.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
7
- annotated_doc-0.0.4.dist-info/licenses/LICENSE,sha256=__Fwd5pqy_ZavbQFwIfxzuF4ZpHkqWpANFF-SlBKDN8,1086
8
- annotated_doc/__init__.py,sha256=VuyxxUe80kfEyWnOrCx_Bk8hybo3aKo6RYBlkBBYW8k,52
9
- annotated_doc/main.py,sha256=5Zfvxv80SwwLqpRW73AZyZyiM4bWma9QWRbp_cgD20s,1075
10
- annotated_doc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
 
 
 
 
 
 
 
 
 
 
 
.venv/lib/python3.12/site-packages/annotated_doc-0.0.4.dist-info/REQUESTED DELETED
File without changes
.venv/lib/python3.12/site-packages/annotated_doc-0.0.4.dist-info/WHEEL DELETED
@@ -1,4 +0,0 @@
1
- Wheel-Version: 1.0
2
- Generator: pdm-backend (2.4.5)
3
- Root-Is-Purelib: true
4
- Tag: py3-none-any
 
 
 
 
 
.venv/lib/python3.12/site-packages/annotated_doc-0.0.4.dist-info/entry_points.txt DELETED
@@ -1,4 +0,0 @@
1
- [console_scripts]
2
-
3
- [gui_scripts]
4
-
 
 
 
 
 
.venv/lib/python3.12/site-packages/annotated_doc-0.0.4.dist-info/licenses/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2025 Sebastián Ramírez
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/lib/python3.12/site-packages/annotated_doc/__init__.py DELETED
@@ -1,3 +0,0 @@
1
- from .main import Doc as Doc
2
-
3
- __version__ = "0.0.4"
 
 
 
 
.venv/lib/python3.12/site-packages/annotated_doc/main.py DELETED
@@ -1,36 +0,0 @@
1
- class Doc:
2
- """Define the documentation of a type annotation using `Annotated`, to be
3
- used in class attributes, function and method parameters, return values,
4
- and variables.
5
-
6
- The value should be a positional-only string literal to allow static tools
7
- like editors and documentation generators to use it.
8
-
9
- This complements docstrings.
10
-
11
- The string value passed is available in the attribute `documentation`.
12
-
13
- Example:
14
-
15
- ```Python
16
- from typing import Annotated
17
- from annotated_doc import Doc
18
-
19
- def hi(name: Annotated[str, Doc("Who to say hi to")]) -> None:
20
- print(f"Hi, {name}!")
21
- ```
22
- """
23
-
24
- def __init__(self, documentation: str, /) -> None:
25
- self.documentation = documentation
26
-
27
- def __repr__(self) -> str:
28
- return f"Doc({self.documentation!r})"
29
-
30
- def __hash__(self) -> int:
31
- return hash(self.documentation)
32
-
33
- def __eq__(self, other: object) -> bool:
34
- if not isinstance(other, Doc):
35
- return NotImplemented
36
- return self.documentation == other.documentation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/lib/python3.12/site-packages/annotated_doc/py.typed DELETED
File without changes
.venv/lib/python3.12/site-packages/anyio-4.13.0.dist-info/INSTALLER DELETED
@@ -1 +0,0 @@
1
- uv
 
 
.venv/lib/python3.12/site-packages/anyio-4.13.0.dist-info/METADATA DELETED
@@ -1,105 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: anyio
3
- Version: 4.13.0
4
- Summary: High-level concurrency and networking framework on top of asyncio or Trio
5
- Author-email: Alex Grönholm <alex.gronholm@nextday.fi>
6
- License-Expression: MIT
7
- Project-URL: Documentation, https://anyio.readthedocs.io/en/latest/
8
- Project-URL: Changelog, https://anyio.readthedocs.io/en/stable/versionhistory.html
9
- Project-URL: Source code, https://github.com/agronholm/anyio
10
- Project-URL: Issue tracker, https://github.com/agronholm/anyio/issues
11
- Classifier: Development Status :: 5 - Production/Stable
12
- Classifier: Intended Audience :: Developers
13
- Classifier: Framework :: AnyIO
14
- Classifier: Typing :: Typed
15
- Classifier: Programming Language :: Python
16
- Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.10
18
- Classifier: Programming Language :: Python :: 3.11
19
- Classifier: Programming Language :: Python :: 3.12
20
- Classifier: Programming Language :: Python :: 3.13
21
- Classifier: Programming Language :: Python :: 3.14
22
- Requires-Python: >=3.10
23
- Description-Content-Type: text/x-rst
24
- License-File: LICENSE
25
- Requires-Dist: exceptiongroup>=1.0.2; python_version < "3.11"
26
- Requires-Dist: idna>=2.8
27
- Requires-Dist: typing_extensions>=4.5; python_version < "3.13"
28
- Provides-Extra: trio
29
- Requires-Dist: trio>=0.32.0; extra == "trio"
30
- Dynamic: license-file
31
-
32
- .. image:: https://github.com/agronholm/anyio/actions/workflows/test.yml/badge.svg
33
- :target: https://github.com/agronholm/anyio/actions/workflows/test.yml
34
- :alt: Build Status
35
- .. image:: https://coveralls.io/repos/github/agronholm/anyio/badge.svg?branch=master
36
- :target: https://coveralls.io/github/agronholm/anyio?branch=master
37
- :alt: Code Coverage
38
- .. image:: https://readthedocs.org/projects/anyio/badge/?version=latest
39
- :target: https://anyio.readthedocs.io/en/latest/?badge=latest
40
- :alt: Documentation
41
- .. image:: https://badges.gitter.im/gitterHQ/gitter.svg
42
- :target: https://gitter.im/python-trio/AnyIO
43
- :alt: Gitter chat
44
- .. image:: https://tidelift.com/badges/package/pypi/anyio
45
- :target: https://tidelift.com/subscription/pkg/pypi-anyio
46
- :alt: Tidelift
47
-
48
- AnyIO is an asynchronous networking and concurrency library that works on top of either asyncio_ or
49
- Trio_. It implements Trio-like `structured concurrency`_ (SC) on top of asyncio and works in harmony
50
- with the native SC of Trio itself.
51
-
52
- Applications and libraries written against AnyIO's API will run unmodified on either asyncio_ or
53
- Trio_. AnyIO can also be adopted into a library or application incrementally – bit by bit, no full
54
- refactoring necessary. It will blend in with the native libraries of your chosen backend.
55
-
56
- To find out why you might want to use AnyIO's APIs instead of asyncio's, you can read about it
57
- `here <https://anyio.readthedocs.io/en/stable/why.html>`_.
58
-
59
- Documentation
60
- -------------
61
-
62
- View full documentation at: https://anyio.readthedocs.io/
63
-
64
- Features
65
- --------
66
-
67
- AnyIO offers the following functionality:
68
-
69
- * Task groups (nurseries_ in trio terminology)
70
- * High-level networking (TCP, UDP and UNIX sockets)
71
-
72
- * `Happy eyeballs`_ algorithm for TCP connections (more robust than that of asyncio on Python
73
- 3.8)
74
- * async/await style UDP sockets (unlike asyncio where you still have to use Transports and
75
- Protocols)
76
-
77
- * A versatile API for byte streams and object streams
78
- * Inter-task synchronization and communication (locks, conditions, events, semaphores, object
79
- streams)
80
- * Worker threads
81
- * Subprocesses
82
- * Subinterpreter support for code parallelization (on Python 3.13 and later)
83
- * Asynchronous file I/O (using worker threads)
84
- * Signal handling
85
- * Asynchronous version of the functools_ module
86
-
87
- AnyIO also comes with its own pytest_ plugin which also supports asynchronous fixtures.
88
- It even works with the popular Hypothesis_ library.
89
-
90
- .. _asyncio: https://docs.python.org/3/library/asyncio.html
91
- .. _Trio: https://github.com/python-trio/trio
92
- .. _structured concurrency: https://en.wikipedia.org/wiki/Structured_concurrency
93
- .. _nurseries: https://trio.readthedocs.io/en/stable/reference-core.html#nurseries-and-spawning
94
- .. _Happy eyeballs: https://en.wikipedia.org/wiki/Happy_Eyeballs
95
- .. _pytest: https://docs.pytest.org/en/latest/
96
- .. _functools: https://docs.python.org/3/library/functools.html
97
- .. _Hypothesis: https://hypothesis.works/
98
-
99
- Security contact information
100
- ----------------------------
101
-
102
- To report a security vulnerability, please use the `Tidelift security contact`_.
103
- Tidelift will coordinate the fix and disclosure.
104
-
105
- .. _Tidelift security contact: https://tidelift.com/security
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/lib/python3.12/site-packages/anyio-4.13.0.dist-info/RECORD DELETED
@@ -1,51 +0,0 @@
1
- anyio-4.13.0.dist-info/INSTALLER,sha256=5hhM4Q4mYTT9z6QB6PGpUAW81PGNFrYrdXMj4oM_6ak,2
2
- anyio-4.13.0.dist-info/METADATA,sha256=F0EYfiPlmTRwmJN2JktNxJg1GNnl0wHhzOWmz7pFvjM,4513
3
- anyio-4.13.0.dist-info/RECORD,,
4
- anyio-4.13.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- anyio-4.13.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
6
- anyio-4.13.0.dist-info/entry_points.txt,sha256=_d6Yu6uiaZmNe0CydowirE9Cmg7zUL2g08tQpoS3Qvc,39
7
- anyio-4.13.0.dist-info/licenses/LICENSE,sha256=U2GsncWPLvX9LpsJxoKXwX8ElQkJu8gCO9uC6s8iwrA,1081
8
- anyio-4.13.0.dist-info/top_level.txt,sha256=QglSMiWX8_5dpoVAEIHdEYzvqFMdSYWmCj6tYw2ITkQ,6
9
- anyio/__init__.py,sha256=7iDVqMUprUuKNY91FuoKqayAhR-OY136YDPI6P78HHk,6170
10
- anyio/_backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- anyio/_backends/_asyncio.py,sha256=kuqlg2sBUsFdgY80xSDAw60Gx_4WNCl9iSL5XlY6lCU,99476
12
- anyio/_backends/_trio.py,sha256=l9U-TsKRxzmTQxSMvOhn0bNeFn_iRx3Ho30jvR5Bdu0,41366
13
- anyio/_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- anyio/_core/_asyncio_selector_thread.py,sha256=2PdxFM3cs02Kp6BSppbvmRT7q7asreTW5FgBxEsflBo,5626
15
- anyio/_core/_contextmanagers.py,sha256=YInBCabiEeS-UaP_Jdxa1CaFC71ETPW8HZTHIM8Rsc8,7215
16
- anyio/_core/_eventloop.py,sha256=c2EdcBX-xnKwxPcC4Pjn3_qG9I-x4IWFO2R9RqCGjM4,6448
17
- anyio/_core/_exceptions.py,sha256=Y3aq-Wxd7Q2HqwSg7nZPvRsHEuGazv_qeet6gqEBdPk,4407
18
- anyio/_core/_fileio.py,sha256=CKi1gFNiW2G4knWeBE7He7-rptQwgYjDUWfG8DSlvLs,25665
19
- anyio/_core/_resources.py,sha256=NbmU5O5UX3xEyACnkmYX28Fmwdl-f-ny0tHym26e0w0,435
20
- anyio/_core/_signals.py,sha256=mjTBB2hTKNPRlU0IhnijeQedpWOGERDiMjSlJQsFrug,1016
21
- anyio/_core/_sockets.py,sha256=RBXHcUqZt5gg_-OOfgHVv8uq2FSKk1uVUzTdpjBoI1o,34977
22
- anyio/_core/_streams.py,sha256=FczFwIgDpnkK0bODWJXMpsUJYdvAD04kaUaGzJU8DK0,1806
23
- anyio/_core/_subprocesses.py,sha256=tkmkPKEkEaiMD8C9WRZBlmgjOYRDRbZdte6e-unay2E,7916
24
- anyio/_core/_synchronization.py,sha256=9G3fvRsPNrrWJ_Z6gD_80wXq8I8qgAyhwM8PvHQnT2c,21061
25
- anyio/_core/_tasks.py,sha256=pVB7K6AAulzUM8YgXAeqNZG44nSyZ1bYJjH8GznC00I,5435
26
- anyio/_core/_tempfile.py,sha256=jE2w59FRF3yRo4vjkjfZF2YcqsBZvc66VWRwrJGDYGk,19624
27
- anyio/_core/_testing.py,sha256=u7MPqGXwpTxqI7hclSdNA30z2GH1Nw258uwKvy_RfBg,2340
28
- anyio/_core/_typedattr.py,sha256=P4ozZikn3-DbpoYcvyghS_FOYAgbmUxeoU8-L_07pZM,2508
29
- anyio/abc/__init__.py,sha256=6mWhcl_pGXhrgZVHP_TCfMvIXIOp9mroEFM90fYCU_U,2869
30
- anyio/abc/_eventloop.py,sha256=39lYnmtvoHaZw22sWBKOTA_zv7bamOnr8O49PqgDXdw,10629
31
- anyio/abc/_resources.py,sha256=DrYvkNN1hH6Uvv5_5uKySvDsnknGVDe8FCKfko0VtN8,783
32
- anyio/abc/_sockets.py,sha256=OmVDrfemVvF9c5K1tpBgQyV6fn5v0XyCExLAqBOGz9o,13124
33
- anyio/abc/_streams.py,sha256=HYvna1iZbWcwLROTO6IhLX79RTRLPShZMWe0sG1q54I,7481
34
- anyio/abc/_subprocesses.py,sha256=cumAPJTktOQtw63IqG0lDpyZqu_l1EElvQHMiwJgL08,2067
35
- anyio/abc/_tasks.py,sha256=KC7wrciE48AINOI-AhPutnFhe1ewfP7QnamFlDzqesQ,3721
36
- anyio/abc/_testing.py,sha256=tBJUzkSfOXJw23fe8qSJ03kJlShOYjjaEyFB6k6MYT8,1821
37
- anyio/from_thread.py,sha256=L-0w1HxJ6BSb-KuVi57k5Tkc3yzQrx3QK5tAxMPcY-0,19141
38
- anyio/functools.py,sha256=5AWM1iYTKkTzptvUhQDdLSh5GvbBW-vcs-SAUfIfA9A,12076
39
- anyio/lowlevel.py,sha256=AyKLVK3LaWSoK39LkCKxE4_GDMLKZBNqTrLUgk63y80,5158
40
- anyio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
- anyio/pytest_plugin.py,sha256=t6h4KJstqIxfxwTZ1YO8vpUVuB99nfCLltn0NHfatHo,12775
42
- anyio/streams/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
- anyio/streams/buffered.py,sha256=2R3PeJhe4EXrdYqz44Y6-Eg9R6DrmlsYrP36Ir43-po,6263
44
- anyio/streams/file.py,sha256=msnrotVKGMQomUu_Rj2qz9MvIdUp6d3JGr7MOEO8kV4,4428
45
- anyio/streams/memory.py,sha256=F0zwzvFJKAhX_LRZGoKzzqDC2oMM-f-yyTBrEYEGOaU,10740
46
- anyio/streams/stapled.py,sha256=T8Xqwf8K6EgURPxbt1N4i7A8BAk-gScv-GRhjLXIf_o,4390
47
- anyio/streams/text.py,sha256=BcVAGJw1VRvtIqnv-o0Rb0pwH7p8vwlvl21xHq522ag,5765
48
- anyio/streams/tls.py,sha256=DQVkXUvsTEYKkBO8dlVU7j_5H8QOtLy4sGi1Wrjqevo,15303
49
- anyio/to_interpreter.py,sha256=_mLngrMy97TMR6VbW4Y6YzDUk9ZuPcQMPlkuyRh3C9k,7100
50
- anyio/to_process.py,sha256=J7gAA_YOuoHqnpDAf5fm1Qu6kOmTzdFbiDNvnV755vk,9798
51
- anyio/to_thread.py,sha256=f6h_k2d743GBv9FhAnhM_YpTvWgIrzBy9cOE0eJ1UJw,2693
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/lib/python3.12/site-packages/anyio-4.13.0.dist-info/REQUESTED DELETED
File without changes
.venv/lib/python3.12/site-packages/anyio-4.13.0.dist-info/WHEEL DELETED
@@ -1,5 +0,0 @@
1
- Wheel-Version: 1.0
2
- Generator: setuptools (82.0.1)
3
- Root-Is-Purelib: true
4
- Tag: py3-none-any
5
-
 
 
 
 
 
 
.venv/lib/python3.12/site-packages/anyio-4.13.0.dist-info/entry_points.txt DELETED
@@ -1,2 +0,0 @@
1
- [pytest11]
2
- anyio = anyio.pytest_plugin
 
 
 
.venv/lib/python3.12/site-packages/anyio-4.13.0.dist-info/licenses/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2018 Alex Grönholm
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/lib/python3.12/site-packages/anyio-4.13.0.dist-info/top_level.txt DELETED
@@ -1 +0,0 @@
1
- anyio
 
 
.venv/lib/python3.12/site-packages/anyio/__init__.py DELETED
@@ -1,111 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from ._core._contextmanagers import AsyncContextManagerMixin as AsyncContextManagerMixin
4
- from ._core._contextmanagers import ContextManagerMixin as ContextManagerMixin
5
- from ._core._eventloop import current_time as current_time
6
- from ._core._eventloop import get_all_backends as get_all_backends
7
- from ._core._eventloop import get_available_backends as get_available_backends
8
- from ._core._eventloop import get_cancelled_exc_class as get_cancelled_exc_class
9
- from ._core._eventloop import run as run
10
- from ._core._eventloop import sleep as sleep
11
- from ._core._eventloop import sleep_forever as sleep_forever
12
- from ._core._eventloop import sleep_until as sleep_until
13
- from ._core._exceptions import BrokenResourceError as BrokenResourceError
14
- from ._core._exceptions import BrokenWorkerInterpreter as BrokenWorkerInterpreter
15
- from ._core._exceptions import BrokenWorkerProcess as BrokenWorkerProcess
16
- from ._core._exceptions import BusyResourceError as BusyResourceError
17
- from ._core._exceptions import ClosedResourceError as ClosedResourceError
18
- from ._core._exceptions import ConnectionFailed as ConnectionFailed
19
- from ._core._exceptions import DelimiterNotFound as DelimiterNotFound
20
- from ._core._exceptions import EndOfStream as EndOfStream
21
- from ._core._exceptions import IncompleteRead as IncompleteRead
22
- from ._core._exceptions import NoEventLoopError as NoEventLoopError
23
- from ._core._exceptions import RunFinishedError as RunFinishedError
24
- from ._core._exceptions import TypedAttributeLookupError as TypedAttributeLookupError
25
- from ._core._exceptions import WouldBlock as WouldBlock
26
- from ._core._fileio import AsyncFile as AsyncFile
27
- from ._core._fileio import Path as Path
28
- from ._core._fileio import open_file as open_file
29
- from ._core._fileio import wrap_file as wrap_file
30
- from ._core._resources import aclose_forcefully as aclose_forcefully
31
- from ._core._signals import open_signal_receiver as open_signal_receiver
32
- from ._core._sockets import TCPConnectable as TCPConnectable
33
- from ._core._sockets import UNIXConnectable as UNIXConnectable
34
- from ._core._sockets import as_connectable as as_connectable
35
- from ._core._sockets import connect_tcp as connect_tcp
36
- from ._core._sockets import connect_unix as connect_unix
37
- from ._core._sockets import create_connected_udp_socket as create_connected_udp_socket
38
- from ._core._sockets import (
39
- create_connected_unix_datagram_socket as create_connected_unix_datagram_socket,
40
- )
41
- from ._core._sockets import create_tcp_listener as create_tcp_listener
42
- from ._core._sockets import create_udp_socket as create_udp_socket
43
- from ._core._sockets import create_unix_datagram_socket as create_unix_datagram_socket
44
- from ._core._sockets import create_unix_listener as create_unix_listener
45
- from ._core._sockets import getaddrinfo as getaddrinfo
46
- from ._core._sockets import getnameinfo as getnameinfo
47
- from ._core._sockets import notify_closing as notify_closing
48
- from ._core._sockets import wait_readable as wait_readable
49
- from ._core._sockets import wait_socket_readable as wait_socket_readable
50
- from ._core._sockets import wait_socket_writable as wait_socket_writable
51
- from ._core._sockets import wait_writable as wait_writable
52
- from ._core._streams import create_memory_object_stream as create_memory_object_stream
53
- from ._core._subprocesses import open_process as open_process
54
- from ._core._subprocesses import run_process as run_process
55
- from ._core._synchronization import CapacityLimiter as CapacityLimiter
56
- from ._core._synchronization import (
57
- CapacityLimiterStatistics as CapacityLimiterStatistics,
58
- )
59
- from ._core._synchronization import Condition as Condition
60
- from ._core._synchronization import ConditionStatistics as ConditionStatistics
61
- from ._core._synchronization import Event as Event
62
- from ._core._synchronization import EventStatistics as EventStatistics
63
- from ._core._synchronization import Lock as Lock
64
- from ._core._synchronization import LockStatistics as LockStatistics
65
- from ._core._synchronization import ResourceGuard as ResourceGuard
66
- from ._core._synchronization import Semaphore as Semaphore
67
- from ._core._synchronization import SemaphoreStatistics as SemaphoreStatistics
68
- from ._core._tasks import TASK_STATUS_IGNORED as TASK_STATUS_IGNORED
69
- from ._core._tasks import CancelScope as CancelScope
70
- from ._core._tasks import create_task_group as create_task_group
71
- from ._core._tasks import current_effective_deadline as current_effective_deadline
72
- from ._core._tasks import fail_after as fail_after
73
- from ._core._tasks import move_on_after as move_on_after
74
- from ._core._tempfile import NamedTemporaryFile as NamedTemporaryFile
75
- from ._core._tempfile import SpooledTemporaryFile as SpooledTemporaryFile
76
- from ._core._tempfile import TemporaryDirectory as TemporaryDirectory
77
- from ._core._tempfile import TemporaryFile as TemporaryFile
78
- from ._core._tempfile import gettempdir as gettempdir
79
- from ._core._tempfile import gettempdirb as gettempdirb
80
- from ._core._tempfile import mkdtemp as mkdtemp
81
- from ._core._tempfile import mkstemp as mkstemp
82
- from ._core._testing import TaskInfo as TaskInfo
83
- from ._core._testing import get_current_task as get_current_task
84
- from ._core._testing import get_running_tasks as get_running_tasks
85
- from ._core._testing import wait_all_tasks_blocked as wait_all_tasks_blocked
86
- from ._core._typedattr import TypedAttributeProvider as TypedAttributeProvider
87
- from ._core._typedattr import TypedAttributeSet as TypedAttributeSet
88
- from ._core._typedattr import typed_attribute as typed_attribute
89
-
90
- # Re-export imports so they look like they live directly in this package
91
- for __value in list(locals().values()):
92
- if getattr(__value, "__module__", "").startswith("anyio."):
93
- __value.__module__ = __name__
94
-
95
-
96
- del __value
97
-
98
-
99
- def __getattr__(attr: str) -> type[BrokenWorkerInterpreter]:
100
- """Support deprecated aliases."""
101
- if attr == "BrokenWorkerIntepreter":
102
- import warnings
103
-
104
- warnings.warn(
105
- "The 'BrokenWorkerIntepreter' alias is deprecated, use 'BrokenWorkerInterpreter' instead.",
106
- DeprecationWarning,
107
- stacklevel=2,
108
- )
109
- return BrokenWorkerInterpreter
110
-
111
- raise AttributeError(f"module {__name__!r} has no attribute {attr!r}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/lib/python3.12/site-packages/anyio/_backends/__init__.py DELETED
File without changes
.venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py DELETED
The diff for this file is too large to render. See raw diff
 
.venv/lib/python3.12/site-packages/anyio/_backends/_trio.py DELETED
@@ -1,1343 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import array
4
- import math
5
- import os
6
- import socket
7
- import sys
8
- import types
9
- import weakref
10
- from collections.abc import (
11
- AsyncGenerator,
12
- AsyncIterator,
13
- Awaitable,
14
- Callable,
15
- Collection,
16
- Coroutine,
17
- Iterable,
18
- Sequence,
19
- )
20
- from contextlib import AbstractContextManager
21
- from dataclasses import dataclass
22
- from io import IOBase
23
- from os import PathLike
24
- from signal import Signals
25
- from socket import AddressFamily, SocketKind
26
- from types import TracebackType
27
- from typing import (
28
- IO,
29
- TYPE_CHECKING,
30
- Any,
31
- Generic,
32
- NoReturn,
33
- ParamSpec,
34
- TypeVar,
35
- cast,
36
- overload,
37
- )
38
-
39
- import trio.from_thread
40
- import trio.lowlevel
41
- from outcome import Error, Outcome, Value
42
- from trio.lowlevel import (
43
- current_root_task,
44
- current_task,
45
- notify_closing,
46
- wait_readable,
47
- wait_writable,
48
- )
49
- from trio.socket import SocketType as TrioSocketType
50
- from trio.to_thread import run_sync
51
-
52
- from .. import (
53
- CapacityLimiterStatistics,
54
- EventStatistics,
55
- LockStatistics,
56
- RunFinishedError,
57
- TaskInfo,
58
- WouldBlock,
59
- abc,
60
- )
61
- from .._core._eventloop import claim_worker_thread
62
- from .._core._exceptions import (
63
- BrokenResourceError,
64
- BusyResourceError,
65
- ClosedResourceError,
66
- EndOfStream,
67
- )
68
- from .._core._sockets import convert_ipv6_sockaddr
69
- from .._core._streams import create_memory_object_stream
70
- from .._core._synchronization import (
71
- CapacityLimiter as BaseCapacityLimiter,
72
- )
73
- from .._core._synchronization import Event as BaseEvent
74
- from .._core._synchronization import Lock as BaseLock
75
- from .._core._synchronization import (
76
- ResourceGuard,
77
- SemaphoreStatistics,
78
- )
79
- from .._core._synchronization import Semaphore as BaseSemaphore
80
- from .._core._tasks import CancelScope as BaseCancelScope
81
- from ..abc import IPSockAddrType, UDPPacketType, UNIXDatagramPacketType
82
- from ..abc._eventloop import AsyncBackend, StrOrBytesPath
83
- from ..streams.memory import MemoryObjectSendStream
84
-
85
- if TYPE_CHECKING:
86
- from _typeshed import FileDescriptorLike
87
-
88
- if sys.version_info >= (3, 11):
89
- from typing import TypeVarTuple, Unpack
90
- else:
91
- from exceptiongroup import BaseExceptionGroup
92
- from typing_extensions import TypeVarTuple, Unpack
93
-
94
- T = TypeVar("T")
95
- T_Retval = TypeVar("T_Retval")
96
- T_SockAddr = TypeVar("T_SockAddr", str, IPSockAddrType)
97
- PosArgsT = TypeVarTuple("PosArgsT")
98
- P = ParamSpec("P")
99
-
100
-
101
- #
102
- # Event loop
103
- #
104
-
105
- RunVar = trio.lowlevel.RunVar
106
-
107
-
108
- #
109
- # Timeouts and cancellation
110
- #
111
-
112
-
113
- class CancelScope(BaseCancelScope):
114
- def __new__(
115
- cls, original: trio.CancelScope | None = None, **kwargs: object
116
- ) -> CancelScope:
117
- return object.__new__(cls)
118
-
119
- def __init__(self, original: trio.CancelScope | None = None, **kwargs: Any) -> None:
120
- self.__original = original or trio.CancelScope(**kwargs)
121
-
122
- def __enter__(self) -> CancelScope:
123
- self.__original.__enter__()
124
- return self
125
-
126
- def __exit__(
127
- self,
128
- exc_type: type[BaseException] | None,
129
- exc_val: BaseException | None,
130
- exc_tb: TracebackType | None,
131
- ) -> bool:
132
- return self.__original.__exit__(exc_type, exc_val, exc_tb)
133
-
134
- def cancel(self, reason: str | None = None) -> None:
135
- self.__original.cancel(reason)
136
-
137
- @property
138
- def deadline(self) -> float:
139
- return self.__original.deadline
140
-
141
- @deadline.setter
142
- def deadline(self, value: float) -> None:
143
- self.__original.deadline = value
144
-
145
- @property
146
- def cancel_called(self) -> bool:
147
- return self.__original.cancel_called
148
-
149
- @property
150
- def cancelled_caught(self) -> bool:
151
- return self.__original.cancelled_caught
152
-
153
- @property
154
- def shield(self) -> bool:
155
- return self.__original.shield
156
-
157
- @shield.setter
158
- def shield(self, value: bool) -> None:
159
- self.__original.shield = value
160
-
161
-
162
- #
163
- # Task groups
164
- #
165
-
166
-
167
- class TaskGroup(abc.TaskGroup):
168
- def __init__(self) -> None:
169
- self._active = False
170
- self._nursery_manager = trio.open_nursery(strict_exception_groups=True)
171
- self.cancel_scope = None # type: ignore[assignment]
172
-
173
- async def __aenter__(self) -> TaskGroup:
174
- self._active = True
175
- self._nursery = await self._nursery_manager.__aenter__()
176
- self.cancel_scope = CancelScope(self._nursery.cancel_scope)
177
- return self
178
-
179
- async def __aexit__(
180
- self,
181
- exc_type: type[BaseException] | None,
182
- exc_val: BaseException | None,
183
- exc_tb: TracebackType | None,
184
- ) -> bool:
185
- try:
186
- # trio.Nursery.__exit__ returns bool; .open_nursery has wrong type
187
- return await self._nursery_manager.__aexit__(exc_type, exc_val, exc_tb) # type: ignore[return-value]
188
- except BaseExceptionGroup as exc:
189
- if not exc.split(trio.Cancelled)[1]:
190
- raise trio.Cancelled._create() from exc
191
-
192
- raise
193
- finally:
194
- del exc_val, exc_tb
195
- self._active = False
196
-
197
- def start_soon(
198
- self,
199
- func: Callable[[Unpack[PosArgsT]], Awaitable[Any]],
200
- *args: Unpack[PosArgsT],
201
- name: object = None,
202
- ) -> None:
203
- if not self._active:
204
- raise RuntimeError(
205
- "This task group is not active; no new tasks can be started."
206
- )
207
-
208
- self._nursery.start_soon(func, *args, name=name)
209
-
210
- async def start(
211
- self, func: Callable[..., Awaitable[Any]], *args: object, name: object = None
212
- ) -> Any:
213
- if not self._active:
214
- raise RuntimeError(
215
- "This task group is not active; no new tasks can be started."
216
- )
217
-
218
- return await self._nursery.start(func, *args, name=name)
219
-
220
-
221
- #
222
- # Subprocesses
223
- #
224
-
225
-
226
- @dataclass(eq=False)
227
- class ReceiveStreamWrapper(abc.ByteReceiveStream):
228
- _stream: trio.abc.ReceiveStream
229
-
230
- async def receive(self, max_bytes: int | None = None) -> bytes:
231
- try:
232
- data = await self._stream.receive_some(max_bytes)
233
- except trio.ClosedResourceError as exc:
234
- raise ClosedResourceError from exc.__cause__
235
- except trio.BrokenResourceError as exc:
236
- raise BrokenResourceError from exc.__cause__
237
-
238
- if data:
239
- return bytes(data)
240
- else:
241
- raise EndOfStream
242
-
243
- async def aclose(self) -> None:
244
- await self._stream.aclose()
245
-
246
-
247
- @dataclass(eq=False)
248
- class SendStreamWrapper(abc.ByteSendStream):
249
- _stream: trio.abc.SendStream
250
-
251
- async def send(self, item: bytes) -> None:
252
- try:
253
- await self._stream.send_all(item)
254
- except trio.ClosedResourceError as exc:
255
- raise ClosedResourceError from exc.__cause__
256
- except trio.BrokenResourceError as exc:
257
- raise BrokenResourceError from exc.__cause__
258
-
259
- async def aclose(self) -> None:
260
- await self._stream.aclose()
261
-
262
-
263
- @dataclass(eq=False)
264
- class Process(abc.Process):
265
- _process: trio.Process
266
- _stdin: abc.ByteSendStream | None
267
- _stdout: abc.ByteReceiveStream | None
268
- _stderr: abc.ByteReceiveStream | None
269
-
270
- async def aclose(self) -> None:
271
- with CancelScope(shield=True):
272
- if self._stdin:
273
- await self._stdin.aclose()
274
- if self._stdout:
275
- await self._stdout.aclose()
276
- if self._stderr:
277
- await self._stderr.aclose()
278
-
279
- try:
280
- await self.wait()
281
- except BaseException:
282
- self.kill()
283
- with CancelScope(shield=True):
284
- await self.wait()
285
- raise
286
-
287
- async def wait(self) -> int:
288
- return await self._process.wait()
289
-
290
- def terminate(self) -> None:
291
- self._process.terminate()
292
-
293
- def kill(self) -> None:
294
- self._process.kill()
295
-
296
- def send_signal(self, signal: Signals) -> None:
297
- self._process.send_signal(signal)
298
-
299
- @property
300
- def pid(self) -> int:
301
- return self._process.pid
302
-
303
- @property
304
- def returncode(self) -> int | None:
305
- return self._process.returncode
306
-
307
- @property
308
- def stdin(self) -> abc.ByteSendStream | None:
309
- return self._stdin
310
-
311
- @property
312
- def stdout(self) -> abc.ByteReceiveStream | None:
313
- return self._stdout
314
-
315
- @property
316
- def stderr(self) -> abc.ByteReceiveStream | None:
317
- return self._stderr
318
-
319
-
320
- class _ProcessPoolShutdownInstrument(trio.abc.Instrument):
321
- def after_run(self) -> None:
322
- super().after_run()
323
-
324
-
325
- current_default_worker_process_limiter: trio.lowlevel.RunVar = RunVar(
326
- "current_default_worker_process_limiter"
327
- )
328
-
329
-
330
- async def _shutdown_process_pool(workers: set[abc.Process]) -> None:
331
- try:
332
- await trio.sleep(math.inf)
333
- except trio.Cancelled:
334
- for process in workers:
335
- if process.returncode is None:
336
- process.kill()
337
-
338
- with CancelScope(shield=True):
339
- for process in workers:
340
- await process.aclose()
341
-
342
-
343
- #
344
- # Sockets and networking
345
- #
346
-
347
-
348
- class _TrioSocketMixin(Generic[T_SockAddr]):
349
- def __init__(self, trio_socket: TrioSocketType) -> None:
350
- self._trio_socket = trio_socket
351
- self._closed = False
352
-
353
- def _check_closed(self) -> None:
354
- if self._closed:
355
- raise ClosedResourceError
356
- if self._trio_socket.fileno() < 0:
357
- raise BrokenResourceError
358
-
359
- @property
360
- def _raw_socket(self) -> socket.socket:
361
- return self._trio_socket._sock # type: ignore[attr-defined]
362
-
363
- async def aclose(self) -> None:
364
- if self._trio_socket.fileno() >= 0:
365
- self._closed = True
366
- self._trio_socket.close()
367
-
368
- def _convert_socket_error(self, exc: BaseException) -> NoReturn:
369
- if isinstance(exc, trio.ClosedResourceError):
370
- raise ClosedResourceError from exc
371
- elif self._trio_socket.fileno() < 0 and self._closed:
372
- raise ClosedResourceError from None
373
- elif isinstance(exc, OSError):
374
- raise BrokenResourceError from exc
375
- else:
376
- raise exc
377
-
378
-
379
- class SocketStream(_TrioSocketMixin, abc.SocketStream):
380
- def __init__(self, trio_socket: TrioSocketType) -> None:
381
- super().__init__(trio_socket)
382
- self._receive_guard = ResourceGuard("reading from")
383
- self._send_guard = ResourceGuard("writing to")
384
-
385
- async def receive(self, max_bytes: int = 65536) -> bytes:
386
- with self._receive_guard:
387
- try:
388
- data = await self._trio_socket.recv(max_bytes)
389
- except BaseException as exc:
390
- self._convert_socket_error(exc)
391
-
392
- if data:
393
- return data
394
- else:
395
- raise EndOfStream
396
-
397
- async def send(self, item: bytes) -> None:
398
- with self._send_guard:
399
- view = memoryview(item)
400
- while view:
401
- try:
402
- bytes_sent = await self._trio_socket.send(view)
403
- except BaseException as exc:
404
- self._convert_socket_error(exc)
405
-
406
- view = view[bytes_sent:]
407
-
408
- async def send_eof(self) -> None:
409
- self._trio_socket.shutdown(socket.SHUT_WR)
410
-
411
-
412
- class UNIXSocketStream(SocketStream, abc.UNIXSocketStream):
413
- async def receive_fds(self, msglen: int, maxfds: int) -> tuple[bytes, list[int]]:
414
- if not isinstance(msglen, int) or msglen < 0:
415
- raise ValueError("msglen must be a non-negative integer")
416
- if not isinstance(maxfds, int) or maxfds < 1:
417
- raise ValueError("maxfds must be a positive integer")
418
-
419
- fds = array.array("i")
420
- await trio.lowlevel.checkpoint()
421
- with self._receive_guard:
422
- while True:
423
- try:
424
- message, ancdata, flags, addr = await self._trio_socket.recvmsg(
425
- msglen, socket.CMSG_LEN(maxfds * fds.itemsize)
426
- )
427
- except BaseException as exc:
428
- self._convert_socket_error(exc)
429
- else:
430
- if not message and not ancdata:
431
- raise EndOfStream
432
-
433
- break
434
-
435
- for cmsg_level, cmsg_type, cmsg_data in ancdata:
436
- if cmsg_level != socket.SOL_SOCKET or cmsg_type != socket.SCM_RIGHTS:
437
- raise RuntimeError(
438
- f"Received unexpected ancillary data; message = {message!r}, "
439
- f"cmsg_level = {cmsg_level}, cmsg_type = {cmsg_type}"
440
- )
441
-
442
- fds.frombytes(cmsg_data[: len(cmsg_data) - (len(cmsg_data) % fds.itemsize)])
443
-
444
- return message, list(fds)
445
-
446
- async def send_fds(self, message: bytes, fds: Collection[int | IOBase]) -> None:
447
- if not message:
448
- raise ValueError("message must not be empty")
449
- if not fds:
450
- raise ValueError("fds must not be empty")
451
-
452
- filenos: list[int] = []
453
- for fd in fds:
454
- if isinstance(fd, int):
455
- filenos.append(fd)
456
- elif isinstance(fd, IOBase):
457
- filenos.append(fd.fileno())
458
-
459
- fdarray = array.array("i", filenos)
460
- await trio.lowlevel.checkpoint()
461
- with self._send_guard:
462
- while True:
463
- try:
464
- await self._trio_socket.sendmsg(
465
- [message],
466
- [
467
- (
468
- socket.SOL_SOCKET,
469
- socket.SCM_RIGHTS,
470
- fdarray,
471
- )
472
- ],
473
- )
474
- break
475
- except BaseException as exc:
476
- self._convert_socket_error(exc)
477
-
478
-
479
- class TCPSocketListener(_TrioSocketMixin, abc.SocketListener):
480
- def __init__(self, raw_socket: socket.socket):
481
- super().__init__(trio.socket.from_stdlib_socket(raw_socket))
482
- self._accept_guard = ResourceGuard("accepting connections from")
483
-
484
- async def accept(self) -> SocketStream:
485
- with self._accept_guard:
486
- try:
487
- trio_socket, _addr = await self._trio_socket.accept()
488
- except BaseException as exc:
489
- self._convert_socket_error(exc)
490
-
491
- trio_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
492
- return SocketStream(trio_socket)
493
-
494
-
495
- class UNIXSocketListener(_TrioSocketMixin, abc.SocketListener):
496
- def __init__(self, raw_socket: socket.socket):
497
- super().__init__(trio.socket.from_stdlib_socket(raw_socket))
498
- self._accept_guard = ResourceGuard("accepting connections from")
499
-
500
- async def accept(self) -> UNIXSocketStream:
501
- with self._accept_guard:
502
- try:
503
- trio_socket, _addr = await self._trio_socket.accept()
504
- except BaseException as exc:
505
- self._convert_socket_error(exc)
506
-
507
- return UNIXSocketStream(trio_socket)
508
-
509
-
510
- class UDPSocket(_TrioSocketMixin[IPSockAddrType], abc.UDPSocket):
511
- def __init__(self, trio_socket: TrioSocketType) -> None:
512
- super().__init__(trio_socket)
513
- self._receive_guard = ResourceGuard("reading from")
514
- self._send_guard = ResourceGuard("writing to")
515
-
516
- async def receive(self) -> tuple[bytes, IPSockAddrType]:
517
- with self._receive_guard:
518
- try:
519
- data, addr = await self._trio_socket.recvfrom(65536)
520
- return data, convert_ipv6_sockaddr(addr)
521
- except BaseException as exc:
522
- self._convert_socket_error(exc)
523
-
524
- async def send(self, item: UDPPacketType) -> None:
525
- with self._send_guard:
526
- try:
527
- await self._trio_socket.sendto(*item)
528
- except BaseException as exc:
529
- self._convert_socket_error(exc)
530
-
531
-
532
- class ConnectedUDPSocket(_TrioSocketMixin[IPSockAddrType], abc.ConnectedUDPSocket):
533
- def __init__(self, trio_socket: TrioSocketType) -> None:
534
- super().__init__(trio_socket)
535
- self._receive_guard = ResourceGuard("reading from")
536
- self._send_guard = ResourceGuard("writing to")
537
-
538
- async def receive(self) -> bytes:
539
- with self._receive_guard:
540
- try:
541
- return await self._trio_socket.recv(65536)
542
- except BaseException as exc:
543
- self._convert_socket_error(exc)
544
-
545
- async def send(self, item: bytes) -> None:
546
- with self._send_guard:
547
- try:
548
- await self._trio_socket.send(item)
549
- except BaseException as exc:
550
- self._convert_socket_error(exc)
551
-
552
-
553
- class UNIXDatagramSocket(_TrioSocketMixin[str], abc.UNIXDatagramSocket):
554
- def __init__(self, trio_socket: TrioSocketType) -> None:
555
- super().__init__(trio_socket)
556
- self._receive_guard = ResourceGuard("reading from")
557
- self._send_guard = ResourceGuard("writing to")
558
-
559
- async def receive(self) -> UNIXDatagramPacketType:
560
- with self._receive_guard:
561
- try:
562
- data, addr = await self._trio_socket.recvfrom(65536)
563
- return data, addr
564
- except BaseException as exc:
565
- self._convert_socket_error(exc)
566
-
567
- async def send(self, item: UNIXDatagramPacketType) -> None:
568
- with self._send_guard:
569
- try:
570
- await self._trio_socket.sendto(*item)
571
- except BaseException as exc:
572
- self._convert_socket_error(exc)
573
-
574
-
575
- class ConnectedUNIXDatagramSocket(
576
- _TrioSocketMixin[str], abc.ConnectedUNIXDatagramSocket
577
- ):
578
- def __init__(self, trio_socket: TrioSocketType) -> None:
579
- super().__init__(trio_socket)
580
- self._receive_guard = ResourceGuard("reading from")
581
- self._send_guard = ResourceGuard("writing to")
582
-
583
- async def receive(self) -> bytes:
584
- with self._receive_guard:
585
- try:
586
- return await self._trio_socket.recv(65536)
587
- except BaseException as exc:
588
- self._convert_socket_error(exc)
589
-
590
- async def send(self, item: bytes) -> None:
591
- with self._send_guard:
592
- try:
593
- await self._trio_socket.send(item)
594
- except BaseException as exc:
595
- self._convert_socket_error(exc)
596
-
597
-
598
- #
599
- # Synchronization
600
- #
601
-
602
-
603
- class Event(BaseEvent):
604
- def __new__(cls) -> Event:
605
- return object.__new__(cls)
606
-
607
- def __init__(self) -> None:
608
- self.__original = trio.Event()
609
-
610
- def is_set(self) -> bool:
611
- return self.__original.is_set()
612
-
613
- async def wait(self) -> None:
614
- return await self.__original.wait()
615
-
616
- def statistics(self) -> EventStatistics:
617
- orig_statistics = self.__original.statistics()
618
- return EventStatistics(tasks_waiting=orig_statistics.tasks_waiting)
619
-
620
- def set(self) -> None:
621
- self.__original.set()
622
-
623
-
624
- class Lock(BaseLock):
625
- def __new__(cls, *, fast_acquire: bool = False) -> Lock:
626
- return object.__new__(cls)
627
-
628
- def __init__(self, *, fast_acquire: bool = False) -> None:
629
- self._fast_acquire = fast_acquire
630
- self.__original = trio.Lock()
631
-
632
- @staticmethod
633
- def _convert_runtime_error_msg(exc: RuntimeError) -> None:
634
- if exc.args == ("attempt to re-acquire an already held Lock",):
635
- exc.args = ("Attempted to acquire an already held Lock",)
636
-
637
- async def acquire(self) -> None:
638
- if not self._fast_acquire:
639
- try:
640
- await self.__original.acquire()
641
- except RuntimeError as exc:
642
- self._convert_runtime_error_msg(exc)
643
- raise
644
-
645
- return
646
-
647
- # This is the "fast path" where we don't let other tasks run
648
- await trio.lowlevel.checkpoint_if_cancelled()
649
- try:
650
- self.__original.acquire_nowait()
651
- except trio.WouldBlock:
652
- await self.__original._lot.park()
653
- except RuntimeError as exc:
654
- self._convert_runtime_error_msg(exc)
655
- raise
656
-
657
- def acquire_nowait(self) -> None:
658
- try:
659
- self.__original.acquire_nowait()
660
- except trio.WouldBlock:
661
- raise WouldBlock from None
662
- except RuntimeError as exc:
663
- self._convert_runtime_error_msg(exc)
664
- raise
665
-
666
- def locked(self) -> bool:
667
- return self.__original.locked()
668
-
669
- def release(self) -> None:
670
- self.__original.release()
671
-
672
- def statistics(self) -> LockStatistics:
673
- orig_statistics = self.__original.statistics()
674
- owner = TrioTaskInfo(orig_statistics.owner) if orig_statistics.owner else None
675
- return LockStatistics(
676
- orig_statistics.locked, owner, orig_statistics.tasks_waiting
677
- )
678
-
679
-
680
- class Semaphore(BaseSemaphore):
681
- def __new__(
682
- cls,
683
- initial_value: int,
684
- *,
685
- max_value: int | None = None,
686
- fast_acquire: bool = False,
687
- ) -> Semaphore:
688
- return object.__new__(cls)
689
-
690
- def __init__(
691
- self,
692
- initial_value: int,
693
- *,
694
- max_value: int | None = None,
695
- fast_acquire: bool = False,
696
- ) -> None:
697
- super().__init__(initial_value, max_value=max_value, fast_acquire=fast_acquire)
698
- self.__original = trio.Semaphore(initial_value, max_value=max_value)
699
-
700
- async def acquire(self) -> None:
701
- if not self._fast_acquire:
702
- await self.__original.acquire()
703
- return
704
-
705
- # This is the "fast path" where we don't let other tasks run
706
- await trio.lowlevel.checkpoint_if_cancelled()
707
- try:
708
- self.__original.acquire_nowait()
709
- except trio.WouldBlock:
710
- await self.__original._lot.park()
711
-
712
- def acquire_nowait(self) -> None:
713
- try:
714
- self.__original.acquire_nowait()
715
- except trio.WouldBlock:
716
- raise WouldBlock from None
717
-
718
- @property
719
- def max_value(self) -> int | None:
720
- return self.__original.max_value
721
-
722
- @property
723
- def value(self) -> int:
724
- return self.__original.value
725
-
726
- def release(self) -> None:
727
- self.__original.release()
728
-
729
- def statistics(self) -> SemaphoreStatistics:
730
- orig_statistics = self.__original.statistics()
731
- return SemaphoreStatistics(orig_statistics.tasks_waiting)
732
-
733
-
734
- class CapacityLimiter(BaseCapacityLimiter):
735
- def __new__(
736
- cls,
737
- total_tokens: float | None = None,
738
- *,
739
- original: trio.CapacityLimiter | None = None,
740
- ) -> CapacityLimiter:
741
- return object.__new__(cls)
742
-
743
- def __init__(
744
- self,
745
- total_tokens: float | None = None,
746
- *,
747
- original: trio.CapacityLimiter | None = None,
748
- ) -> None:
749
- if original is not None:
750
- self.__original = original
751
- else:
752
- assert total_tokens is not None
753
- self.__original = trio.CapacityLimiter(total_tokens)
754
-
755
- async def __aenter__(self) -> None:
756
- return await self.__original.__aenter__()
757
-
758
- async def __aexit__(
759
- self,
760
- exc_type: type[BaseException] | None,
761
- exc_val: BaseException | None,
762
- exc_tb: TracebackType | None,
763
- ) -> None:
764
- await self.__original.__aexit__(exc_type, exc_val, exc_tb)
765
-
766
- @property
767
- def total_tokens(self) -> float:
768
- return self.__original.total_tokens
769
-
770
- @total_tokens.setter
771
- def total_tokens(self, value: float) -> None:
772
- self.__original.total_tokens = value
773
-
774
- @property
775
- def borrowed_tokens(self) -> int:
776
- return self.__original.borrowed_tokens
777
-
778
- @property
779
- def available_tokens(self) -> float:
780
- return self.__original.available_tokens
781
-
782
- def acquire_nowait(self) -> None:
783
- self.__original.acquire_nowait()
784
-
785
- def acquire_on_behalf_of_nowait(self, borrower: object) -> None:
786
- self.__original.acquire_on_behalf_of_nowait(borrower)
787
-
788
- async def acquire(self) -> None:
789
- await self.__original.acquire()
790
-
791
- async def acquire_on_behalf_of(self, borrower: object) -> None:
792
- await self.__original.acquire_on_behalf_of(borrower)
793
-
794
- def release(self) -> None:
795
- return self.__original.release()
796
-
797
- def release_on_behalf_of(self, borrower: object) -> None:
798
- return self.__original.release_on_behalf_of(borrower)
799
-
800
- def statistics(self) -> CapacityLimiterStatistics:
801
- orig = self.__original.statistics()
802
- return CapacityLimiterStatistics(
803
- borrowed_tokens=orig.borrowed_tokens,
804
- total_tokens=orig.total_tokens,
805
- borrowers=tuple(orig.borrowers),
806
- tasks_waiting=orig.tasks_waiting,
807
- )
808
-
809
-
810
- _capacity_limiter_wrapper: trio.lowlevel.RunVar = RunVar("_capacity_limiter_wrapper")
811
-
812
-
813
- #
814
- # Signal handling
815
- #
816
-
817
-
818
- class _SignalReceiver:
819
- _iterator: AsyncIterator[int]
820
-
821
- def __init__(self, signals: tuple[Signals, ...]):
822
- self._signals = signals
823
-
824
- def __enter__(self) -> _SignalReceiver:
825
- self._cm = trio.open_signal_receiver(*self._signals)
826
- self._iterator = self._cm.__enter__()
827
- return self
828
-
829
- def __exit__(
830
- self,
831
- exc_type: type[BaseException] | None,
832
- exc_val: BaseException | None,
833
- exc_tb: TracebackType | None,
834
- ) -> bool | None:
835
- return self._cm.__exit__(exc_type, exc_val, exc_tb)
836
-
837
- def __aiter__(self) -> _SignalReceiver:
838
- return self
839
-
840
- async def __anext__(self) -> Signals:
841
- signum = await self._iterator.__anext__()
842
- return Signals(signum)
843
-
844
-
845
- #
846
- # Testing and debugging
847
- #
848
-
849
-
850
- class TestRunner(abc.TestRunner):
851
- def __init__(self, **options: Any) -> None:
852
- from queue import Queue
853
-
854
- self._call_queue: Queue[Callable[[], object]] = Queue()
855
- self._send_stream: MemoryObjectSendStream | None = None
856
- self._options = options
857
-
858
- def __exit__(
859
- self,
860
- exc_type: type[BaseException] | None,
861
- exc_val: BaseException | None,
862
- exc_tb: types.TracebackType | None,
863
- ) -> None:
864
- if self._send_stream:
865
- self._send_stream.close()
866
- while self._send_stream is not None:
867
- self._call_queue.get()()
868
-
869
- async def _run_tests_and_fixtures(self) -> None:
870
- self._send_stream, receive_stream = create_memory_object_stream(1)
871
- with receive_stream:
872
- async for coro, outcome_holder in receive_stream:
873
- try:
874
- retval = await coro
875
- except BaseException as exc:
876
- outcome_holder.append(Error(exc))
877
- else:
878
- outcome_holder.append(Value(retval))
879
-
880
- def _main_task_finished(self, outcome: object) -> None:
881
- self._send_stream = None
882
-
883
- def _call_in_runner_task(
884
- self,
885
- func: Callable[P, Awaitable[T_Retval]],
886
- /,
887
- *args: P.args,
888
- **kwargs: P.kwargs,
889
- ) -> T_Retval:
890
- if self._send_stream is None:
891
- trio.lowlevel.start_guest_run(
892
- self._run_tests_and_fixtures,
893
- run_sync_soon_threadsafe=self._call_queue.put,
894
- done_callback=self._main_task_finished,
895
- **self._options,
896
- )
897
- while self._send_stream is None:
898
- self._call_queue.get()()
899
-
900
- outcome_holder: list[Outcome] = []
901
- self._send_stream.send_nowait((func(*args, **kwargs), outcome_holder))
902
- while not outcome_holder:
903
- self._call_queue.get()()
904
-
905
- return outcome_holder[0].unwrap()
906
-
907
- def run_asyncgen_fixture(
908
- self,
909
- fixture_func: Callable[..., AsyncGenerator[T_Retval, Any]],
910
- kwargs: dict[str, Any],
911
- ) -> Iterable[T_Retval]:
912
- asyncgen = fixture_func(**kwargs)
913
- fixturevalue: T_Retval = self._call_in_runner_task(asyncgen.asend, None)
914
-
915
- yield fixturevalue
916
-
917
- try:
918
- self._call_in_runner_task(asyncgen.asend, None)
919
- except StopAsyncIteration:
920
- pass
921
- else:
922
- self._call_in_runner_task(asyncgen.aclose)
923
- raise RuntimeError("Async generator fixture did not stop")
924
-
925
- def run_fixture(
926
- self,
927
- fixture_func: Callable[..., Coroutine[Any, Any, T_Retval]],
928
- kwargs: dict[str, Any],
929
- ) -> T_Retval:
930
- return self._call_in_runner_task(fixture_func, **kwargs)
931
-
932
- def run_test(
933
- self, test_func: Callable[..., Coroutine[Any, Any, Any]], kwargs: dict[str, Any]
934
- ) -> None:
935
- self._call_in_runner_task(test_func, **kwargs)
936
-
937
-
938
- class TrioTaskInfo(TaskInfo):
939
- def __init__(self, task: trio.lowlevel.Task):
940
- parent_id = None
941
- if task.parent_nursery and task.parent_nursery.parent_task:
942
- parent_id = id(task.parent_nursery.parent_task)
943
-
944
- super().__init__(id(task), parent_id, task.name, task.coro)
945
- self._task = weakref.proxy(task)
946
-
947
- def has_pending_cancellation(self) -> bool:
948
- try:
949
- return self._task._cancel_status.effectively_cancelled
950
- except ReferenceError:
951
- # If the task is no longer around, it surely doesn't have a cancellation
952
- # pending
953
- return False
954
-
955
-
956
- class TrioBackend(AsyncBackend):
957
- @classmethod
958
- def run(
959
- cls,
960
- func: Callable[[Unpack[PosArgsT]], Awaitable[T_Retval]],
961
- args: tuple[Unpack[PosArgsT]],
962
- kwargs: dict[str, Any],
963
- options: dict[str, Any],
964
- ) -> T_Retval:
965
- return trio.run(func, *args)
966
-
967
- @classmethod
968
- def current_token(cls) -> object:
969
- return trio.lowlevel.current_trio_token()
970
-
971
- @classmethod
972
- def current_time(cls) -> float:
973
- return trio.current_time()
974
-
975
- @classmethod
976
- def cancelled_exception_class(cls) -> type[BaseException]:
977
- return trio.Cancelled
978
-
979
- @classmethod
980
- async def checkpoint(cls) -> None:
981
- await trio.lowlevel.checkpoint()
982
-
983
- @classmethod
984
- async def checkpoint_if_cancelled(cls) -> None:
985
- await trio.lowlevel.checkpoint_if_cancelled()
986
-
987
- @classmethod
988
- async def cancel_shielded_checkpoint(cls) -> None:
989
- await trio.lowlevel.cancel_shielded_checkpoint()
990
-
991
- @classmethod
992
- async def sleep(cls, delay: float) -> None:
993
- await trio.sleep(delay)
994
-
995
- @classmethod
996
- def create_cancel_scope(
997
- cls, *, deadline: float = math.inf, shield: bool = False
998
- ) -> abc.CancelScope:
999
- return CancelScope(deadline=deadline, shield=shield)
1000
-
1001
- @classmethod
1002
- def current_effective_deadline(cls) -> float:
1003
- return trio.current_effective_deadline()
1004
-
1005
- @classmethod
1006
- def create_task_group(cls) -> abc.TaskGroup:
1007
- return TaskGroup()
1008
-
1009
- @classmethod
1010
- def create_event(cls) -> abc.Event:
1011
- return Event()
1012
-
1013
- @classmethod
1014
- def create_lock(cls, *, fast_acquire: bool) -> Lock:
1015
- return Lock(fast_acquire=fast_acquire)
1016
-
1017
- @classmethod
1018
- def create_semaphore(
1019
- cls,
1020
- initial_value: int,
1021
- *,
1022
- max_value: int | None = None,
1023
- fast_acquire: bool = False,
1024
- ) -> abc.Semaphore:
1025
- return Semaphore(initial_value, max_value=max_value, fast_acquire=fast_acquire)
1026
-
1027
- @classmethod
1028
- def create_capacity_limiter(cls, total_tokens: float) -> CapacityLimiter:
1029
- return CapacityLimiter(total_tokens)
1030
-
1031
- @classmethod
1032
- async def run_sync_in_worker_thread(
1033
- cls,
1034
- func: Callable[[Unpack[PosArgsT]], T_Retval],
1035
- args: tuple[Unpack[PosArgsT]],
1036
- abandon_on_cancel: bool = False,
1037
- limiter: abc.CapacityLimiter | None = None,
1038
- ) -> T_Retval:
1039
- def wrapper() -> T_Retval:
1040
- with claim_worker_thread(TrioBackend, token):
1041
- return func(*args)
1042
-
1043
- token = TrioBackend.current_token()
1044
- return await run_sync(
1045
- wrapper,
1046
- abandon_on_cancel=abandon_on_cancel,
1047
- limiter=cast(trio.CapacityLimiter, limiter),
1048
- )
1049
-
1050
- @classmethod
1051
- def check_cancelled(cls) -> None:
1052
- trio.from_thread.check_cancelled()
1053
-
1054
- @classmethod
1055
- def run_async_from_thread(
1056
- cls,
1057
- func: Callable[[Unpack[PosArgsT]], Awaitable[T_Retval]],
1058
- args: tuple[Unpack[PosArgsT]],
1059
- token: object,
1060
- ) -> T_Retval:
1061
- trio_token = cast("trio.lowlevel.TrioToken | None", token)
1062
- try:
1063
- return trio.from_thread.run(func, *args, trio_token=trio_token)
1064
- except trio.RunFinishedError:
1065
- raise RunFinishedError from None
1066
-
1067
- @classmethod
1068
- def run_sync_from_thread(
1069
- cls,
1070
- func: Callable[[Unpack[PosArgsT]], T_Retval],
1071
- args: tuple[Unpack[PosArgsT]],
1072
- token: object,
1073
- ) -> T_Retval:
1074
- trio_token = cast("trio.lowlevel.TrioToken | None", token)
1075
- try:
1076
- return trio.from_thread.run_sync(func, *args, trio_token=trio_token)
1077
- except trio.RunFinishedError:
1078
- raise RunFinishedError from None
1079
-
1080
- @classmethod
1081
- async def open_process(
1082
- cls,
1083
- command: StrOrBytesPath | Sequence[StrOrBytesPath],
1084
- *,
1085
- stdin: int | IO[Any] | None,
1086
- stdout: int | IO[Any] | None,
1087
- stderr: int | IO[Any] | None,
1088
- **kwargs: Any,
1089
- ) -> Process:
1090
- def convert_item(item: StrOrBytesPath) -> str:
1091
- str_or_bytes = os.fspath(item)
1092
- if isinstance(str_or_bytes, str):
1093
- return str_or_bytes
1094
- else:
1095
- return os.fsdecode(str_or_bytes)
1096
-
1097
- if isinstance(command, (str, bytes, PathLike)):
1098
- process = await trio.lowlevel.open_process(
1099
- convert_item(command),
1100
- stdin=stdin,
1101
- stdout=stdout,
1102
- stderr=stderr,
1103
- shell=True,
1104
- **kwargs,
1105
- )
1106
- else:
1107
- process = await trio.lowlevel.open_process(
1108
- [convert_item(item) for item in command],
1109
- stdin=stdin,
1110
- stdout=stdout,
1111
- stderr=stderr,
1112
- shell=False,
1113
- **kwargs,
1114
- )
1115
-
1116
- stdin_stream = SendStreamWrapper(process.stdin) if process.stdin else None
1117
- stdout_stream = ReceiveStreamWrapper(process.stdout) if process.stdout else None
1118
- stderr_stream = ReceiveStreamWrapper(process.stderr) if process.stderr else None
1119
- return Process(process, stdin_stream, stdout_stream, stderr_stream)
1120
-
1121
- @classmethod
1122
- def setup_process_pool_exit_at_shutdown(cls, workers: set[abc.Process]) -> None:
1123
- trio.lowlevel.spawn_system_task(_shutdown_process_pool, workers)
1124
-
1125
- @classmethod
1126
- async def connect_tcp(
1127
- cls, host: str, port: int, local_address: IPSockAddrType | None = None
1128
- ) -> SocketStream:
1129
- family = socket.AF_INET6 if ":" in host else socket.AF_INET
1130
- trio_socket = trio.socket.socket(family)
1131
- trio_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
1132
- if local_address:
1133
- await trio_socket.bind(local_address)
1134
-
1135
- try:
1136
- await trio_socket.connect((host, port))
1137
- except BaseException:
1138
- trio_socket.close()
1139
- raise
1140
-
1141
- return SocketStream(trio_socket)
1142
-
1143
- @classmethod
1144
- async def connect_unix(cls, path: str | bytes) -> abc.UNIXSocketStream:
1145
- trio_socket = trio.socket.socket(socket.AF_UNIX)
1146
- try:
1147
- await trio_socket.connect(path)
1148
- except BaseException:
1149
- trio_socket.close()
1150
- raise
1151
-
1152
- return UNIXSocketStream(trio_socket)
1153
-
1154
- @classmethod
1155
- def create_tcp_listener(cls, sock: socket.socket) -> abc.SocketListener:
1156
- return TCPSocketListener(sock)
1157
-
1158
- @classmethod
1159
- def create_unix_listener(cls, sock: socket.socket) -> abc.SocketListener:
1160
- return UNIXSocketListener(sock)
1161
-
1162
- @classmethod
1163
- async def create_udp_socket(
1164
- cls,
1165
- family: socket.AddressFamily,
1166
- local_address: IPSockAddrType | None,
1167
- remote_address: IPSockAddrType | None,
1168
- reuse_port: bool,
1169
- ) -> UDPSocket | ConnectedUDPSocket:
1170
- trio_socket = trio.socket.socket(family=family, type=socket.SOCK_DGRAM)
1171
-
1172
- if reuse_port:
1173
- trio_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
1174
-
1175
- if local_address:
1176
- await trio_socket.bind(local_address)
1177
-
1178
- if remote_address:
1179
- await trio_socket.connect(remote_address)
1180
- return ConnectedUDPSocket(trio_socket)
1181
- else:
1182
- return UDPSocket(trio_socket)
1183
-
1184
- @classmethod
1185
- @overload
1186
- async def create_unix_datagram_socket(
1187
- cls, raw_socket: socket.socket, remote_path: None
1188
- ) -> abc.UNIXDatagramSocket: ...
1189
-
1190
- @classmethod
1191
- @overload
1192
- async def create_unix_datagram_socket(
1193
- cls, raw_socket: socket.socket, remote_path: str | bytes
1194
- ) -> abc.ConnectedUNIXDatagramSocket: ...
1195
-
1196
- @classmethod
1197
- async def create_unix_datagram_socket(
1198
- cls, raw_socket: socket.socket, remote_path: str | bytes | None
1199
- ) -> abc.UNIXDatagramSocket | abc.ConnectedUNIXDatagramSocket:
1200
- trio_socket = trio.socket.from_stdlib_socket(raw_socket)
1201
-
1202
- if remote_path:
1203
- await trio_socket.connect(remote_path)
1204
- return ConnectedUNIXDatagramSocket(trio_socket)
1205
- else:
1206
- return UNIXDatagramSocket(trio_socket)
1207
-
1208
- @classmethod
1209
- async def getaddrinfo(
1210
- cls,
1211
- host: bytes | str | None,
1212
- port: str | int | None,
1213
- *,
1214
- family: int | AddressFamily = 0,
1215
- type: int | SocketKind = 0,
1216
- proto: int = 0,
1217
- flags: int = 0,
1218
- ) -> Sequence[
1219
- tuple[
1220
- AddressFamily,
1221
- SocketKind,
1222
- int,
1223
- str,
1224
- tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes],
1225
- ]
1226
- ]:
1227
- return await trio.socket.getaddrinfo(host, port, family, type, proto, flags)
1228
-
1229
- @classmethod
1230
- async def getnameinfo(
1231
- cls, sockaddr: IPSockAddrType, flags: int = 0
1232
- ) -> tuple[str, str]:
1233
- return await trio.socket.getnameinfo(sockaddr, flags)
1234
-
1235
- @classmethod
1236
- async def wait_readable(cls, obj: FileDescriptorLike) -> None:
1237
- try:
1238
- await wait_readable(obj)
1239
- except trio.ClosedResourceError as exc:
1240
- raise ClosedResourceError().with_traceback(exc.__traceback__) from None
1241
- except trio.BusyResourceError:
1242
- raise BusyResourceError("reading from") from None
1243
-
1244
- @classmethod
1245
- async def wait_writable(cls, obj: FileDescriptorLike) -> None:
1246
- try:
1247
- await wait_writable(obj)
1248
- except trio.ClosedResourceError as exc:
1249
- raise ClosedResourceError().with_traceback(exc.__traceback__) from None
1250
- except trio.BusyResourceError:
1251
- raise BusyResourceError("writing to") from None
1252
-
1253
- @classmethod
1254
- def notify_closing(cls, obj: FileDescriptorLike) -> None:
1255
- notify_closing(obj)
1256
-
1257
- @classmethod
1258
- async def wrap_listener_socket(cls, sock: socket.socket) -> abc.SocketListener:
1259
- return TCPSocketListener(sock)
1260
-
1261
- @classmethod
1262
- async def wrap_stream_socket(cls, sock: socket.socket) -> SocketStream:
1263
- trio_sock = trio.socket.from_stdlib_socket(sock)
1264
- return SocketStream(trio_sock)
1265
-
1266
- @classmethod
1267
- async def wrap_unix_stream_socket(cls, sock: socket.socket) -> UNIXSocketStream:
1268
- trio_sock = trio.socket.from_stdlib_socket(sock)
1269
- return UNIXSocketStream(trio_sock)
1270
-
1271
- @classmethod
1272
- async def wrap_udp_socket(cls, sock: socket.socket) -> UDPSocket:
1273
- trio_sock = trio.socket.from_stdlib_socket(sock)
1274
- return UDPSocket(trio_sock)
1275
-
1276
- @classmethod
1277
- async def wrap_connected_udp_socket(cls, sock: socket.socket) -> ConnectedUDPSocket:
1278
- trio_sock = trio.socket.from_stdlib_socket(sock)
1279
- return ConnectedUDPSocket(trio_sock)
1280
-
1281
- @classmethod
1282
- async def wrap_unix_datagram_socket(cls, sock: socket.socket) -> UNIXDatagramSocket:
1283
- trio_sock = trio.socket.from_stdlib_socket(sock)
1284
- return UNIXDatagramSocket(trio_sock)
1285
-
1286
- @classmethod
1287
- async def wrap_connected_unix_datagram_socket(
1288
- cls, sock: socket.socket
1289
- ) -> ConnectedUNIXDatagramSocket:
1290
- trio_sock = trio.socket.from_stdlib_socket(sock)
1291
- return ConnectedUNIXDatagramSocket(trio_sock)
1292
-
1293
- @classmethod
1294
- def current_default_thread_limiter(cls) -> CapacityLimiter:
1295
- try:
1296
- return _capacity_limiter_wrapper.get()
1297
- except LookupError:
1298
- limiter = CapacityLimiter(
1299
- original=trio.to_thread.current_default_thread_limiter()
1300
- )
1301
- _capacity_limiter_wrapper.set(limiter)
1302
- return limiter
1303
-
1304
- @classmethod
1305
- def open_signal_receiver(
1306
- cls, *signals: Signals
1307
- ) -> AbstractContextManager[AsyncIterator[Signals]]:
1308
- return _SignalReceiver(signals)
1309
-
1310
- @classmethod
1311
- def get_current_task(cls) -> TaskInfo:
1312
- task = current_task()
1313
- return TrioTaskInfo(task)
1314
-
1315
- @classmethod
1316
- def get_running_tasks(cls) -> Sequence[TaskInfo]:
1317
- root_task = current_root_task()
1318
- assert root_task
1319
- task_infos = [TrioTaskInfo(root_task)]
1320
- nurseries = root_task.child_nurseries
1321
- while nurseries:
1322
- new_nurseries: list[trio.Nursery] = []
1323
- for nursery in nurseries:
1324
- for task in nursery.child_tasks:
1325
- task_infos.append(TrioTaskInfo(task))
1326
- new_nurseries.extend(task.child_nurseries)
1327
-
1328
- nurseries = new_nurseries
1329
-
1330
- return task_infos
1331
-
1332
- @classmethod
1333
- async def wait_all_tasks_blocked(cls) -> None:
1334
- from trio.testing import wait_all_tasks_blocked
1335
-
1336
- await wait_all_tasks_blocked()
1337
-
1338
- @classmethod
1339
- def create_test_runner(cls, options: dict[str, Any]) -> TestRunner:
1340
- return TestRunner(**options)
1341
-
1342
-
1343
- backend_class = TrioBackend
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.venv/lib/python3.12/site-packages/anyio/_core/__init__.py DELETED
File without changes
.venv/lib/python3.12/site-packages/anyio/_core/_asyncio_selector_thread.py DELETED
@@ -1,167 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import asyncio
4
- import socket
5
- import threading
6
- from collections.abc import Callable
7
- from selectors import EVENT_READ, EVENT_WRITE, DefaultSelector
8
- from typing import TYPE_CHECKING, Any
9
-
10
- if TYPE_CHECKING:
11
- from _typeshed import FileDescriptorLike
12
-
13
- _selector_lock = threading.Lock()
14
- _selector: Selector | None = None
15
-
16
-
17
- class Selector:
18
- def __init__(self) -> None:
19
- self._thread = threading.Thread(target=self.run, name="AnyIO socket selector")
20
- self._selector = DefaultSelector()
21
- self._send, self._receive = socket.socketpair()
22
- self._send.setblocking(False)
23
- self._receive.setblocking(False)
24
- # This somewhat reduces the amount of memory wasted queueing up data
25
- # for wakeups. With these settings, maximum number of 1-byte sends
26
- # before getting BlockingIOError:
27
- # Linux 4.8: 6
28
- # macOS (darwin 15.5): 1
29
- # Windows 10: 525347
30
- # Windows you're weird. (And on Windows setting SNDBUF to 0 makes send
31
- # blocking, even on non-blocking sockets, so don't do that.)
32
- self._receive.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 1)
33
- self._send.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 1)
34
- # On Windows this is a TCP socket so this might matter. On other
35
- # platforms this fails b/c AF_UNIX sockets aren't actually TCP.
36
- try:
37
- self._send.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
38
- except OSError:
39
- pass
40
-
41
- self._selector.register(self._receive, EVENT_READ)
42
- self._closed = False
43
-
44
- def start(self) -> None:
45
- self._thread.start()
46
- threading._register_atexit(self._stop) # type: ignore[attr-defined]
47
-
48
- def _stop(self) -> None:
49
- global _selector
50
- self._closed = True
51
- self._notify_self()
52
- self._send.close()
53
- self._thread.join()
54
- self._selector.unregister(self._receive)
55
- self._receive.close()
56
- self._selector.close()
57
- _selector = None
58
- assert not self._selector.get_map(), (
59
- "selector still has registered file descriptors after shutdown"
60
- )
61
-
62
- def _notify_self(self) -> None:
63
- try:
64
- self._send.send(b"\x00")
65
- except BlockingIOError:
66
- pass
67
-
68
- def add_reader(self, fd: FileDescriptorLike, callback: Callable[[], Any]) -> None:
69
- loop = asyncio.get_running_loop()
70
- try:
71
- key = self._selector.get_key(fd)
72
- except KeyError:
73
- self._selector.register(fd, EVENT_READ, {EVENT_READ: (loop, callback)})
74
- else:
75
- if EVENT_READ in key.data:
76
- raise ValueError(
77
- "this file descriptor is already registered for reading"
78
- )
79
-
80
- key.data[EVENT_READ] = loop, callback
81
- self._selector.modify(fd, key.events | EVENT_READ, key.data)
82
-
83
- self._notify_self()
84
-
85
- def add_writer(self, fd: FileDescriptorLike, callback: Callable[[], Any]) -> None:
86
- loop = asyncio.get_running_loop()
87
- try:
88
- key = self._selector.get_key(fd)
89
- except KeyError:
90
- self._selector.register(fd, EVENT_WRITE, {EVENT_WRITE: (loop, callback)})
91
- else:
92
- if EVENT_WRITE in key.data:
93
- raise ValueError(
94
- "this file descriptor is already registered for writing"
95
- )
96
-
97
- key.data[EVENT_WRITE] = loop, callback
98
- self._selector.modify(fd, key.events | EVENT_WRITE, key.data)
99
-
100
- self._notify_self()
101
-
102
- def remove_reader(self, fd: FileDescriptorLike) -> bool:
103
- try:
104
- key = self._selector.get_key(fd)
105
- except KeyError:
106
- return False
107
-
108
- if new_events := key.events ^ EVENT_READ:
109
- del key.data[EVENT_READ]
110
- self._selector.modify(fd, new_events, key.data)
111
- else:
112
- self._selector.unregister(fd)
113
-
114
- return True
115
-
116
- def remove_writer(self, fd: FileDescriptorLike) -> bool:
117
- try:
118
- key = self._selector.get_key(fd)
119
- except KeyError:
120
- return False
121
-
122
- if new_events := key.events ^ EVENT_WRITE:
123
- del key.data[EVENT_WRITE]
124
- self._selector.modify(fd, new_events, key.data)
125
- else:
126
- self._selector.unregister(fd)
127
-
128
- return True
129
-
130
- def run(self) -> None:
131
- while not self._closed:
132
- for key, events in self._selector.select():
133
- if key.fileobj is self._receive:
134
- try:
135
- while self._receive.recv(4096):
136
- pass
137
- except BlockingIOError:
138
- pass
139
-
140
- continue
141
-
142
- if events & EVENT_READ:
143
- loop, callback = key.data[EVENT_READ]
144
- self.remove_reader(key.fd)
145
- try:
146
- loop.call_soon_threadsafe(callback)
147
- except RuntimeError:
148
- pass # the loop was already closed
149
-
150
- if events & EVENT_WRITE:
151
- loop, callback = key.data[EVENT_WRITE]
152
- self.remove_writer(key.fd)
153
- try:
154
- loop.call_soon_threadsafe(callback)
155
- except RuntimeError:
156
- pass # the loop was already closed
157
-
158
-
159
- def get_selector() -> Selector:
160
- global _selector
161
-
162
- with _selector_lock:
163
- if _selector is None:
164
- _selector = Selector()
165
- _selector.start()
166
-
167
- return _selector