From 82726a2d612603d82fa729646bd96630433ae7e0 Mon Sep 17 00:00:00 2001 From: deven367 Date: Thu, 27 Aug 2026 15:05:07 -0400 Subject: [PATCH 1/6] make the post part a bit more verbose --- nbdev/release.py | 2 +- nbs/api/18_release.ipynb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nbdev/release.py b/nbdev/release.py index 95c74b088..841447295 100644 --- a/nbdev/release.py +++ b/nbdev/release.py @@ -386,7 +386,7 @@ def release_both( # %% ../nbs/api/18_release.ipynb #c0f64b2c @call_parse def nbdev_bump_version( - part:int=None, # Release part to bump; defaults to post when present, otherwise patch + part:int=None, # 0-based version part to bump (0=major, 1=minor, 2=patch); defaults to post when present, otherwise the last part unbump:bool=False): # Reduce version instead of increasing it "Increment version in __init__.py by one" cfg = get_config() diff --git a/nbs/api/18_release.ipynb b/nbs/api/18_release.ipynb index a55212c76..1e9a9cc6f 100644 --- a/nbs/api/18_release.ipynb +++ b/nbs/api/18_release.ipynb @@ -1096,7 +1096,7 @@ "source": [ "## Bump Version\n", "\n", - "By default, a post-release version increments `.postN`; other versions increment their patch component. Passing `--part` explicitly selects a release component and removes the post suffix." + "By default, a post-release version increments `.postN`; other versions increment their last component. Passing `--part` explicitly selects a 0-based release component from the left (0=major, 1=minor, 2=patch for semver versions) and removes the post suffix." ] }, { @@ -1109,7 +1109,7 @@ "#| export\n", "@call_parse\n", "def nbdev_bump_version(\n", - " part:int=None, # Release part to bump; defaults to post when present, otherwise patch\n", + " part:int=None, # 0-based version part to bump (0=major, 1=minor, 2=patch); defaults to post when present, otherwise the last part\n", " unbump:bool=False): # Reduce version instead of increasing it\n", " \"Increment version in __init__.py by one\"\n", " cfg = get_config()\n", From 41a97eb2fdf85e5a1a72840e3aae982fdc4dbb02 Mon Sep 17 00:00:00 2001 From: deven367 Date: Thu, 27 Aug 2026 15:11:26 -0400 Subject: [PATCH 2/6] add the config again --- nbdev/config.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nbdev/config.py b/nbdev/config.py index 30e4e2d30..ab0bfcfdc 100644 --- a/nbdev/config.py +++ b/nbdev/config.py @@ -316,20 +316,20 @@ def set_version(path, version): # %% ../nbs/api/01_config.ipynb #d00889e5 def bump_version(v, part=None, unbump=False): - "Bump `.postN` by default when present, otherwise a semver part counted from the right" + "Bump `.postN` by default when present, otherwise the part at 0-based index `part` of `v` (0=major, 1=minor, 2=patch), defaulting to the last part" v = v or '0.0.0' post = re.fullmatch(r'(.*)\.post(\d+)', v) if part is None and post: n = max(0, int(post[2]) + (-1 if unbump else 1)) return f'{post[1]}.post{n}' - if part is None: part = 2 parts = (post[1] if post else v).split('.') parts += ['0'] * (3 - len(parts)) - idx = len(parts) - 3 + part - parts[idx] = str(int(parts[idx]) + (-1 if unbump else 1)) - for i in range(idx+1, len(parts)): parts[i] = '0' + if part is None: part = len(parts) - 1 + parts[part] = str(int(parts[part]) + (-1 if unbump else 1)) + for i in range(part+1, len(parts)): parts[i] = '0' return '.'.join(parts) + # %% ../nbs/api/01_config.ipynb #e32583e6 def update_version(path=None): "Add __version__ to `path/__init__.py` if it doesn't exist" From 488eff19125d343f692799ebae117f93bb9e098b Mon Sep 17 00:00:00 2001 From: deven367 Date: Thu, 27 Aug 2026 15:15:49 -0400 Subject: [PATCH 3/6] changes in the nb --- nbs/api/01_config.ipynb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/nbs/api/01_config.ipynb b/nbs/api/01_config.ipynb index 1ba47e186..5918c6e41 100644 --- a/nbs/api/01_config.ipynb +++ b/nbs/api/01_config.ipynb @@ -808,19 +808,18 @@ "source": [ "#| export\n", "def bump_version(v, part=None, unbump=False):\n", - " \"Bump `.postN` by default when present, otherwise a semver part counted from the right\"\n", + " \"Bump `.postN` by default when present, otherwise the part at 0-based index `part` of `v` (0=major, 1=minor, 2=patch), defaulting to the last part\"\n", " v = v or '0.0.0'\n", " post = re.fullmatch(r'(.*)\\.post(\\d+)', v)\n", " if part is None and post:\n", " n = max(0, int(post[2]) + (-1 if unbump else 1))\n", " return f'{post[1]}.post{n}'\n", - " if part is None: part = 2\n", " parts = (post[1] if post else v).split('.')\n", " parts += ['0'] * (3 - len(parts))\n", - " idx = len(parts) - 3 + part\n", - " parts[idx] = str(int(parts[idx]) + (-1 if unbump else 1))\n", - " for i in range(idx+1, len(parts)): parts[i] = '0'\n", - " return '.'.join(parts)" + " if part is None: part = len(parts) - 1\n", + " parts[part] = str(int(parts[part]) + (-1 if unbump else 1))\n", + " for i in range(part+1, len(parts)): parts[i] = '0'\n", + " return '.'.join(parts)\n" ] }, { From 032493b50e4ea0fbf66a8285202cf6e49433458a Mon Sep 17 00:00:00 2001 From: deven367 Date: Thu, 27 Aug 2026 15:16:23 -0400 Subject: [PATCH 4/6] Reapply "update logic to bump parts (and add more tests)" This reverts commit 93868a2d82230433dfd7893b44d8c06472f08fdb. --- nbs/api/01_config.ipynb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/nbs/api/01_config.ipynb b/nbs/api/01_config.ipynb index 5918c6e41..0f5873cd2 100644 --- a/nbs/api/01_config.ipynb +++ b/nbs/api/01_config.ipynb @@ -848,11 +848,14 @@ "test_eq(bump_version('1.2.3', part=0), '2.0.0')\n", "test_eq(bump_version('1.2.3', part=2, unbump=True), '1.2.2')\n", "test_eq(bump_version('2026.05.27.2'), '2026.05.27.3')\n", - "test_eq(bump_version('2026.05.27.2', part=1), '2026.05.28.0')\n", - "test_eq(bump_version('2026.05.27.2', part=0), '2026.6.0.0')\n", + "test_eq(bump_version('2026.05.27.2', part=3), '2026.05.27.3')\n", + "test_eq(bump_version('2026.05.27.2', part=2), '2026.05.28.0')\n", + "test_eq(bump_version('2026.05.27.2', part=1), '2026.6.0.0')\n", + "test_eq(bump_version('2026.05.27.2', part=0), '2027.0.0.0')\n", + "test_eq(bump_version('2026.01.28.0', part=3), '2026.01.28.1')\n", "test_eq(bump_version('0.0.2026082005.post1'), '0.0.2026082005.post2')\n", "test_eq(bump_version('0.0.2026082005.post2', unbump=True), '0.0.2026082005.post1')\n", - "test_eq(bump_version('0.0.2026082005.post1', part=2), '0.0.2026082006')" + "test_eq(bump_version('0.0.2026082005.post1', part=2), '0.0.2026082006')\n" ] }, { From 259e94677b9822aed13505a7ea72e998fbd663f4 Mon Sep 17 00:00:00 2001 From: deven367 Date: Thu, 27 Aug 2026 15:28:26 -0400 Subject: [PATCH 5/6] fix the failing test (121 is hardcoded, it was supposed to be `MAXLEN`) --- nbs/api/19_diff.ipynb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nbs/api/19_diff.ipynb b/nbs/api/19_diff.ipynb index b2e33e3ef..cf979680e 100644 --- a/nbs/api/19_diff.ipynb +++ b/nbs/api/19_diff.ipynb @@ -618,9 +618,9 @@ "metadata": {}, "outputs": [], "source": [ - "assert all(len(l)<=121 for l in nb_diff(nb_path).splitlines())\n", + "assert all(len(l)<=MAXLEN+1 for l in nb_diff(nb_path).splitlines())\n", "assert any(l.endswith('…') for l in nb_diff(nb_path).splitlines())\n", - "assert all(len(l)>121 for l in nb_diff(nb_path, maxlen=0).splitlines() if l.startswith('+y'))" + "assert all(len(l)>MAXLEN for l in nb_diff(nb_path, maxlen=0).splitlines() if l.startswith('+y'))" ] }, { @@ -859,6 +859,9 @@ } ], "metadata": { + "language_info": { + "name": "python" + }, "solveit": { "default_code": false, "mode": "learning", From 6cdbaa099cdc591a9affb711aaf767f9f7cdbf39 Mon Sep 17 00:00:00 2001 From: deven367 Date: Thu, 27 Aug 2026 15:31:09 -0400 Subject: [PATCH 6/6] clean --- nbs/api/19_diff.ipynb | 3 --- 1 file changed, 3 deletions(-) diff --git a/nbs/api/19_diff.ipynb b/nbs/api/19_diff.ipynb index cf979680e..e1b9cbce9 100644 --- a/nbs/api/19_diff.ipynb +++ b/nbs/api/19_diff.ipynb @@ -859,9 +859,6 @@ } ], "metadata": { - "language_info": { - "name": "python" - }, "solveit": { "default_code": false, "mode": "learning",