Skip to content

blurb merge: "No 'section' specified. You must provide one!" #525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hugovk opened this issue Jan 24, 2024 · 1 comment · Fixed by python/cpython#114553
Closed

blurb merge: "No 'section' specified. You must provide one!" #525

hugovk opened this issue Jan 24, 2024 · 1 comment · Fixed by python/cpython#114553
Labels

Comments

@hugovk
Copy link
Member

hugovk commented Jan 24, 2024

The short story

Error with blurb merge, with the unreleased version.

Long version

With current CPython main (commit 981d172f7f0613d30bef4a8934b361db7fcf0672), run blurb merge:

❯ blurb merge
You already have a 'Misc/NEWS' file.
[Type ok to overwrite> ok
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.12/bin/blurb", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/hugo/github/core-workflow/blurb/blurb.py", line 1288, in main
    sys.exit(fn(*filtered_args, **kwargs))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hugo/github/core-workflow/blurb/blurb.py", line 1067, in merge
    write_news(output, versions=versions)
  File "/Users/hugo/github/core-workflow/blurb/blurb.py", line 1099, in write_news
    blurbs.load(filenames[0])
  File "/Users/hugo/github/core-workflow/blurb/blurb.py", line 541, in load
    self.parse(text, metadata=metadata, filename=filename)
  File "/Users/hugo/github/core-workflow/blurb/blurb.py", line 531, in parse
    finish_entry()
  File "/Users/hugo/github/core-workflow/blurb/blurb.py", line 502, in finish_entry
    throw("No 'section' specified.  You must provide one!")
  File "/Users/hugo/github/core-workflow/blurb/blurb.py", line 459, in throw
    raise BlurbError(f"Error in {filename}:{line_number}:\n{s}")
blurb.BlurbError: Error in Misc/NEWS.d/3.6.2.rst:7:
No 'section' specified.  You must provide one!

The last released 1.1.0 still works.

git bisect points to a0db0d9:

a0db0d98b41ef1debf443c988c450de278932ee2 is the first bad commit
commit a0db0d98b41ef1debf443c988c450de278932ee2
Date:   Sun Jul 23 06:36:51 2023 -0700

    Improved error checking when parsing a Blurb. (#507)

    We now:
    * Check the entries in metadata in order, so we complain about
      the *first* one that has an error, which is a more familiar
      user experience.
    * Have checks for:
            * Invalid issue number
            * Invalid section
            * Empty section
            * Completely missing section

    (There is no test for "missing issue number", because it's legal
    to have a Blurb with no issue number.  "no changes" blurbs don't
    have an issue number.  But we do now reliably test that, *if* the
    issue number is specified, it *is* correctly formatted.)

 blurb/blurb.py                         | 54 +++++++++++++++++++++-------------
 blurb/tests/fail/invalid-gh-number.rst |  4 +++
 blurb/tests/fail/invalid-section.rst   |  4 +++
 blurb/tests/fail/no-gh-number.rst      |  4 +++
 blurb/tests/fail/no-section.rst        |  3 ++
 5 files changed, 49 insertions(+), 20 deletions(-)
 create mode 100644 blurb/tests/fail/invalid-gh-number.rst
 create mode 100644 blurb/tests/fail/invalid-section.rst
 create mode 100644 blurb/tests/fail/no-gh-number.rst
 create mode 100644 blurb/tests/fail/no-section.rst

Added in #507.

Whilst it's useful to check for a missing section in normal , maybe we should allow missing sections in combined Misc/NEWS.d/x.y.z.rst files?

We could skip the three problematic files:

-            if not 'section' in metadata:
+            if 'section' not in metadata and filename not in [
+                "Misc/NEWS.d/3.5.3.rst",
+                "Misc/NEWS.d/3.6.0.rst",
+                "Misc/NEWS.d/3.6.2.rst",
+            ]:
                 throw("No 'section' specified.  You must provide one!")

Or generally:

-            if not 'section' in metadata:
+            if 'section' not in metadata and filename.startswith("Misc/NEWS.d/next"):
                 throw("No 'section' specified.  You must provide one!")
@hugovk
Copy link
Member Author

hugovk commented Jan 25, 2024

Alternatively, it's easier to add the missing sections to those three files, as was already done for others.

See python/cpython#114553 to fix them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant