Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
7369ac2e
P
pip
项目概览
镜像
/
Python_Packaging_Authority
/
pip
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
7369ac2e
编写于
12月 29, 2020
作者:
P
Pradyun Gedam
提交者:
GitHub
12月 29, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9396 from jdufresne/expanduser
Replace compat.expanduser() with os.path.expanduser()
上级
af5b7fe1
5150129f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
6 addition
and
37 deletion
+6
-37
news/7edb0afc-938e-457b-ae6e-0905e7443b2f.trivial.rst
news/7edb0afc-938e-457b-ae6e-0905e7443b2f.trivial.rst
+0
-0
src/pip/_internal/configuration.py
src/pip/_internal/configuration.py
+2
-2
src/pip/_internal/utils/compat.py
src/pip/_internal/utils/compat.py
+0
-13
src/pip/_internal/utils/misc.py
src/pip/_internal/utils/misc.py
+2
-2
tests/unit/test_collector.py
tests/unit/test_collector.py
+1
-1
tests/unit/test_compat.py
tests/unit/test_compat.py
+1
-19
未找到文件。
news/7edb0afc-938e-457b-ae6e-0905e7443b2f.trivial.rst
0 → 100644
浏览文件 @
7369ac2e
src/pip/_internal/configuration.py
浏览文件 @
7369ac2e
...
...
@@ -22,7 +22,7 @@ from pip._internal.exceptions import (
ConfigurationFileCouldNotBeLoaded
,
)
from
pip._internal.utils
import
appdirs
from
pip._internal.utils.compat
import
WINDOWS
,
expanduser
from
pip._internal.utils.compat
import
WINDOWS
from
pip._internal.utils.misc
import
ensure_dir
,
enum
from
pip._internal.utils.typing
import
MYPY_CHECK_RUNNING
...
...
@@ -80,7 +80,7 @@ def get_configuration_files():
site_config_file
=
os
.
path
.
join
(
sys
.
prefix
,
CONFIG_BASENAME
)
legacy_config_file
=
os
.
path
.
join
(
expanduser
(
'~'
),
os
.
path
.
expanduser
(
'~'
),
'pip'
if
WINDOWS
else
'.pip'
,
CONFIG_BASENAME
,
)
...
...
src/pip/_internal/utils/compat.py
浏览文件 @
7369ac2e
...
...
@@ -139,19 +139,6 @@ def get_path_uid(path):
return
file_uid
def
expanduser
(
path
):
# type: (str) -> str
"""
Expand ~ and ~user constructions.
Includes a workaround for https://bugs.python.org/issue14768
"""
expanded
=
os
.
path
.
expanduser
(
path
)
if
path
.
startswith
(
'~/'
)
and
expanded
.
startswith
(
'//'
):
expanded
=
expanded
[
1
:]
return
expanded
# packages in the stdlib that may have installation metadata, but should not be
# considered 'installed'. this theoretically could be determined based on
# dist.location (py27:`sysconfig.get_paths()['stdlib']`,
...
...
src/pip/_internal/utils/misc.py
浏览文件 @
7369ac2e
...
...
@@ -28,7 +28,7 @@ from pip._vendor.retrying import retry # type: ignore
from
pip
import
__version__
from
pip._internal.exceptions
import
CommandError
from
pip._internal.locations
import
get_major_minor_version
,
site_packages
,
user_site
from
pip._internal.utils.compat
import
WINDOWS
,
expanduser
,
stdlib_pkgs
from
pip._internal.utils.compat
import
WINDOWS
,
stdlib_pkgs
from
pip._internal.utils.typing
import
MYPY_CHECK_RUNNING
,
cast
from
pip._internal.utils.virtualenv
import
(
running_under_virtualenv
,
...
...
@@ -302,7 +302,7 @@ def normalize_path(path, resolve_symlinks=True):
Convert a path to its canonical, case-normalized, absolute version.
"""
path
=
expanduser
(
path
)
path
=
os
.
path
.
expanduser
(
path
)
if
resolve_symlinks
:
path
=
os
.
path
.
realpath
(
path
)
else
:
...
...
tests/unit/test_collector.py
浏览文件 @
7369ac2e
...
...
@@ -733,7 +733,7 @@ def test_link_collector_create(
assert
search_scope
.
index_urls
==
expected_index_urls
@
patch
(
'
pip._internal.utils.misc
.expanduser'
)
@
patch
(
'
os.path
.expanduser'
)
def
test_link_collector_create_find_links_expansion
(
mock_expanduser
,
tmpdir
,
):
...
...
tests/unit/test_compat.py
浏览文件 @
7369ac2e
...
...
@@ -5,12 +5,7 @@ import sys
import
pytest
import
pip._internal.utils.compat
as
pip_compat
from
pip._internal.utils.compat
import
(
console_to_str
,
expanduser
,
get_path_uid
,
str_to_display
,
)
from
pip._internal.utils.compat
import
console_to_str
,
get_path_uid
,
str_to_display
def
test_get_path_uid
():
...
...
@@ -127,16 +122,3 @@ def test_console_to_str_warning(monkeypatch):
monkeypatch
.
setattr
(
locale
,
'getpreferredencoding'
,
lambda
:
'utf-8'
)
monkeypatch
.
setattr
(
pip_compat
.
logger
,
'warning'
,
check_warning
)
console_to_str
(
some_bytes
)
@
pytest
.
mark
.
parametrize
(
"home,path,expanded"
,
[
(
"/Users/test"
,
"~"
,
"/Users/test"
),
(
"/Users/test"
,
"~/.cache"
,
"/Users/test/.cache"
),
# Verify that we are not affected by https://bugs.python.org/issue14768
(
"/"
,
"~"
,
"/"
),
(
"/"
,
"~/.cache"
,
"/.cache"
),
])
def
test_expanduser
(
home
,
path
,
expanded
,
monkeypatch
):
monkeypatch
.
setenv
(
"HOME"
,
home
)
monkeypatch
.
setenv
(
"USERPROFILE"
,
home
)
assert
expanduser
(
path
)
==
expanded
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录