shortcutxl 0.3.76 → 0.3.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BINARY-INVENTORY.json +813 -813
- package/CHANGELOG.md +14 -0
- package/dist/ai/models.d.ts +10 -6
- package/dist/ai/models.generated.d.ts +72 -0
- package/dist/ai/models.generated.js +33 -0
- package/dist/ai/models.js +36 -13
- package/dist/ai/providers/anthropic.d.ts +4 -2
- package/dist/ai/providers/anthropic.js +59 -29
- package/dist/ai/providers/azure-openai-responses.d.ts +2 -1
- package/dist/ai/providers/azure-openai-responses.js +4 -20
- package/dist/ai/providers/google-vertex.d.ts +8 -2
- package/dist/ai/providers/google-vertex.js +66 -54
- package/dist/ai/providers/google.js +15 -48
- package/dist/ai/providers/openai-completions.d.ts +4 -1
- package/dist/ai/providers/openai-completions.js +26 -10
- package/dist/ai/providers/openai-reasoning.d.ts +5 -0
- package/dist/ai/providers/openai-reasoning.js +13 -0
- package/dist/ai/providers/openai-responses-shared.js +1 -1
- package/dist/ai/providers/openai-responses.d.ts +6 -2
- package/dist/ai/providers/openai-responses.js +28 -23
- package/dist/ai/providers/simple-options.d.ts +2 -3
- package/dist/ai/providers/simple-options.js +4 -6
- package/dist/ai/types.d.ts +19 -2
- package/dist/app/agent-session-runtime-adapter.js +7 -6
- package/dist/app/agent-session.d.ts +0 -15
- package/dist/app/agent-session.js +0 -37
- package/dist/app/approvals/approval-errors.d.ts +15 -0
- package/dist/app/approvals/approval-errors.js +14 -0
- package/dist/app/approvals/runtime-approval-gates.d.ts +1 -2
- package/dist/app/approvals/tool-approval.d.ts +1 -0
- package/dist/app/approvals/tool-approval.js +11 -23
- package/dist/app/approvals/types.d.ts +0 -14
- package/dist/app/approvals/types.js +0 -2
- package/dist/app/background/tool-summaries.js +0 -2
- package/dist/app/extensions/slash-commands.js +1 -3
- package/dist/app/local/tools/execute-code/executor.d.ts +1 -1
- package/dist/app/local/tools/execute-code/executor.js +20 -10
- package/dist/app/local/tools/execute-code/tool.js +21 -2
- package/dist/app/modes/action/agent.js +4 -5
- package/dist/app/modes/ask/agent.js +4 -6
- package/dist/app/modes/index.js +20 -10
- package/dist/app/modes/installation/agent.js +4 -5
- package/dist/app/modes/manage/agent.js +3 -4
- package/dist/app/modes/manage/prompt.js +1 -2
- package/dist/app/modes/metadata.d.ts +31 -0
- package/dist/app/modes/metadata.js +35 -0
- package/dist/app/modes/plan/agent.js +5 -8
- package/dist/app/modes/plan/prompt.js +3 -3
- package/dist/app/permissions/runtime-approval-flow.d.ts +1 -5
- package/dist/app/permissions/runtime-approval-flow.js +0 -28
- package/dist/app/permissions/tool-gates.d.ts +2 -3
- package/dist/app/permissions/tool-gates.js +3 -81
- package/dist/app/prompts/com-api.js +1 -1
- package/dist/app/prompts/shared-guidelines.js +7 -3
- package/dist/app/providers/google-vertex-gateway.js +4 -51
- package/dist/app/providers/model-registry.d.ts +1 -0
- package/dist/app/providers/model-registry.js +39 -0
- package/dist/app/providers/model-resolver.js +10 -7
- package/dist/app/providers/register-shortcut-provider.js +6 -6
- package/dist/app/providers/shortcut-api-v2-transport.js +4 -0
- package/dist/app/providers/shortcut-llm-proxy-client.d.ts +2 -2
- package/dist/app/providers/shortcut-llm-proxy-client.js +1 -0
- package/dist/app/resources/package-manager.js +2 -123
- package/dist/app/resources/resource-patterns.d.ts +9 -0
- package/dist/app/resources/resource-patterns.js +120 -0
- package/dist/app/session/forked-agent.d.ts +2 -2
- package/dist/app/session/model-manager.js +3 -2
- package/dist/app/session/session-lifecycle.js +3 -2
- package/dist/app/session/session-models.d.ts +2 -0
- package/dist/app/session/session-models.js +14 -6
- package/dist/app/settings-manager.d.ts +3 -3
- package/dist/app/shared/tools/execute-code/mog.d.ts +3 -1
- package/dist/app/shared/tools/execute-code/mog.js +18 -2
- package/dist/app/tools/bash.js +3 -3
- package/dist/app/tools/execute-code/index.d.ts +1 -0
- package/dist/app/tools/execute-code/index.js +3 -1
- package/dist/app/tools/find-ignore-files.d.ts +3 -0
- package/dist/app/tools/find-ignore-files.js +33 -0
- package/dist/app/tools/find.js +2 -21
- package/dist/app/tools/llm-analysis.js +0 -2
- package/dist/app/tools/refresh-context.d.ts +1 -1
- package/dist/app/tools/session-settings/update-session-settings.js +2 -2
- package/dist/app/tools/switch-mode.js +2 -2
- package/dist/app/tools/take-screenshot.js +0 -2
- package/dist/app/tools/task/runner.js +1 -2
- package/dist/app/tools/task/task.d.ts +1 -3
- package/dist/app/tools/task/task.js +20 -40
- package/dist/app/tools/web-search.js +12 -2
- package/dist/autocomplete/core.d.ts +33 -0
- package/dist/autocomplete/core.js +113 -0
- package/dist/{tui → autocomplete}/fuzzy.d.ts +0 -1
- package/dist/{tui → autocomplete}/fuzzy.js +0 -1
- package/dist/{tui/autocomplete.d.ts → autocomplete/index.d.ts} +0 -1
- package/dist/{tui/autocomplete.js → autocomplete/index.js} +62 -158
- package/dist/cli/args.js +1 -1
- package/dist/cli/list-models.js +1 -1
- package/dist/cli.js +26227 -30480
- package/dist/constants.d.ts +0 -2
- package/dist/constants.js +0 -3
- package/dist/contracts/agent-session-store.d.ts +1 -1
- package/dist/contracts/agent-settings.d.ts +1 -0
- package/dist/contracts/agent-settings.js +2 -1
- package/dist/contracts/model-call.d.ts +1 -2
- package/dist/contracts/model-call.js +1 -2
- package/dist/contracts/model-stream.d.ts +1 -0
- package/dist/contracts/model-stream.js +1 -0
- package/dist/contracts/wire.d.ts +10 -7
- package/dist/contracts/wire.js +8 -0
- package/dist/core/agent-engine.js +1 -1
- package/dist/core/core-types.d.ts +1 -21
- package/dist/core/defaults.d.ts +1 -1
- package/dist/core/defaults.js +9 -1
- package/dist/core/prompts/agent-guidelines.d.ts +4 -5
- package/dist/core/prompts/agent-guidelines.js +28 -42
- package/dist/core/session-schema.d.ts +1 -1
- package/dist/embedded-agent/ai-invoke.d.ts +1 -2
- package/dist/embedded-agent/ai-invoke.js +2 -70
- package/dist/embedded-agent/anthropic-messages-transport.d.ts +4 -20
- package/dist/embedded-agent/anthropic-messages-transport.js +23 -786
- package/dist/embedded-agent/bootstrap.js +2 -2
- package/dist/embedded-agent/compose.js +8 -7
- package/dist/embedded-agent/gateway-base-url.d.ts +3 -0
- package/dist/embedded-agent/gateway-base-url.js +35 -0
- package/dist/embedded-agent/google-vertex-transport.d.ts +2 -11
- package/dist/embedded-agent/google-vertex-transport.js +20 -117
- package/dist/embedded-agent/host-runtime-options.d.ts +0 -8
- package/dist/embedded-agent/host-runtime-options.js +10 -2
- package/dist/embedded-agent/host-tools/invoke-llm/contract.d.ts +2 -2
- package/dist/embedded-agent/host-tools/invoke-llm/contract.js +4 -2
- package/dist/embedded-agent/host-tools/sandbox-llm/contract.d.ts +8 -3
- package/dist/embedded-agent/host-tools/sandbox-llm/contract.js +12 -8
- package/dist/embedded-agent/host-tools/sandbox-llm/index.d.ts +1 -1
- package/dist/embedded-agent/host-tools/sandbox-llm/index.js +1 -1
- package/dist/embedded-agent/host-tools/shared/index.d.ts +1 -1
- package/dist/embedded-agent/host-tools/shared/index.js +1 -1
- package/dist/embedded-agent/host-tools/shared/llm-stream-error.d.ts +7 -0
- package/dist/embedded-agent/host-tools/shared/llm-stream-error.js +10 -0
- package/dist/embedded-agent/host-tools/take-screenshot/contract.d.ts +0 -2
- package/dist/embedded-agent/host-tools/take-screenshot/contract.js +1 -3
- package/dist/embedded-agent/host-tools/take-screenshot/index.d.ts +1 -1
- package/dist/embedded-agent/host-tools/take-screenshot/index.js +1 -1
- package/dist/embedded-agent/host-tools/task/agents/clone.js +1 -2
- package/dist/embedded-agent/host-tools/task/contract.js +1 -1
- package/dist/embedded-agent/index.d.ts +3 -4
- package/dist/embedded-agent/index.js +2 -3
- package/dist/embedded-agent/model-selection.d.ts +0 -6
- package/dist/embedded-agent/model-selection.js +15 -8
- package/dist/embedded-agent/openai-completions-transport.d.ts +2 -11
- package/dist/embedded-agent/openai-completions-transport.js +20 -120
- package/dist/embedded-agent/openai-responses-transport.d.ts +2 -11
- package/dist/embedded-agent/openai-responses-transport.js +15 -170
- package/dist/embedded-agent/prompt/build.js +1 -2
- package/dist/embedded-agent/prompt/sections.d.ts +1 -1
- package/dist/embedded-agent/prompt/sections.js +2 -0
- package/dist/embedded-agent/provider-native-request.d.ts +29 -0
- package/dist/embedded-agent/provider-native-request.js +65 -0
- package/dist/embedded-agent/run-stats.d.ts +1 -1
- package/dist/embedded-agent/stream.d.ts +10 -96
- package/dist/embedded-agent/stream.js +31 -556
- package/dist/embedded-agent/suggestions.d.ts +1 -1
- package/dist/embedded-agent/suggestions.js +1 -1
- package/dist/embedded-agent/worker-bridge/host-client.d.ts +7 -0
- package/dist/embedded-agent/worker-bridge/host-client.js +15 -0
- package/dist/embedded-agent/worker-bridge/worker-port.js +17 -1
- package/dist/main.js +18 -14
- package/dist/rpc/index.d.ts +1 -1
- package/dist/rpc/rpc-approval-gates.js +1 -2
- package/dist/rpc/rpc-host.d.ts +4 -0
- package/dist/rpc/rpc-host.js +13 -24
- package/dist/rpc/rpc-types.d.ts +6 -17
- package/dist/shared/platform/open.d.ts +4 -1
- package/dist/shared/platform/open.js +14 -2
- package/dist/shell/approvals/runtime-approval-gates.js +1 -3
- package/dist/shell/components/selectors/model-selector.js +2 -1
- package/dist/shell/components/selectors/session-selector-search.js +1 -1
- package/dist/shell/components/selectors/thinking-selector.js +7 -6
- package/dist/shell/index.d.ts +0 -1
- package/dist/shell/index.js +0 -1
- package/dist/shell/interactive/interactive-mode-options.d.ts +10 -0
- package/dist/shell/interactive/interactive-mode.d.ts +6 -12
- package/dist/shell/interactive/interactive-mode.js +39 -158
- package/dist/shell/interactive/slash-commands.d.ts +0 -34
- package/dist/shell/interactive/slash-commands.js +0 -2
- package/dist/shell/links/local-file-link-input.d.ts +15 -0
- package/dist/shell/links/local-file-link-input.js +38 -0
- package/dist/shell/links/local-file-link.d.ts +7 -0
- package/dist/shell/links/local-file-link.js +35 -0
- package/dist/shell/links/local-file-opener.d.ts +16 -0
- package/dist/shell/links/local-file-opener.js +90 -0
- package/dist/shell/session-client.d.ts +0 -1
- package/dist/shell/session-client.js +0 -6
- package/dist/shell/status/update-check-scheduler.d.ts +30 -0
- package/dist/shell/status/update-check-scheduler.js +71 -0
- package/dist/shell/status/update-reminder-controller.d.ts +22 -0
- package/dist/shell/status/update-reminder-controller.js +40 -0
- package/dist/shell/status/update-reminder.d.ts +6 -0
- package/dist/shell/status/update-reminder.js +4 -0
- package/dist/shell/theme/dark.json +1 -2
- package/dist/shell/theme/light.json +1 -2
- package/dist/shell/theme/runtime.d.ts +2 -3
- package/dist/shell/theme/runtime.js +2 -6
- package/dist/shell/theme/theme-schema.json +1 -6
- package/dist/shortcut-model-catalog.d.ts +7 -2
- package/dist/shortcut-model-catalog.js +134 -10
- package/dist/startup/update-manager.d.ts +6 -6
- package/dist/startup/update-manager.js +23 -38
- package/dist/startup/update-prompt.d.ts +1 -0
- package/dist/startup/update-prompt.js +2 -2
- package/dist/tui/components/editor.d.ts +1 -1
- package/dist/tui/components/editor.js +1 -1
- package/dist/tui/components/markdown.js +15 -6
- package/dist/tui/components/settings-list.js +1 -1
- package/dist/tui/editor-component.d.ts +1 -1
- package/dist/tui/index.d.ts +7 -8
- package/dist/tui/index.js +7 -6
- package/dist/tui/tui.d.ts +2 -0
- package/dist/tui/tui.js +16 -1
- package/dist/tui/utils.d.ts +7 -0
- package/dist/tui/utils.js +58 -8
- package/native-app/main/index.js +3200 -48
- package/native-app/main/{photon_rs-SoVDgheu.js → photon_rs-XkYyYTVA.js} +2 -2
- package/native-app/package.json +1 -1
- package/native-app/preload/index.cjs +2 -0
- package/native-app/renderer/assets/{index-CFc-oZuS.js → index-B4jz6epR.js} +825 -155
- package/native-app/renderer/assets/{index-OhGE0UY4.css → index-C__g36ft.css} +412 -162
- package/native-app/renderer/assets/shortcutagent-DxFsGSkw.png +0 -0
- package/native-app/renderer/index.html +2 -2
- package/package.json +17 -3
- package/skills/add-custom-model/SKILL.md +52 -0
- package/user-docs/dist/index.html +1 -1
- package/user-docs/dist/shortcutxl-docs.pdf +0 -0
- package/xll/ShortcutXL.xll +0 -0
- package/xll/modules/shortcut_xl/_managed.py +26 -7
- package/xll/modules/shortcut_xl/_tracking.py +141 -251
- package/xll/modules/shortcut_xl/api/__init__.py +60 -0
- package/xll/modules/shortcut_xl/api/workbook.py +9 -1
- package/xll/modules/shortcut_xl/api/worksheet.py +4 -1
- package/xll/python/Lib/site-packages/httpx-0.28.1.dist-info/RECORD +1 -1
- package/xll/python/Lib/site-packages/idna-3.18.dist-info/RECORD +1 -1
- package/xll/python/Lib/site-packages/pip/__init__.py +1 -1
- package/xll/python/Lib/site-packages/pip/_internal/build_env/__init__.py +25 -0
- package/xll/python/Lib/site-packages/pip/_internal/build_env/base.py +103 -0
- package/xll/python/Lib/site-packages/pip/_internal/build_env/installer.py +333 -0
- package/xll/python/Lib/site-packages/pip/_internal/build_env/noop.py +42 -0
- package/xll/python/Lib/site-packages/pip/_internal/build_env/venv.py +145 -0
- package/xll/python/Lib/site-packages/pip/_internal/build_env/virtual.py +139 -0
- package/xll/python/Lib/site-packages/pip/_internal/cache.py +4 -1
- package/xll/python/Lib/site-packages/pip/_internal/cli/autocompletion.py +4 -1
- package/xll/python/Lib/site-packages/pip/_internal/cli/base_command.py +11 -14
- package/xll/python/Lib/site-packages/pip/_internal/cli/cmdoptions.py +133 -22
- package/xll/python/Lib/site-packages/pip/_internal/cli/index_command.py +11 -6
- package/xll/python/Lib/site-packages/pip/_internal/cli/main.py +2 -1
- package/xll/python/Lib/site-packages/pip/_internal/cli/main_parser.py +1 -2
- package/xll/python/Lib/site-packages/pip/_internal/cli/parser.py +10 -2
- package/xll/python/Lib/site-packages/pip/_internal/cli/progress_bars.py +2 -2
- package/xll/python/Lib/site-packages/pip/_internal/cli/req_command.py +57 -25
- package/xll/python/Lib/site-packages/pip/_internal/cli/status_codes.py +1 -0
- package/xll/python/Lib/site-packages/pip/_internal/commands/cache.py +7 -6
- package/xll/python/Lib/site-packages/pip/_internal/commands/configuration.py +2 -1
- package/xll/python/Lib/site-packages/pip/_internal/commands/debug.py +4 -5
- package/xll/python/Lib/site-packages/pip/_internal/commands/download.py +4 -0
- package/xll/python/Lib/site-packages/pip/_internal/commands/freeze.py +1 -1
- package/xll/python/Lib/site-packages/pip/_internal/commands/index.py +10 -3
- package/xll/python/Lib/site-packages/pip/_internal/commands/inspect.py +1 -1
- package/xll/python/Lib/site-packages/pip/_internal/commands/install.py +6 -6
- package/xll/python/Lib/site-packages/pip/_internal/commands/list.py +11 -6
- package/xll/python/Lib/site-packages/pip/_internal/commands/lock.py +4 -6
- package/xll/python/Lib/site-packages/pip/_internal/commands/show.py +14 -8
- package/xll/python/Lib/site-packages/pip/_internal/commands/wheel.py +7 -1
- package/xll/python/Lib/site-packages/pip/_internal/configuration.py +2 -3
- package/xll/python/Lib/site-packages/pip/_internal/distributions/base.py +5 -3
- package/xll/python/Lib/site-packages/pip/_internal/distributions/installed.py +3 -2
- package/xll/python/Lib/site-packages/pip/_internal/distributions/sdist.py +45 -20
- package/xll/python/Lib/site-packages/pip/_internal/distributions/wheel.py +3 -2
- package/xll/python/Lib/site-packages/pip/_internal/exceptions.py +174 -0
- package/xll/python/Lib/site-packages/pip/_internal/index/collector.py +70 -48
- package/xll/python/Lib/site-packages/pip/_internal/index/package_finder.py +46 -7
- package/xll/python/Lib/site-packages/pip/_internal/index/sources.py +1 -2
- package/xll/python/Lib/site-packages/pip/_internal/locations/_sysconfig.py +1 -1
- package/xll/python/Lib/site-packages/pip/_internal/locations/base.py +1 -1
- package/xll/python/Lib/site-packages/pip/_internal/metadata/base.py +10 -5
- package/xll/python/Lib/site-packages/pip/_internal/metadata/importlib/_dists.py +1 -1
- package/xll/python/Lib/site-packages/pip/_internal/metadata/importlib/_envs.py +8 -3
- package/xll/python/Lib/site-packages/pip/_internal/models/candidate.py +5 -1
- package/xll/python/Lib/site-packages/pip/_internal/models/link.py +53 -13
- package/xll/python/Lib/site-packages/pip/_internal/network/auth.py +38 -21
- package/xll/python/Lib/site-packages/pip/_internal/network/cache.py +2 -2
- package/xll/python/Lib/site-packages/pip/_internal/network/download.py +58 -11
- package/xll/python/Lib/site-packages/pip/_internal/network/session.py +35 -40
- package/xll/python/Lib/site-packages/pip/_internal/network/utils.py +109 -1
- package/xll/python/Lib/site-packages/pip/_internal/operations/check.py +2 -3
- package/xll/python/Lib/site-packages/pip/_internal/operations/install/wheel.py +23 -18
- package/xll/python/Lib/site-packages/pip/_internal/operations/prepare.py +152 -7
- package/xll/python/Lib/site-packages/pip/_internal/req/__init__.py +2 -0
- package/xll/python/Lib/site-packages/pip/_internal/req/constructors.py +54 -69
- package/xll/python/Lib/site-packages/pip/_internal/req/req_file.py +6 -6
- package/xll/python/Lib/site-packages/pip/_internal/req/req_install.py +25 -21
- package/xll/python/Lib/site-packages/pip/_internal/req/req_uninstall.py +13 -8
- package/xll/python/Lib/site-packages/pip/_internal/resolution/base.py +2 -2
- package/xll/python/Lib/site-packages/pip/_internal/resolution/legacy/resolver.py +2 -2
- package/xll/python/Lib/site-packages/pip/_internal/resolution/resolvelib/base.py +1 -1
- package/xll/python/Lib/site-packages/pip/_internal/resolution/resolvelib/candidates.py +0 -1
- package/xll/python/Lib/site-packages/pip/_internal/resolution/resolvelib/factory.py +39 -52
- package/xll/python/Lib/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py +3 -3
- package/xll/python/Lib/site-packages/pip/_internal/resolution/resolvelib/provider.py +3 -0
- package/xll/python/Lib/site-packages/pip/_internal/resolution/resolvelib/resolver.py +9 -0
- package/xll/python/Lib/site-packages/pip/_internal/utils/compat.py +15 -9
- package/xll/python/Lib/site-packages/pip/_internal/utils/deprecation.py +6 -1
- package/xll/python/Lib/site-packages/pip/_internal/utils/filesystem.py +2 -2
- package/xll/python/Lib/site-packages/pip/_internal/utils/logging.py +11 -3
- package/xll/python/Lib/site-packages/pip/_internal/utils/misc.py +48 -4
- package/xll/python/Lib/site-packages/pip/_internal/utils/pylock.py +18 -2
- package/xll/python/Lib/site-packages/pip/_internal/utils/retry.py +2 -1
- package/xll/python/Lib/site-packages/pip/_internal/utils/subprocess.py +4 -3
- package/xll/python/Lib/site-packages/pip/_internal/utils/temp_dir.py +1 -2
- package/xll/python/Lib/site-packages/pip/_internal/utils/unpacking.py +30 -4
- package/xll/python/Lib/site-packages/pip/_internal/utils/urls.py +5 -2
- package/xll/python/Lib/site-packages/pip/_internal/utils/virtualenv.py +2 -36
- package/xll/python/Lib/site-packages/pip/_internal/vcs/git.py +8 -5
- package/xll/python/Lib/site-packages/pip/_internal/vcs/versioncontrol.py +1 -2
- package/xll/python/Lib/site-packages/pip/_internal/wheel_builder.py +5 -1
- package/xll/python/Lib/site-packages/pip/_vendor/bom.cdx.json +231 -0
- package/xll/python/Lib/site-packages/pip/_vendor/certifi/__init__.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/certifi/cacert.pem +0 -631
- package/xll/python/Lib/site-packages/pip/_vendor/distlib/__init__.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/distlib/compat.py +34 -64
- package/xll/python/Lib/site-packages/pip/_vendor/distlib/resources.py +28 -14
- package/xll/python/Lib/site-packages/pip/_vendor/distlib/scripts.py +7 -3
- package/xll/python/Lib/site-packages/pip/_vendor/distlib/util.py +48 -11
- package/xll/python/Lib/site-packages/pip/_vendor/idna/LICENSE.md +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/idna/__main__.py +6 -0
- package/xll/python/Lib/site-packages/pip/_vendor/idna/cli.py +128 -0
- package/xll/python/Lib/site-packages/pip/_vendor/idna/codec.py +50 -13
- package/xll/python/Lib/site-packages/pip/_vendor/idna/compat.py +26 -0
- package/xll/python/Lib/site-packages/pip/_vendor/idna/core.py +352 -141
- package/xll/python/Lib/site-packages/pip/_vendor/idna/idnadata.py +571 -2983
- package/xll/python/Lib/site-packages/pip/_vendor/idna/intranges.py +5 -7
- package/xll/python/Lib/site-packages/pip/_vendor/idna/package_data.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/idna/uts46data.py +16887 -8832
- package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/__init__.py +352 -66
- package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/__main__.py +11 -0
- package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/_xdg.py +171 -0
- package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/android.py +92 -41
- package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/api.py +213 -49
- package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/macos.py +128 -51
- package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/unix.py +176 -127
- package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/version.py +8 -18
- package/xll/python/Lib/site-packages/pip/_vendor/platformdirs/windows.py +185 -68
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/__init__.py +2 -2
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/__main__.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/console.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/filter.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/filters/__init__.py +10 -8
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/formatter.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/formatters/__init__.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/lexer.py +7 -5
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/lexers/__init__.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/lexers/_mapping.py +9 -8
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/lexers/python.py +35 -32
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/modeline.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/plugin.py +3 -1
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/regexopt.py +13 -2
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/scanner.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/sphinxext.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/style.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/styles/__init__.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/token.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/unistring.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/pygments/util.py +2 -2
- package/xll/python/Lib/site-packages/pip/_vendor/requests/__init__.py +52 -16
- package/xll/python/Lib/site-packages/pip/_vendor/requests/__version__.py +2 -2
- package/xll/python/Lib/site-packages/pip/_vendor/requests/_internal_utils.py +2 -2
- package/xll/python/Lib/site-packages/pip/_vendor/requests/_types.py +183 -0
- package/xll/python/Lib/site-packages/pip/_vendor/requests/adapters.py +101 -50
- package/xll/python/Lib/site-packages/pip/_vendor/requests/api.py +31 -8
- package/xll/python/Lib/site-packages/pip/_vendor/requests/auth.py +80 -40
- package/xll/python/Lib/site-packages/pip/_vendor/requests/compat.py +9 -3
- package/xll/python/Lib/site-packages/pip/_vendor/requests/cookies.py +143 -79
- package/xll/python/Lib/site-packages/pip/_vendor/requests/exceptions.py +15 -5
- package/xll/python/Lib/site-packages/pip/_vendor/requests/help.py +13 -10
- package/xll/python/Lib/site-packages/pip/_vendor/requests/hooks.py +23 -9
- package/xll/python/Lib/site-packages/pip/_vendor/requests/models.py +265 -126
- package/xll/python/Lib/site-packages/pip/_vendor/requests/py.typed +0 -0
- package/xll/python/Lib/site-packages/pip/_vendor/requests/sessions.py +164 -78
- package/xll/python/Lib/site-packages/pip/_vendor/requests/status_codes.py +2 -2
- package/xll/python/Lib/site-packages/pip/_vendor/requests/structures.py +51 -20
- package/xll/python/Lib/site-packages/pip/_vendor/requests/utils.py +161 -89
- package/xll/python/Lib/site-packages/pip/_vendor/tomli/__init__.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/tomli/_parser.py +9 -4
- package/xll/python/Lib/site-packages/pip/_vendor/tomli/_re.py +13 -9
- package/xll/python/Lib/site-packages/pip/_vendor/urllib3/_base_connection.py +3 -1
- package/xll/python/Lib/site-packages/pip/_vendor/urllib3/_collections.py +0 -1
- package/xll/python/Lib/site-packages/pip/_vendor/urllib3/_version.py +8 -18
- package/xll/python/Lib/site-packages/pip/_vendor/urllib3/connection.py +4 -4
- package/xll/python/Lib/site-packages/pip/_vendor/urllib3/connectionpool.py +23 -10
- package/xll/python/Lib/site-packages/pip/_vendor/urllib3/contrib/emscripten/response.py +5 -1
- package/xll/python/Lib/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py +7 -8
- package/xll/python/Lib/site-packages/pip/_vendor/urllib3/contrib/socks.py +1 -1
- package/xll/python/Lib/site-packages/pip/_vendor/urllib3/exceptions.py +2 -2
- package/xll/python/Lib/site-packages/pip/_vendor/urllib3/fields.py +14 -14
- package/xll/python/Lib/site-packages/pip/_vendor/urllib3/poolmanager.py +8 -6
- package/xll/python/Lib/site-packages/pip/_vendor/urllib3/response.py +35 -22
- package/xll/python/Lib/site-packages/pip/_vendor/urllib3/util/retry.py +8 -0
- package/xll/python/Lib/site-packages/pip/_vendor/urllib3/util/ssl_.py +11 -61
- package/xll/python/Lib/site-packages/pip/_vendor/urllib3/util/ssl_match_hostname.py +5 -11
- package/xll/python/Lib/site-packages/pip/_vendor/vendor.txt +8 -8
- package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/METADATA +3 -2
- package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/RECORD +208 -188
- package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/AUTHORS.txt +20 -0
- package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/idna/LICENSE.md +1 -1
- package/xll/python/Lib/site-packages/pywin32-311.dist-info/RECORD +2 -2
- package/xll/python/Scripts/httpx.exe +0 -0
- package/xll/python/Scripts/idna.exe +0 -0
- package/xll/python/Scripts/pip.exe +0 -0
- package/xll/python/Scripts/pip3.13.exe +0 -0
- package/xll/python/Scripts/pip3.exe +0 -0
- package/xll/python/Scripts/pywin32_postinstall.exe +0 -0
- package/xll/python/Scripts/pywin32_testall.exe +0 -0
- package/dist/app/collab/awareness.d.ts +0 -32
- package/dist/app/collab/awareness.js +0 -52
- package/dist/app/collab/collab-client.d.ts +0 -37
- package/dist/app/collab/collab-client.js +0 -208
- package/dist/app/collab/collab-manager.d.ts +0 -91
- package/dist/app/collab/collab-manager.js +0 -218
- package/dist/app/collab/collab-sync.d.ts +0 -62
- package/dist/app/collab/collab-sync.js +0 -215
- package/dist/app/collab/index.d.ts +0 -9
- package/dist/app/collab/index.js +0 -6
- package/dist/app/collab/super-fight.d.ts +0 -90
- package/dist/app/collab/super-fight.js +0 -310
- package/dist/app/collab/sync-bridge.d.ts +0 -35
- package/dist/app/collab/sync-bridge.js +0 -109
- package/dist/app/collab/types.d.ts +0 -75
- package/dist/app/collab/types.js +0 -5
- package/dist/embedded-agent/ai-content.d.ts +0 -52
- package/dist/embedded-agent/ai-content.js +0 -101
- package/dist/embedded-agent/host-tools/shared/llm-stream.d.ts +0 -31
- package/dist/embedded-agent/host-tools/shared/llm-stream.js +0 -136
- package/dist/embedded-agent/model-call-orchestrator.d.ts +0 -22
- package/dist/embedded-agent/model-call-orchestrator.js +0 -22
- package/dist/embedded-agent/stream-errors.d.ts +0 -10
- package/dist/embedded-agent/stream-errors.js +0 -73
- package/dist/embedded-agent/stream-message-state.d.ts +0 -14
- package/dist/embedded-agent/stream-message-state.js +0 -271
- package/dist/embedded-agent/stream-sse.d.ts +0 -78
- package/dist/embedded-agent/stream-sse.js +0 -73
- package/dist/shell/approvals/task-spawn-approval.d.ts +0 -20
- package/dist/shell/approvals/task-spawn-approval.js +0 -93
- package/dist/shell/interactive/collab-command.d.ts +0 -9
- package/dist/shell/interactive/collab-command.js +0 -115
- package/dist/shell/interactive/super-fight-ui.d.ts +0 -80
- package/dist/shell/interactive/super-fight-ui.js +0 -484
- package/dist/shell/status/collab-status.d.ts +0 -18
- package/dist/shell/status/collab-status.js +0 -46
- package/xll/python/Lib/site-packages/pip/_internal/build_env.py +0 -606
- /package/dist/{tui → autocomplete}/skill-autocomplete.js +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/INSTALLER +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/REQUESTED +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/WHEEL +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/entry_points.txt +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/LICENSE.txt +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/cachecontrol/LICENSE.txt +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/certifi/LICENSE +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/distlib/LICENSE.txt +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/distro/LICENSE +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/msgpack/COPYING +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/packaging/LICENSE +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/packaging/LICENSE.APACHE +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/packaging/LICENSE.BSD +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/pkg_resources/LICENSE +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/platformdirs/LICENSE +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/pygments/LICENSE +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/pyproject_hooks/LICENSE +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/requests/LICENSE +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/resolvelib/LICENSE +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/rich/LICENSE +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/tomli/LICENSE +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/tomli_w/LICENSE +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/truststore/LICENSE +0 -0
- /package/xll/python/Lib/site-packages/{pip-26.1.2.dist-info → pip-26.2.dist-info}/licenses/src/pip/_vendor/urllib3/LICENSE.txt +0 -0
|
@@ -5,13 +5,24 @@ requests.models
|
|
|
5
5
|
This module contains the primary objects that power Requests.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
8
10
|
import datetime
|
|
9
11
|
|
|
10
12
|
# Import encoding now, to avoid implicit import later.
|
|
11
13
|
# Implicit import within threads may cause LookupError when standard library is in a ZIP,
|
|
12
14
|
# such as in Embedded Python. See https://github.com/psf/requests/issues/3578.
|
|
13
|
-
import encodings.idna # noqa: F401
|
|
15
|
+
import encodings.idna # noqa: F401 # type: ignore[reportUnusedImport]
|
|
16
|
+
from collections.abc import Callable, Generator, Iterable, Iterator, Mapping
|
|
14
17
|
from io import UnsupportedOperation
|
|
18
|
+
from typing import (
|
|
19
|
+
TYPE_CHECKING,
|
|
20
|
+
Any,
|
|
21
|
+
Final,
|
|
22
|
+
Literal,
|
|
23
|
+
cast,
|
|
24
|
+
overload,
|
|
25
|
+
)
|
|
15
26
|
|
|
16
27
|
from pip._vendor.urllib3.exceptions import (
|
|
17
28
|
DecodeError,
|
|
@@ -25,11 +36,10 @@ from pip._vendor.urllib3.filepost import encode_multipart_formdata
|
|
|
25
36
|
from pip._vendor.urllib3.util import parse_url
|
|
26
37
|
|
|
27
38
|
from ._internal_utils import to_native_string, unicode_is_ascii
|
|
39
|
+
from ._types import SupportsRead as _SupportsRead
|
|
28
40
|
from .auth import HTTPBasicAuth
|
|
29
41
|
from .compat import (
|
|
30
|
-
Callable,
|
|
31
42
|
JSONDecodeError,
|
|
32
|
-
Mapping,
|
|
33
43
|
basestring,
|
|
34
44
|
builtin_str,
|
|
35
45
|
chardet,
|
|
@@ -39,7 +49,11 @@ from .compat import (
|
|
|
39
49
|
urlunparse,
|
|
40
50
|
)
|
|
41
51
|
from .compat import json as complexjson
|
|
42
|
-
from .cookies import
|
|
52
|
+
from .cookies import (
|
|
53
|
+
_copy_cookie_jar, # type: ignore[reportPrivateUsage]
|
|
54
|
+
cookiejar_from_dict,
|
|
55
|
+
get_cookie_header,
|
|
56
|
+
)
|
|
43
57
|
from .exceptions import (
|
|
44
58
|
ChunkedEncodingError,
|
|
45
59
|
ConnectionError,
|
|
@@ -68,9 +82,18 @@ from .utils import (
|
|
|
68
82
|
to_key_val_list,
|
|
69
83
|
)
|
|
70
84
|
|
|
85
|
+
if TYPE_CHECKING:
|
|
86
|
+
from http.cookiejar import CookieJar
|
|
87
|
+
|
|
88
|
+
from typing_extensions import Self
|
|
89
|
+
|
|
90
|
+
from . import _types as _t
|
|
91
|
+
from .adapters import HTTPAdapter
|
|
92
|
+
from .cookies import RequestsCookieJar
|
|
93
|
+
|
|
71
94
|
#: The set of HTTP status codes that indicate an automatically
|
|
72
95
|
#: processable redirect.
|
|
73
|
-
REDIRECT_STATI = (
|
|
96
|
+
REDIRECT_STATI: Final[tuple[int, ...]] = ( # type: ignore[assignment]
|
|
74
97
|
codes.moved, # 301
|
|
75
98
|
codes.found, # 302
|
|
76
99
|
codes.other, # 303
|
|
@@ -78,19 +101,21 @@ REDIRECT_STATI = (
|
|
|
78
101
|
codes.permanent_redirect, # 308
|
|
79
102
|
)
|
|
80
103
|
|
|
81
|
-
DEFAULT_REDIRECT_LIMIT = 30
|
|
82
|
-
CONTENT_CHUNK_SIZE = 10 * 1024
|
|
83
|
-
ITER_CHUNK_SIZE = 512
|
|
104
|
+
DEFAULT_REDIRECT_LIMIT: int = 30
|
|
105
|
+
CONTENT_CHUNK_SIZE: int = 10 * 1024
|
|
106
|
+
ITER_CHUNK_SIZE: int = 512
|
|
84
107
|
|
|
85
108
|
|
|
86
109
|
class RequestEncodingMixin:
|
|
110
|
+
url: str | None
|
|
111
|
+
|
|
87
112
|
@property
|
|
88
|
-
def path_url(self):
|
|
113
|
+
def path_url(self) -> str:
|
|
89
114
|
"""Build the path URL to use."""
|
|
90
115
|
|
|
91
|
-
url = []
|
|
116
|
+
url: list[str] = []
|
|
92
117
|
|
|
93
|
-
p = urlsplit(self.url)
|
|
118
|
+
p = urlsplit(cast(str, self.url))
|
|
94
119
|
|
|
95
120
|
path = p.path
|
|
96
121
|
if not path:
|
|
@@ -105,8 +130,28 @@ class RequestEncodingMixin:
|
|
|
105
130
|
|
|
106
131
|
return "".join(url)
|
|
107
132
|
|
|
133
|
+
@overload
|
|
134
|
+
@staticmethod
|
|
135
|
+
def _encode_params(data: str) -> str: ...
|
|
136
|
+
|
|
137
|
+
@overload
|
|
108
138
|
@staticmethod
|
|
109
|
-
def _encode_params(data):
|
|
139
|
+
def _encode_params(data: bytes) -> bytes: ...
|
|
140
|
+
|
|
141
|
+
@overload
|
|
142
|
+
@staticmethod
|
|
143
|
+
def _encode_params(
|
|
144
|
+
data: _t.SupportsRead[str | bytes],
|
|
145
|
+
) -> _t.SupportsRead[str | bytes]: ...
|
|
146
|
+
|
|
147
|
+
@overload
|
|
148
|
+
@staticmethod
|
|
149
|
+
def _encode_params(data: _t.KVDataType) -> str: ...
|
|
150
|
+
|
|
151
|
+
@staticmethod
|
|
152
|
+
def _encode_params(
|
|
153
|
+
data: _t.EncodableDataType,
|
|
154
|
+
) -> str | bytes | _t.SupportsRead[str | bytes]:
|
|
110
155
|
"""Encode parameters in a piece of data.
|
|
111
156
|
|
|
112
157
|
Will successfully encode parameters when passed as a dict or a list of
|
|
@@ -116,10 +161,10 @@ class RequestEncodingMixin:
|
|
|
116
161
|
|
|
117
162
|
if isinstance(data, (str, bytes)):
|
|
118
163
|
return data
|
|
119
|
-
elif
|
|
164
|
+
elif isinstance(data, _SupportsRead):
|
|
120
165
|
return data
|
|
121
166
|
elif hasattr(data, "__iter__"):
|
|
122
|
-
result = []
|
|
167
|
+
result: list[tuple[bytes, bytes]] = []
|
|
123
168
|
for k, vs in to_key_val_list(data):
|
|
124
169
|
if isinstance(vs, basestring) or not hasattr(vs, "__iter__"):
|
|
125
170
|
vs = [vs]
|
|
@@ -133,10 +178,12 @@ class RequestEncodingMixin:
|
|
|
133
178
|
)
|
|
134
179
|
return urlencode(result, doseq=True)
|
|
135
180
|
else:
|
|
136
|
-
return data
|
|
181
|
+
return data # type: ignore[return-value] # unreachable for valid _t.DataType
|
|
137
182
|
|
|
138
183
|
@staticmethod
|
|
139
|
-
def _encode_files(
|
|
184
|
+
def _encode_files(
|
|
185
|
+
files: _t.FilesType, data: _t.RawDataType | None
|
|
186
|
+
) -> tuple[bytes, str]:
|
|
140
187
|
"""Build the body for a multipart/form-data request.
|
|
141
188
|
|
|
142
189
|
Will successfully encode files when passed as a dict or a list of
|
|
@@ -150,7 +197,7 @@ class RequestEncodingMixin:
|
|
|
150
197
|
elif isinstance(data, basestring):
|
|
151
198
|
raise ValueError("Data must not be a string.")
|
|
152
199
|
|
|
153
|
-
new_fields = []
|
|
200
|
+
new_fields: list[RequestField | tuple[str, bytes]] = []
|
|
154
201
|
fields = to_key_val_list(data or {})
|
|
155
202
|
files = to_key_val_list(files or {})
|
|
156
203
|
|
|
@@ -189,9 +236,9 @@ class RequestEncodingMixin:
|
|
|
189
236
|
|
|
190
237
|
if isinstance(fp, (str, bytes, bytearray)):
|
|
191
238
|
fdata = fp
|
|
192
|
-
elif
|
|
239
|
+
elif isinstance(fp, _SupportsRead): # type: ignore[reportUnnecessaryIsInstance] # defensive check for untyped callers
|
|
193
240
|
fdata = fp.read()
|
|
194
|
-
elif fp is None:
|
|
241
|
+
elif fp is None: # type: ignore[reportUnnecessaryComparison] # defensive check for untyped callers
|
|
195
242
|
continue
|
|
196
243
|
else:
|
|
197
244
|
fdata = fp
|
|
@@ -206,7 +253,11 @@ class RequestEncodingMixin:
|
|
|
206
253
|
|
|
207
254
|
|
|
208
255
|
class RequestHooksMixin:
|
|
209
|
-
|
|
256
|
+
hooks: dict[str, list[_t.HookType]]
|
|
257
|
+
|
|
258
|
+
def register_hook(
|
|
259
|
+
self, event: str, hook: Iterable[_t.HookType] | _t.HookType
|
|
260
|
+
) -> None:
|
|
210
261
|
"""Properly register a hook."""
|
|
211
262
|
|
|
212
263
|
if event not in self.hooks:
|
|
@@ -215,9 +266,9 @@ class RequestHooksMixin:
|
|
|
215
266
|
if isinstance(hook, Callable):
|
|
216
267
|
self.hooks[event].append(hook)
|
|
217
268
|
elif hasattr(hook, "__iter__"):
|
|
218
|
-
self.hooks[event].extend(h for h in hook if isinstance(h, Callable))
|
|
269
|
+
self.hooks[event].extend(h for h in hook if isinstance(h, Callable)) # type: ignore[reportUnnecessaryIsInstance] # defensive runtime filter
|
|
219
270
|
|
|
220
|
-
def deregister_hook(self, event, hook):
|
|
271
|
+
def deregister_hook(self, event: str, hook: _t.HookType) -> bool:
|
|
221
272
|
"""Deregister a previously registered hook.
|
|
222
273
|
Returns True if the hook existed, False if not.
|
|
223
274
|
"""
|
|
@@ -257,19 +308,29 @@ class Request(RequestHooksMixin):
|
|
|
257
308
|
<PreparedRequest [GET]>
|
|
258
309
|
"""
|
|
259
310
|
|
|
311
|
+
method: str | None
|
|
312
|
+
url: _t.UriType | None
|
|
313
|
+
headers: Mapping[str, str | bytes]
|
|
314
|
+
files: _t.FilesType
|
|
315
|
+
data: _t.DataType
|
|
316
|
+
json: _t.JsonType
|
|
317
|
+
params: _t.ParamsType
|
|
318
|
+
auth: _t.AuthType
|
|
319
|
+
cookies: RequestsCookieJar | CookieJar | dict[str, str] | None
|
|
320
|
+
|
|
260
321
|
def __init__(
|
|
261
322
|
self,
|
|
262
|
-
method=None,
|
|
263
|
-
url=None,
|
|
264
|
-
headers=None,
|
|
265
|
-
files=None,
|
|
266
|
-
data=None,
|
|
267
|
-
params=None,
|
|
268
|
-
auth=None,
|
|
269
|
-
cookies=None,
|
|
270
|
-
hooks=None,
|
|
271
|
-
json=None,
|
|
272
|
-
):
|
|
323
|
+
method: str | None = None,
|
|
324
|
+
url: _t.UriType | None = None,
|
|
325
|
+
headers: _t.HeadersType = None,
|
|
326
|
+
files: _t.FilesType = None,
|
|
327
|
+
data: _t.DataType = None,
|
|
328
|
+
params: _t.ParamsType = None,
|
|
329
|
+
auth: _t.AuthType = None,
|
|
330
|
+
cookies: RequestsCookieJar | CookieJar | dict[str, str] | None = None,
|
|
331
|
+
hooks: _t.HooksInputType | None = None,
|
|
332
|
+
json: _t.JsonType = None,
|
|
333
|
+
) -> None:
|
|
273
334
|
# Default empty dicts for dict params.
|
|
274
335
|
data = [] if data is None else data
|
|
275
336
|
files = [] if files is None else files
|
|
@@ -291,10 +352,10 @@ class Request(RequestHooksMixin):
|
|
|
291
352
|
self.auth = auth
|
|
292
353
|
self.cookies = cookies
|
|
293
354
|
|
|
294
|
-
def __repr__(self):
|
|
355
|
+
def __repr__(self) -> str:
|
|
295
356
|
return f"<Request [{self.method}]>"
|
|
296
357
|
|
|
297
|
-
def prepare(self):
|
|
358
|
+
def prepare(self) -> PreparedRequest:
|
|
298
359
|
"""Constructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it."""
|
|
299
360
|
p = PreparedRequest()
|
|
300
361
|
p.prepare(
|
|
@@ -333,13 +394,21 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
|
|
333
394
|
<Response [200]>
|
|
334
395
|
"""
|
|
335
396
|
|
|
336
|
-
|
|
397
|
+
method: str | None
|
|
398
|
+
url: str | None
|
|
399
|
+
headers: CaseInsensitiveDict[str | bytes]
|
|
400
|
+
_cookies: RequestsCookieJar | CookieJar | None
|
|
401
|
+
body: _t.BodyType
|
|
402
|
+
hooks: dict[str, list[_t.HookType]]
|
|
403
|
+
_body_position: int | object | None
|
|
404
|
+
|
|
405
|
+
def __init__(self) -> None:
|
|
337
406
|
#: HTTP verb to send to the server.
|
|
338
407
|
self.method = None
|
|
339
408
|
#: HTTP URL to send the request to.
|
|
340
409
|
self.url = None
|
|
341
410
|
#: dictionary of HTTP headers.
|
|
342
|
-
self.headers = None
|
|
411
|
+
self.headers = None # type: ignore[assignment]
|
|
343
412
|
# The `CookieJar` used to create the Cookie header will be stored here
|
|
344
413
|
# after prepare_cookies is called
|
|
345
414
|
self._cookies = None
|
|
@@ -352,19 +421,20 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
|
|
352
421
|
|
|
353
422
|
def prepare(
|
|
354
423
|
self,
|
|
355
|
-
method=None,
|
|
356
|
-
url=None,
|
|
357
|
-
headers=None,
|
|
358
|
-
files=None,
|
|
359
|
-
data=None,
|
|
360
|
-
params=None,
|
|
361
|
-
auth=None,
|
|
362
|
-
cookies=None,
|
|
363
|
-
hooks=None,
|
|
364
|
-
json=None,
|
|
365
|
-
):
|
|
424
|
+
method: str | None = None,
|
|
425
|
+
url: _t.UriType | None = None,
|
|
426
|
+
headers: Mapping[str, str | bytes] | None = None,
|
|
427
|
+
files: _t.FilesType = None,
|
|
428
|
+
data: _t.DataType = None,
|
|
429
|
+
params: _t.ParamsType = None,
|
|
430
|
+
auth: _t.AuthType = None,
|
|
431
|
+
cookies: RequestsCookieJar | CookieJar | dict[str, str] | None = None,
|
|
432
|
+
hooks: _t.HooksInputType | None = None,
|
|
433
|
+
json: _t.JsonType = None,
|
|
434
|
+
) -> None:
|
|
366
435
|
"""Prepares the entire request with the given parameters."""
|
|
367
436
|
|
|
437
|
+
url = cast("_t.UriType", url)
|
|
368
438
|
self.prepare_method(method)
|
|
369
439
|
self.prepare_url(url, params)
|
|
370
440
|
self.prepare_headers(headers)
|
|
@@ -378,28 +448,28 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
|
|
378
448
|
# This MUST go after prepare_auth. Authenticators could add a hook
|
|
379
449
|
self.prepare_hooks(hooks)
|
|
380
450
|
|
|
381
|
-
def __repr__(self):
|
|
451
|
+
def __repr__(self) -> str:
|
|
382
452
|
return f"<PreparedRequest [{self.method}]>"
|
|
383
453
|
|
|
384
|
-
def copy(self):
|
|
454
|
+
def copy(self) -> PreparedRequest:
|
|
385
455
|
p = PreparedRequest()
|
|
386
456
|
p.method = self.method
|
|
387
457
|
p.url = self.url
|
|
388
|
-
p.headers = self.headers.copy() if self.headers is not None else None
|
|
458
|
+
p.headers = self.headers.copy() if self.headers is not None else None # type: ignore[assignment]
|
|
389
459
|
p._cookies = _copy_cookie_jar(self._cookies)
|
|
390
460
|
p.body = self.body
|
|
391
461
|
p.hooks = self.hooks
|
|
392
462
|
p._body_position = self._body_position
|
|
393
463
|
return p
|
|
394
464
|
|
|
395
|
-
def prepare_method(self, method):
|
|
465
|
+
def prepare_method(self, method: str | None) -> None:
|
|
396
466
|
"""Prepares the given HTTP method."""
|
|
397
467
|
self.method = method
|
|
398
468
|
if self.method is not None:
|
|
399
469
|
self.method = to_native_string(self.method.upper())
|
|
400
470
|
|
|
401
471
|
@staticmethod
|
|
402
|
-
def _get_idna_encoded_host(host):
|
|
472
|
+
def _get_idna_encoded_host(host: str) -> str:
|
|
403
473
|
from pip._vendor import idna
|
|
404
474
|
|
|
405
475
|
try:
|
|
@@ -408,7 +478,11 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
|
|
408
478
|
raise UnicodeError
|
|
409
479
|
return host
|
|
410
480
|
|
|
411
|
-
def prepare_url(
|
|
481
|
+
def prepare_url(
|
|
482
|
+
self,
|
|
483
|
+
url: _t.UriType,
|
|
484
|
+
params: _t.ParamsType,
|
|
485
|
+
) -> None:
|
|
412
486
|
"""Prepares the given HTTP URL."""
|
|
413
487
|
#: Accept objects that have string representations.
|
|
414
488
|
#: We're unable to blindly call unicode/str functions
|
|
@@ -472,17 +546,21 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
|
|
472
546
|
if isinstance(params, (str, bytes)):
|
|
473
547
|
params = to_native_string(params)
|
|
474
548
|
|
|
475
|
-
|
|
549
|
+
if params is not None:
|
|
550
|
+
enc_params = self._encode_params(params)
|
|
551
|
+
else:
|
|
552
|
+
enc_params = ""
|
|
553
|
+
|
|
476
554
|
if enc_params:
|
|
477
555
|
if query:
|
|
478
556
|
query = f"{query}&{enc_params}"
|
|
479
557
|
else:
|
|
480
558
|
query = enc_params
|
|
481
559
|
|
|
482
|
-
url = requote_uri(urlunparse(
|
|
560
|
+
url = requote_uri(urlunparse((scheme, netloc, path, "", query, fragment)))
|
|
483
561
|
self.url = url
|
|
484
562
|
|
|
485
|
-
def prepare_headers(self, headers):
|
|
563
|
+
def prepare_headers(self, headers: Mapping[str, str | bytes] | None) -> None:
|
|
486
564
|
"""Prepares the given HTTP headers."""
|
|
487
565
|
|
|
488
566
|
self.headers = CaseInsensitiveDict()
|
|
@@ -493,7 +571,9 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
|
|
493
571
|
name, value = header
|
|
494
572
|
self.headers[to_native_string(name)] = value
|
|
495
573
|
|
|
496
|
-
def prepare_body(
|
|
574
|
+
def prepare_body(
|
|
575
|
+
self, data: _t.DataType, files: _t.FilesType, json: _t.JsonType = None
|
|
576
|
+
) -> None:
|
|
497
577
|
"""Prepares the given HTTP body data."""
|
|
498
578
|
|
|
499
579
|
# Check if file, fo, generator, iterator.
|
|
@@ -516,14 +596,9 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
|
|
516
596
|
if not isinstance(body, bytes):
|
|
517
597
|
body = body.encode("utf-8")
|
|
518
598
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
not isinstance(data, (basestring, list, tuple, Mapping)),
|
|
523
|
-
]
|
|
524
|
-
)
|
|
525
|
-
|
|
526
|
-
if is_stream:
|
|
599
|
+
# data that proxies attributes to underlying objects needs hasattr
|
|
600
|
+
is_iterable = isinstance(data, Iterable) or hasattr(data, "__iter__")
|
|
601
|
+
if is_iterable and not isinstance(data, (str, bytes, list, tuple, Mapping)):
|
|
527
602
|
try:
|
|
528
603
|
length = super_len(data)
|
|
529
604
|
except (TypeError, AttributeError, UnsupportedOperation):
|
|
@@ -536,7 +611,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
|
|
536
611
|
# This will allow us to rewind a file in the event
|
|
537
612
|
# of a redirect.
|
|
538
613
|
try:
|
|
539
|
-
self._body_position = body.tell()
|
|
614
|
+
self._body_position = body.tell() # type: ignore[union-attr] # guarded by getattr check
|
|
540
615
|
except OSError:
|
|
541
616
|
# This differentiates from None, allowing us to catch
|
|
542
617
|
# a failed `tell()` later when trying to rewind the body
|
|
@@ -552,13 +627,16 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
|
|
552
627
|
else:
|
|
553
628
|
self.headers["Transfer-Encoding"] = "chunked"
|
|
554
629
|
else:
|
|
630
|
+
# After is_stream filtering, remaining data is raw (not streamed)
|
|
631
|
+
raw_data = cast("_t.RawDataType | None", data)
|
|
632
|
+
|
|
555
633
|
# Multi-part file uploads.
|
|
556
634
|
if files:
|
|
557
|
-
(body, content_type) = self._encode_files(files,
|
|
635
|
+
(body, content_type) = self._encode_files(files, raw_data)
|
|
558
636
|
else:
|
|
559
|
-
if
|
|
560
|
-
body = self._encode_params(
|
|
561
|
-
if isinstance(data, basestring) or
|
|
637
|
+
if raw_data:
|
|
638
|
+
body = self._encode_params(raw_data)
|
|
639
|
+
if isinstance(data, basestring) or isinstance(data, _SupportsRead):
|
|
562
640
|
content_type = None
|
|
563
641
|
else:
|
|
564
642
|
content_type = "application/x-www-form-urlencoded"
|
|
@@ -569,9 +647,9 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
|
|
569
647
|
if content_type and ("content-type" not in self.headers):
|
|
570
648
|
self.headers["Content-Type"] = content_type
|
|
571
649
|
|
|
572
|
-
self.body = body
|
|
650
|
+
self.body = body # type: ignore[assignment] # body transforms from DataType to BodyType
|
|
573
651
|
|
|
574
|
-
def prepare_content_length(self, body):
|
|
652
|
+
def prepare_content_length(self, body: _t.BodyType) -> None:
|
|
575
653
|
"""Prepare Content-Length header based on request method and body"""
|
|
576
654
|
if body is not None:
|
|
577
655
|
length = super_len(body)
|
|
@@ -587,21 +665,28 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
|
|
587
665
|
# but don't provide one. (i.e. not GET or HEAD)
|
|
588
666
|
self.headers["Content-Length"] = "0"
|
|
589
667
|
|
|
590
|
-
def prepare_auth(
|
|
668
|
+
def prepare_auth(
|
|
669
|
+
self,
|
|
670
|
+
auth: _t.AuthType,
|
|
671
|
+
url: _t.UriType = "",
|
|
672
|
+
) -> None:
|
|
591
673
|
"""Prepares the given HTTP auth data."""
|
|
592
674
|
|
|
593
675
|
# If no Auth is explicitly provided, extract it from the URL first.
|
|
594
676
|
if auth is None:
|
|
595
|
-
url_auth = get_auth_from_url(self.url)
|
|
677
|
+
url_auth = get_auth_from_url(cast(str, self.url))
|
|
596
678
|
auth = url_auth if any(url_auth) else None
|
|
597
679
|
|
|
598
680
|
if auth:
|
|
599
|
-
if isinstance(auth, tuple) and len(auth) == 2:
|
|
681
|
+
if isinstance(auth, tuple) and len(auth) == 2: # type: ignore[arg-type] # pyright widens tuple from Callable in AuthType
|
|
600
682
|
# special-case basic HTTP auth
|
|
601
|
-
|
|
683
|
+
auth_handler = HTTPBasicAuth(*auth) # type: ignore[arg-type] # pyright widens tuple from Callable in AuthType
|
|
684
|
+
else:
|
|
685
|
+
# TODO: can be fixed by flipping the conditionals
|
|
686
|
+
auth_handler = cast("Callable[..., PreparedRequest]", auth)
|
|
602
687
|
|
|
603
688
|
# Allow auth to make its changes.
|
|
604
|
-
r =
|
|
689
|
+
r = auth_handler(self)
|
|
605
690
|
|
|
606
691
|
# Update self to reflect the auth changes.
|
|
607
692
|
self.__dict__.update(r.__dict__)
|
|
@@ -609,7 +694,9 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
|
|
609
694
|
# Recompute Content-Length
|
|
610
695
|
self.prepare_content_length(self.body)
|
|
611
696
|
|
|
612
|
-
def prepare_cookies(
|
|
697
|
+
def prepare_cookies(
|
|
698
|
+
self, cookies: RequestsCookieJar | CookieJar | dict[str, str] | None
|
|
699
|
+
) -> None:
|
|
613
700
|
"""Prepares the given HTTP cookie data.
|
|
614
701
|
|
|
615
702
|
This function eventually generates a ``Cookie`` header from the
|
|
@@ -625,16 +712,17 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
|
|
|
625
712
|
else:
|
|
626
713
|
self._cookies = cookiejar_from_dict(cookies)
|
|
627
714
|
|
|
628
|
-
|
|
715
|
+
cookies_jar = cast("CookieJar", self._cookies)
|
|
716
|
+
cookie_header = get_cookie_header(cookies_jar, self)
|
|
629
717
|
if cookie_header is not None:
|
|
630
718
|
self.headers["Cookie"] = cookie_header
|
|
631
719
|
|
|
632
|
-
def prepare_hooks(self, hooks):
|
|
720
|
+
def prepare_hooks(self, hooks: _t.HooksInputType | None) -> None:
|
|
633
721
|
"""Prepares the given hooks."""
|
|
634
722
|
# hooks can be passed as None to the prepare method and to this
|
|
635
723
|
# method. To prevent iterating over None, simply use an empty list
|
|
636
724
|
# if hooks is False-y
|
|
637
|
-
hooks = hooks or
|
|
725
|
+
hooks = hooks or {}
|
|
638
726
|
for event in hooks:
|
|
639
727
|
self.register_hook(event, hooks[event])
|
|
640
728
|
|
|
@@ -644,7 +732,22 @@ class Response:
|
|
|
644
732
|
server's response to an HTTP request.
|
|
645
733
|
"""
|
|
646
734
|
|
|
647
|
-
|
|
735
|
+
_content: bytes | Literal[False] | None
|
|
736
|
+
_content_consumed: bool
|
|
737
|
+
_next: PreparedRequest | None
|
|
738
|
+
status_code: int
|
|
739
|
+
headers: CaseInsensitiveDict[str]
|
|
740
|
+
raw: Any
|
|
741
|
+
url: str
|
|
742
|
+
encoding: str | None
|
|
743
|
+
history: list[Response]
|
|
744
|
+
reason: str
|
|
745
|
+
cookies: RequestsCookieJar
|
|
746
|
+
elapsed: datetime.timedelta
|
|
747
|
+
request: PreparedRequest
|
|
748
|
+
connection: HTTPAdapter
|
|
749
|
+
|
|
750
|
+
__attrs__: list[str] = [
|
|
648
751
|
"_content",
|
|
649
752
|
"status_code",
|
|
650
753
|
"headers",
|
|
@@ -657,13 +760,13 @@ class Response:
|
|
|
657
760
|
"request",
|
|
658
761
|
]
|
|
659
762
|
|
|
660
|
-
def __init__(self):
|
|
763
|
+
def __init__(self) -> None:
|
|
661
764
|
self._content = False
|
|
662
765
|
self._content_consumed = False
|
|
663
766
|
self._next = None
|
|
664
767
|
|
|
665
768
|
#: Integer Code of responded HTTP Status, e.g. 404 or 200.
|
|
666
|
-
self.status_code = None
|
|
769
|
+
self.status_code = None # type: ignore[assignment]
|
|
667
770
|
|
|
668
771
|
#: Case-insensitive Dictionary of Response Headers.
|
|
669
772
|
#: For example, ``headers['content-encoding']`` will return the
|
|
@@ -676,7 +779,7 @@ class Response:
|
|
|
676
779
|
self.raw = None
|
|
677
780
|
|
|
678
781
|
#: Final URL location of Response.
|
|
679
|
-
self.url = None
|
|
782
|
+
self.url = None # type: ignore[assignment]
|
|
680
783
|
|
|
681
784
|
#: Encoding to decode with when accessing r.text.
|
|
682
785
|
self.encoding = None
|
|
@@ -687,7 +790,7 @@ class Response:
|
|
|
687
790
|
self.history = []
|
|
688
791
|
|
|
689
792
|
#: Textual reason of responded HTTP Status, e.g. "Not Found" or "OK".
|
|
690
|
-
self.reason = None
|
|
793
|
+
self.reason = None # type: ignore[assignment]
|
|
691
794
|
|
|
692
795
|
#: A CookieJar of Cookies the server sent back.
|
|
693
796
|
self.cookies = cookiejar_from_dict({})
|
|
@@ -702,15 +805,15 @@ class Response:
|
|
|
702
805
|
|
|
703
806
|
#: The :class:`PreparedRequest <PreparedRequest>` object to which this
|
|
704
807
|
#: is a response.
|
|
705
|
-
self.request = None
|
|
808
|
+
self.request = None # type: ignore[assignment]
|
|
706
809
|
|
|
707
|
-
def __enter__(self):
|
|
810
|
+
def __enter__(self) -> Self:
|
|
708
811
|
return self
|
|
709
812
|
|
|
710
|
-
def __exit__(self, *args):
|
|
813
|
+
def __exit__(self, *args: Any) -> None:
|
|
711
814
|
self.close()
|
|
712
815
|
|
|
713
|
-
def __getstate__(self):
|
|
816
|
+
def __getstate__(self) -> dict[str, Any]:
|
|
714
817
|
# Consume everything; accessing the content attribute makes
|
|
715
818
|
# sure the content has been fully read.
|
|
716
819
|
if not self._content_consumed:
|
|
@@ -718,7 +821,7 @@ class Response:
|
|
|
718
821
|
|
|
719
822
|
return {attr: getattr(self, attr, None) for attr in self.__attrs__}
|
|
720
823
|
|
|
721
|
-
def __setstate__(self, state):
|
|
824
|
+
def __setstate__(self, state: dict[str, Any]) -> None:
|
|
722
825
|
for name, value in state.items():
|
|
723
826
|
setattr(self, name, value)
|
|
724
827
|
|
|
@@ -726,10 +829,10 @@ class Response:
|
|
|
726
829
|
setattr(self, "_content_consumed", True)
|
|
727
830
|
setattr(self, "raw", None)
|
|
728
831
|
|
|
729
|
-
def __repr__(self):
|
|
832
|
+
def __repr__(self) -> str:
|
|
730
833
|
return f"<Response [{self.status_code}]>"
|
|
731
834
|
|
|
732
|
-
def __bool__(self):
|
|
835
|
+
def __bool__(self) -> bool:
|
|
733
836
|
"""Returns True if :attr:`status_code` is less than 400.
|
|
734
837
|
|
|
735
838
|
This attribute checks if the status code of the response is between
|
|
@@ -739,7 +842,7 @@ class Response:
|
|
|
739
842
|
"""
|
|
740
843
|
return self.ok
|
|
741
844
|
|
|
742
|
-
def __nonzero__(self):
|
|
845
|
+
def __nonzero__(self) -> bool:
|
|
743
846
|
"""Returns True if :attr:`status_code` is less than 400.
|
|
744
847
|
|
|
745
848
|
This attribute checks if the status code of the response is between
|
|
@@ -749,12 +852,12 @@ class Response:
|
|
|
749
852
|
"""
|
|
750
853
|
return self.ok
|
|
751
854
|
|
|
752
|
-
def __iter__(self):
|
|
855
|
+
def __iter__(self) -> Iterator[bytes]:
|
|
753
856
|
"""Allows you to use a response as an iterator."""
|
|
754
857
|
return self.iter_content(128)
|
|
755
858
|
|
|
756
859
|
@property
|
|
757
|
-
def ok(self):
|
|
860
|
+
def ok(self) -> bool:
|
|
758
861
|
"""Returns True if :attr:`status_code` is less than 400, False if not.
|
|
759
862
|
|
|
760
863
|
This attribute checks if the status code of the response is between
|
|
@@ -769,14 +872,14 @@ class Response:
|
|
|
769
872
|
return True
|
|
770
873
|
|
|
771
874
|
@property
|
|
772
|
-
def is_redirect(self):
|
|
875
|
+
def is_redirect(self) -> bool:
|
|
773
876
|
"""True if this Response is a well-formed HTTP redirect that could have
|
|
774
877
|
been processed automatically (by :meth:`Session.resolve_redirects`).
|
|
775
878
|
"""
|
|
776
879
|
return "location" in self.headers and self.status_code in REDIRECT_STATI
|
|
777
880
|
|
|
778
881
|
@property
|
|
779
|
-
def is_permanent_redirect(self):
|
|
882
|
+
def is_permanent_redirect(self) -> bool:
|
|
780
883
|
"""True if this Response one of the permanent versions of redirect."""
|
|
781
884
|
return "location" in self.headers and self.status_code in (
|
|
782
885
|
codes.moved_permanently,
|
|
@@ -784,12 +887,12 @@ class Response:
|
|
|
784
887
|
)
|
|
785
888
|
|
|
786
889
|
@property
|
|
787
|
-
def next(self):
|
|
890
|
+
def next(self) -> PreparedRequest | None:
|
|
788
891
|
"""Returns a PreparedRequest for the next request in a redirect chain, if there is one."""
|
|
789
892
|
return self._next
|
|
790
893
|
|
|
791
894
|
@property
|
|
792
|
-
def apparent_encoding(self):
|
|
895
|
+
def apparent_encoding(self) -> str | None:
|
|
793
896
|
"""The apparent encoding, provided by the charset_normalizer or chardet libraries."""
|
|
794
897
|
if chardet is not None:
|
|
795
898
|
return chardet.detect(self.content)["encoding"]
|
|
@@ -798,7 +901,17 @@ class Response:
|
|
|
798
901
|
# to a standard Python utf-8 str.
|
|
799
902
|
return "utf-8"
|
|
800
903
|
|
|
801
|
-
|
|
904
|
+
@overload
|
|
905
|
+
def iter_content(
|
|
906
|
+
self, chunk_size: int | None = 1, decode_unicode: Literal[False] = False
|
|
907
|
+
) -> Iterator[bytes]: ...
|
|
908
|
+
@overload
|
|
909
|
+
def iter_content(
|
|
910
|
+
self, chunk_size: int | None = 1, *, decode_unicode: Literal[True]
|
|
911
|
+
) -> Iterator[str | bytes]: ...
|
|
912
|
+
def iter_content(
|
|
913
|
+
self, chunk_size: int | None = 1, decode_unicode: bool = False
|
|
914
|
+
) -> Iterator[str | bytes]:
|
|
802
915
|
"""Iterates over the response data. When stream=True is set on the
|
|
803
916
|
request, this avoids reading the content at once into memory for
|
|
804
917
|
large responses. The chunk size is the number of bytes it should
|
|
@@ -811,11 +924,13 @@ class Response:
|
|
|
811
924
|
chunks are received. If stream=False, data is returned as
|
|
812
925
|
a single chunk.
|
|
813
926
|
|
|
814
|
-
If decode_unicode is True, content will be decoded using
|
|
815
|
-
|
|
927
|
+
If decode_unicode is True, content will be decoded using encoding
|
|
928
|
+
information from the response. If no encoding information is available,
|
|
929
|
+
bytes will be returned. This can be bypassed by manually setting
|
|
930
|
+
`encoding` on the response.
|
|
816
931
|
"""
|
|
817
932
|
|
|
818
|
-
def generate():
|
|
933
|
+
def generate() -> Generator[bytes, None, None]:
|
|
819
934
|
# Special case for urllib3.
|
|
820
935
|
if hasattr(self.raw, "stream"):
|
|
821
936
|
try:
|
|
@@ -840,42 +955,65 @@ class Response:
|
|
|
840
955
|
|
|
841
956
|
if self._content_consumed and isinstance(self._content, bool):
|
|
842
957
|
raise StreamConsumedError()
|
|
843
|
-
elif chunk_size is not None and not isinstance(chunk_size, int):
|
|
958
|
+
elif chunk_size is not None and not isinstance(chunk_size, int): # type: ignore[reportUnnecessaryIsInstance] # runtime guard for untyped callers
|
|
844
959
|
raise TypeError(
|
|
845
960
|
f"chunk_size must be an int, it is instead a {type(chunk_size)}."
|
|
846
961
|
)
|
|
847
|
-
# simulate reading small chunks of the content
|
|
848
|
-
reused_chunks = iter_slices(self._content, chunk_size)
|
|
849
|
-
|
|
850
|
-
stream_chunks = generate()
|
|
851
962
|
|
|
852
|
-
|
|
963
|
+
if self._content_consumed:
|
|
964
|
+
# simulate reading small chunks of the content
|
|
965
|
+
content = cast(bytes, self._content)
|
|
966
|
+
chunks = iter_slices(content, chunk_size)
|
|
967
|
+
else:
|
|
968
|
+
chunks = generate()
|
|
853
969
|
|
|
854
970
|
if decode_unicode:
|
|
855
971
|
chunks = stream_decode_response_unicode(chunks, self)
|
|
856
972
|
|
|
857
973
|
return chunks
|
|
858
974
|
|
|
975
|
+
@overload
|
|
976
|
+
def iter_lines(
|
|
977
|
+
self,
|
|
978
|
+
chunk_size: int = ITER_CHUNK_SIZE,
|
|
979
|
+
decode_unicode: Literal[False] = False,
|
|
980
|
+
delimiter: bytes | None = None,
|
|
981
|
+
) -> Iterator[bytes]: ...
|
|
982
|
+
@overload
|
|
859
983
|
def iter_lines(
|
|
860
|
-
self,
|
|
861
|
-
|
|
984
|
+
self,
|
|
985
|
+
chunk_size: int = ITER_CHUNK_SIZE,
|
|
986
|
+
*,
|
|
987
|
+
decode_unicode: Literal[True],
|
|
988
|
+
delimiter: str | bytes | None = None,
|
|
989
|
+
) -> Iterator[str | bytes]: ...
|
|
990
|
+
def iter_lines(
|
|
991
|
+
self,
|
|
992
|
+
chunk_size: int = ITER_CHUNK_SIZE,
|
|
993
|
+
decode_unicode: bool = False,
|
|
994
|
+
delimiter: str | bytes | None = None,
|
|
995
|
+
) -> Iterator[str | bytes]:
|
|
862
996
|
"""Iterates over the response data, one line at a time. When
|
|
863
997
|
stream=True is set on the request, this avoids reading the
|
|
864
998
|
content at once into memory for large responses.
|
|
865
999
|
|
|
1000
|
+
The decode_unicode param works the same as in `iter_content`, with the
|
|
1001
|
+
same caveats.
|
|
1002
|
+
|
|
866
1003
|
.. note:: This method is not reentrant safe.
|
|
867
1004
|
"""
|
|
868
1005
|
|
|
869
|
-
pending = None
|
|
1006
|
+
pending: str | bytes | None = None
|
|
870
1007
|
|
|
871
1008
|
for chunk in self.iter_content(
|
|
872
1009
|
chunk_size=chunk_size, decode_unicode=decode_unicode
|
|
873
1010
|
):
|
|
874
1011
|
if pending is not None:
|
|
875
|
-
|
|
1012
|
+
# TODO: remove cast after iter_lines rewrite
|
|
1013
|
+
chunk = cast("str | bytes", pending + chunk) # type: ignore[operator]
|
|
876
1014
|
|
|
877
1015
|
if delimiter:
|
|
878
|
-
lines = chunk.split(delimiter)
|
|
1016
|
+
lines = chunk.split(delimiter) # type: ignore[arg-type]
|
|
879
1017
|
else:
|
|
880
1018
|
lines = chunk.splitlines()
|
|
881
1019
|
|
|
@@ -890,7 +1028,7 @@ class Response:
|
|
|
890
1028
|
yield pending
|
|
891
1029
|
|
|
892
1030
|
@property
|
|
893
|
-
def content(self):
|
|
1031
|
+
def content(self) -> bytes:
|
|
894
1032
|
"""Content of the response, in bytes."""
|
|
895
1033
|
|
|
896
1034
|
if self._content is False:
|
|
@@ -906,10 +1044,10 @@ class Response:
|
|
|
906
1044
|
self._content_consumed = True
|
|
907
1045
|
# don't need to release the connection; that's been handled by urllib3
|
|
908
1046
|
# since we exhausted the data.
|
|
909
|
-
return self._content
|
|
1047
|
+
return self._content # type: ignore[return-value]
|
|
910
1048
|
|
|
911
1049
|
@property
|
|
912
|
-
def text(self):
|
|
1050
|
+
def text(self) -> str:
|
|
913
1051
|
"""Content of the response, in unicode.
|
|
914
1052
|
|
|
915
1053
|
If Response.encoding is None, encoding will be guessed using
|
|
@@ -934,7 +1072,7 @@ class Response:
|
|
|
934
1072
|
|
|
935
1073
|
# Decode unicode from given encoding.
|
|
936
1074
|
try:
|
|
937
|
-
content = str(self.content, encoding, errors="replace")
|
|
1075
|
+
content = str(self.content, encoding or "utf-8", errors="replace")
|
|
938
1076
|
except (LookupError, TypeError):
|
|
939
1077
|
# A LookupError is raised if the encoding was not found which could
|
|
940
1078
|
# indicate a misspelling or similar mistake.
|
|
@@ -946,7 +1084,7 @@ class Response:
|
|
|
946
1084
|
|
|
947
1085
|
return content
|
|
948
1086
|
|
|
949
|
-
def json(self, **kwargs):
|
|
1087
|
+
def json(self, **kwargs: Any) -> Any:
|
|
950
1088
|
r"""Decodes the JSON response body (if any) as a Python object.
|
|
951
1089
|
|
|
952
1090
|
This may return a dictionary, list, etc. depending on what is in the response.
|
|
@@ -982,23 +1120,24 @@ class Response:
|
|
|
982
1120
|
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
|
|
983
1121
|
|
|
984
1122
|
@property
|
|
985
|
-
def links(self):
|
|
1123
|
+
def links(self) -> dict[str, dict[str, str]]:
|
|
986
1124
|
"""Returns the parsed header links of the response, if any."""
|
|
987
1125
|
|
|
988
1126
|
header = self.headers.get("link")
|
|
989
1127
|
|
|
990
|
-
resolved_links = {}
|
|
1128
|
+
resolved_links: dict[str, dict[str, str]] = {}
|
|
991
1129
|
|
|
992
1130
|
if header:
|
|
993
1131
|
links = parse_header_links(header)
|
|
994
1132
|
|
|
995
1133
|
for link in links:
|
|
996
1134
|
key = link.get("rel") or link.get("url")
|
|
997
|
-
|
|
1135
|
+
if key is not None:
|
|
1136
|
+
resolved_links[key] = link
|
|
998
1137
|
|
|
999
1138
|
return resolved_links
|
|
1000
1139
|
|
|
1001
|
-
def raise_for_status(self):
|
|
1140
|
+
def raise_for_status(self) -> None:
|
|
1002
1141
|
"""Raises :class:`HTTPError`, if one occurred."""
|
|
1003
1142
|
|
|
1004
1143
|
http_error_msg = ""
|
|
@@ -1027,7 +1166,7 @@ class Response:
|
|
|
1027
1166
|
if http_error_msg:
|
|
1028
1167
|
raise HTTPError(http_error_msg, response=self)
|
|
1029
1168
|
|
|
1030
|
-
def close(self):
|
|
1169
|
+
def close(self) -> None:
|
|
1031
1170
|
"""Releases the connection back to the pool. Once this method has been
|
|
1032
1171
|
called the underlying ``raw`` object must not be accessed again.
|
|
1033
1172
|
|