WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 9476629

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent ad63bb1 commit 9476629

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/pdm/cli/commands/publish/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,9 @@ def get_repository(project: Project, options: argparse.Namespace) -> Repository:
143143
password = options.password or os.getenv("PDM_PUBLISH_PASSWORD")
144144
ca_certs = options.ca_certs or os.getenv("PDM_PUBLISH_CA_CERTS")
145145

146-
config = (
147-
project.project_config.get_repository_config(repository, "repository") or
148-
project.global_config.get_repository_config(repository, "repository")
149-
)
146+
config = project.project_config.get_repository_config(
147+
repository, "repository"
148+
) or project.global_config.get_repository_config(repository, "repository")
150149
if config is None:
151150
raise PdmUsageError(f"Missing repository config of {repository}")
152151
assert config.url is not None

tests/cli/test_config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def test_default_repository_setting(project):
9898
repository = project.global_config.get_repository_config("nonexist", "repository")
9999
assert repository is None
100100

101+
101102
def test_repository_global_config_key_short(project):
102103
with pytest.raises(PdmUsageError):
103104
project.global_config["repository.test"] = {"url": "https://example.org/simple"}
@@ -108,6 +109,7 @@ def test_repository_global_config_key_short(project):
108109
with pytest.raises(PdmUsageError):
109110
del project.global_config["repository"]
110111

112+
111113
def test_repository_project_config_key_short(project):
112114
with pytest.raises(PdmUsageError):
113115
project.project_config["repository.test"] = {"url": "https://example.org/simple"}
@@ -131,6 +133,7 @@ def test_repository_global_config_overwrite_default(project):
131133
repository = project.global_config.get_repository_config("pypi", "repository")
132134
assert repository.url == "https://example.pypi.org/legacy/"
133135

136+
134137
def test_repository_project_config_overwrite_default(project):
135138
project.project_config["repository.pypi.username"] = "foo"
136139
project.project_config["repository.pypi.password"] = "bar"
@@ -183,6 +186,7 @@ def test_config_get_repository_global_config(project, pdm):
183186
result = pdm(["config", "repository.pypi.url"], obj=project, strict=True)
184187
assert result.stdout.strip() == "https://upload.pypi.org/legacy/"
185188

189+
186190
def test_config_get_repository_project_config(project, pdm):
187191
config = project.project_config["repository.pypi"]
188192
assert config == project.project_config.get_repository_config("pypi", "repository")
@@ -199,6 +203,7 @@ def test_config_get_repository_project_config(project, pdm):
199203
result = pdm(["config", "repository.pypi.url"], obj=project, strict=True)
200204
assert result.stdout.strip() == "https://upload.pypi.org/legacy/"
201205

206+
202207
def test_config_set_repository_global_config(project):
203208
project.global_config["repository.pypi.url"] = "https://example.pypi.org/legacy/"
204209
project.global_config["repository.pypi.username"] = "foo"
@@ -207,6 +212,7 @@ def test_config_set_repository_global_config(project):
207212
del project.global_config["repository.pypi.username"]
208213
assert project.global_config["repository.pypi.username"] is None
209214

215+
210216
def test_config_set_repository_project_config(project):
211217
project.project_config["repository.pypi.url"] = "https://example.pypi.org/legacy/"
212218
project.project_config["repository.pypi.username"] = "foo"
@@ -215,13 +221,15 @@ def test_config_set_repository_project_config(project):
215221
del project.project_config["repository.pypi.username"]
216222
assert project.project_config["repository.pypi.username"] is None
217223

224+
218225
def test_config_del_repository_global_config(project):
219226
project.global_config["repository.test.url"] = "https://example.org/simple"
220227
assert project.global_config.get_repository_config("test", "repository") is not None
221228

222229
del project.global_config["repository.test"]
223230
assert project.global_config.get_repository_config("test", "repository") is None
224231

232+
225233
def test_config_del_repository_project_config(project):
226234
project.project_config["repository.test.url"] = "https://example.org/simple"
227235
assert project.project_config.get_repository_config("test", "repository") is not None

0 commit comments

Comments
 (0)