Skip to content

finalize fails with FileNotFoundError when no newsfragments dir #26

@jaraco

Description

@jaraco
 singledispatch main 🐚 tox -e finalize
finalize: install_deps> python -I -m pip install 'jaraco.develop>=7.23' towncrier
finalize: commands[0]> python -m jaraco.develop.finalize
╭─────────────────────────────────────────────────────── Traceback (most recent call last) ───────────────────────────────────────────────────────╮
│ /Users/jaraco/code/jaraco/singledispatch/.tox/finalize/lib/python3.13/site-packages/jaraco/develop/finalize.py:11 in finalize                   │
│                                                                                                                                                 │
│    8                                                                                                                                            │
│    9 @main                                                                                                                                      │
│   10 def finalize():                                                                                                                            │
│ ❱ 11 │   ver = towncrier.semver(towncrier.get_version())                                                                                        │
│   12 │   # workaround for twisted/towncrier#538                                                                                                 │
│   13 │   pathlib.Path('newsfragments').mkdir(exist_ok=True)                                                                                     │
│   14 │   towncrier.run('build', '--yes')                                                                                                        │
│                                                                                                                                                 │
│ /Users/jaraco/code/jaraco/singledispatch/.tox/finalize/lib/python3.13/site-packages/jaraco/develop/towncrier.py:65 in get_version               │
│                                                                                                                                                 │
│   62 │   >>> str(get_version())                                                                                                                 │
│   63 │   '...'                                                                                                                                  │
│   64 │   """                                                                                                                                    │
│ ❱ 65 │   return repo().get_next_version(release_kind())                                                                                         │
│   66                                                                                                                                            │
│   67                                                                                                                                            │
│   68 def run(command, *args):                                                                                                                   │
│                                                                                                                                                 │
│ /Users/jaraco/code/jaraco/singledispatch/.tox/finalize/lib/python3.13/site-packages/jaraco/develop/towncrier.py:42 in release_kind              │
│                                                                                                                                                 │
│   39 │   Determine which release to make based on the files in the                                                                              │
│   40 │   changelog.                                                                                                                             │
│   41 │   """                                                                                                                                    │
│ ❱ 42 │   bumps = map(_release_bump, news_fragments())                                                                                           │
│   43 │   # use min here as 'major' < 'minor' < 'patch'                                                                                          │
│   44 │   return min(bumps, default='patch')                                                                                                     │
│   45                                                                                                                                            │
│                                                                                                                                                 │
│ /Users/jaraco/code/jaraco/singledispatch/.tox/finalize/lib/python3.13/site-packages/jaraco/develop/towncrier.py:33 in news_fragments            │
│                                                                                                                                                 │
│   30 def news_fragments():                                                                    ╭──────────────── locals ────────────────╮        │
│   31 │   except_ = 'README.rst', '.gitignore'                                                 │ except_ = ('README.rst', '.gitignore') │        │
│   32 │   path = pathlib.Path('newsfragments')                                                 │    path = PosixPath('newsfragments')   │        │
│ ❱ 33 │   names = (file for file in path.iterdir() if file.name not in except_)                ╰────────────────────────────────────────╯        │
│   34 │   return names if path.exists() else ()                                                                                                  │
│   35                                                                                                                                            │
│   36                                                                                                                                            │
│                                                                                                                                                 │
│ /opt/homebrew/Cellar/python@3.13/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/pathlib/_local.py:575 in iterdir               │
│                                                                                                                                                 │
│   572 │   │   special entries '.' and '..' are not included.                                   ╭─────────────── locals ────────────────╮        │
│   573 │   │   """                                                                              │ root_dir = 'newsfragments'            │        │
│   574 │   │   root_dir = str(self)                                                             │     self = PosixPath('newsfragments') │        │
│ ❱ 575 │   │   with os.scandir(root_dir) as scandir_it:                                         ╰───────────────────────────────────────╯        │
│   576 │   │   │   paths = [entry.path for entry in scandir_it]                                                                                  │
│   577 │   │   if root_dir == '.':                                                                                                               │
│   578 │   │   │   paths = map(self._remove_leading_dot, paths)                                                                                  │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
FileNotFoundError: [Errno 2] No such file or directory: 'newsfragments'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions