Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
593b85f4
P
pip
项目概览
镜像
/
Python_Packaging_Authority
/
pip
10 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pip
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
593b85f4
编写于
7月 17, 2023
作者:
S
Shantanu
提交者:
GitHub
7月 17, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use strict optional checking in misc.py (#11382)
上级
b252ad81
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
14 deletion
+16
-14
news/14514698-7F32-4890-97C1-7403A685733D.trivial.rst
news/14514698-7F32-4890-97C1-7403A685733D.trivial.rst
+0
-0
src/pip/_internal/network/session.py
src/pip/_internal/network/session.py
+6
-4
src/pip/_internal/utils/misc.py
src/pip/_internal/utils/misc.py
+10
-10
未找到文件。
news/14514698-7F32-4890-97C1-7403A685733D.trivial.rst
0 → 100644
浏览文件 @
593b85f4
src/pip/_internal/network/session.py
浏览文件 @
593b85f4
...
...
@@ -419,15 +419,17 @@ class PipSession(requests.Session):
msg
+=
f
" (from
{
source
}
)"
logger
.
info
(
msg
)
host_port
=
parse_netloc
(
host
)
if
host_port
not
in
self
.
pip_trusted_origins
:
self
.
pip_trusted_origins
.
append
(
host_port
)
parsed_host
,
parsed_port
=
parse_netloc
(
host
)
if
parsed_host
is
None
:
raise
ValueError
(
f
"Trusted host URL must include a host part:
{
host
!
r
}
"
)
if
(
parsed_host
,
parsed_port
)
not
in
self
.
pip_trusted_origins
:
self
.
pip_trusted_origins
.
append
((
parsed_host
,
parsed_port
))
self
.
mount
(
build_url_from_netloc
(
host
,
scheme
=
"http"
)
+
"/"
,
self
.
_trusted_host_adapter
)
self
.
mount
(
build_url_from_netloc
(
host
)
+
"/"
,
self
.
_trusted_host_adapter
)
if
not
host_port
[
1
]
:
if
not
parsed_port
:
self
.
mount
(
build_url_from_netloc
(
host
,
scheme
=
"http"
)
+
":"
,
self
.
_trusted_host_adapter
,
...
...
src/pip/_internal/utils/misc.py
浏览文件 @
593b85f4
# The following comment should be removed at some point in the future.
# mypy: strict-optional=False
import
contextlib
import
errno
import
getpass
...
...
@@ -344,17 +341,18 @@ def write_output(msg: Any, *args: Any) -> None:
class
StreamWrapper
(
StringIO
):
orig_stream
:
TextIO
=
None
orig_stream
:
TextIO
@
classmethod
def
from_stream
(
cls
,
orig_stream
:
TextIO
)
->
"StreamWrapper"
:
cls
.
orig_stream
=
orig_stream
return
cls
()
ret
=
cls
()
ret
.
orig_stream
=
orig_stream
return
ret
# compileall.compile_dir() needs stdout.encoding to print to stdout
#
https://github.com/python/mypy/issues/4125
#
type ignore is because TextIOBase.encoding is writeable
@
property
def
encoding
(
self
):
# type: ignore
def
encoding
(
self
)
->
str
:
# type: ignore
return
self
.
orig_stream
.
encoding
...
...
@@ -422,7 +420,7 @@ def build_url_from_netloc(netloc: str, scheme: str = "https") -> str:
return
f
"
{
scheme
}
://
{
netloc
}
"
def
parse_netloc
(
netloc
:
str
)
->
Tuple
[
str
,
Optional
[
int
]]:
def
parse_netloc
(
netloc
:
str
)
->
Tuple
[
Optional
[
str
]
,
Optional
[
int
]]:
"""
Return the host-port pair from a netloc.
"""
...
...
@@ -510,7 +508,9 @@ def _redact_netloc(netloc: str) -> Tuple[str]:
return
(
redact_netloc
(
netloc
),)
def
split_auth_netloc_from_url
(
url
:
str
)
->
Tuple
[
str
,
str
,
Tuple
[
str
,
str
]]:
def
split_auth_netloc_from_url
(
url
:
str
,
)
->
Tuple
[
str
,
str
,
Tuple
[
Optional
[
str
],
Optional
[
str
]]]:
"""
Parse a url into separate netloc, auth, and url with no auth.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录