AnswerDotAI / AnswerDotAI/nbdev
nbdev_bump_version destroys literate programming in settings.ini
- Dominant language
- Jupyter Notebook
- Stars
- 5.3k
- Forks
- 513
- Avg merge
- 2d 30m
- Merged PRs (30d)
- 8
Description
# Reproduction
1. Create a new nbdev repository
1. Examine the settings.ini file, which contains comments and variable substitution
1. Execute the nbdev_bump_version command
1. Observe that the settings.ini file now lacks comments, and variables have been replaced with their hardcoded values.
# Solution
Just a simple terminal command would suffice
```bash
new_version="0.1.2"
sed -i "s/^\(version[[:space:]]*=[[:space:]]*\).*$/\1 ${new_version}/" settings.ini
```
or in python
```python
import re
new_version = "0.1.2"
with open("settings.ini", "r") as file:
content = file.read()
content = re.sub(r"^(version\s*=\s*).*?$", r"\1 " + new_version, content, flags=re.MULTILINE)
with open("settings.ini", "w") as file:
file.write(content)
```
Contributor guide
Assessment
This issue has not been assessed yet.