Skip to content

Commit

Permalink
fix: Empty source tables causing errors when runing pdm (#2043)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming authored Jun 21, 2023
1 parent 15b7e88 commit b31edde
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/2034.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug that empty source tables in configuration files causes errors when running pdm commands.
2 changes: 1 addition & 1 deletion src/pdm/project/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def self_data(self) -> dict[str, Any]:

def iter_sources(self) -> Iterator[RepositoryConfig]:
for name, data in self._data.items():
if name.startswith(f"{SOURCE}.") and name not in self._config_map:
if name.startswith(f"{SOURCE}.") and name not in self._config_map and data:
yield RepositoryConfig(**data, name=name[len(SOURCE) + 1 :], config_prefix=SOURCE)

def _save_config(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/pdm/project/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def merge_sources(other_sources: Iterable[RepositoryConfig]) -> None:
merge_sources(self.project_config.iter_sources())
merge_sources(self.global_config.iter_sources())
for source in result.values():
assert source.url, "Source URL must not be empty"
assert source.url, f"Source URL must not be empty for {source.name}"
source.url = expand_env_vars_in_auth(source.url)
return list(result.values())

Expand Down

0 comments on commit b31edde

Please sign in to comment.