Skip to content

Commit 146b170

Browse files
authored
fix: error about dynamic project version (#235)
* Fixed error in document regarding `Get with a specific function` section * Fixed the error of not correctly parsing single literal parameters.
1 parent 4ca42f0 commit 146b170

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

docs/metadata.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ def format_version(version: SCMVersion) -> str:
8787
```toml
8888
[tool.pdm.version]
8989
source = "call"
90-
getter = "mypackage.version.get_version"
90+
getter = "mypackage.version:get_version"
9191
```
9292

9393
You can also supply it with literal arguments:
9494

9595
```toml
96-
getter = "mypackage.version.get_version('dev')"
96+
getter = "mypackage.version:get_version('dev')"
9797
```
9898

9999
### Writing dynamic version to file

src/pdm/backend/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,10 @@ def evaluate_module_attribute(
215215
obj: Any = functools.reduce(getattr, attrs, module)
216216
args_group = matched.group(3)
217217
if args_group:
218+
# make tuple
219+
args_group = args_group.strip()[:-1] + ",)"
218220
args = ast.literal_eval(args_group)
221+
219222
else:
220223
args = ()
221224
return obj, args

0 commit comments

Comments
 (0)