Skip to content
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

glob fail to locate file and raise TypeError exception #65

Closed
kdeldycke opened this issue Sep 6, 2023 · 2 comments
Closed

glob fail to locate file and raise TypeError exception #65

kdeldycke opened this issue Sep 6, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@kdeldycke
Copy link
Collaborator

  • bump-my-version version: 0.10.0
  • Python version: 3.11.15
  • Operating System: macOS

Description

The glob pattern doesn't seems to locate the file I am looking for and end up in an exception.

What I Did

Given this changelog.md file:

# Changelog

## {gh}`4.7.1 (unreleased) <compare/v4.7.0...main>`

- Rely on `bump-my-version` to update metadata.

Associated with this pyproject.toml configuration:

[tool.bumpversion]
current_version = "4.7.1"

[[tool.bumpversion.files]]
glob = "./**/changelog.md"
no_regex = true
search = " (unreleased)"
replace = " ({now:%Y-%m-%d})"

The two files are in the same folder:

$ ls -lah
Permissions Size User Date Modified    Name
drwxr-xr-x     - kde  2023-09-06 15:22 .
drwxr-xr-x     - root 2023-08-18 00:24 ..
.rw-r--r--   114 kde  2023-09-06 11:37 changelog.md
.rw-r--r--   171 kde  2023-09-06 15:16 pyproject.toml

Trying to bump the version with:

$ bump-my-version --verbose --dry-run patch

WARNING:

Calling bumpversion without a subcommand is deprecated. Please use `bumpversion bump` instead

Starting BumpVersion 0.10.0                                                                                                                                                                                         
Reading config file pyproject.toml:                                                                                                                                                                                 
Parsing version '4.7.1' using regexp '(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)'                                                                                                                               
Parsed the following values: major=4, minor=7, patch=1                                                                                                                                                              
Attempting to increment part 'patch'                                                                                                                                                                                
Values are now: major=4, minor=7, patch=2                                                                                                                                                                           
New version will be '4.7.2'                                                                                                                                                                                         
Dry run active, won't touch any files.                                                                                                                                                                              
Asserting files None contain the version string...  

I end up with this exception:

Traceback (most recent call last):
  File "/Users/kde/.local/bin/bump-my-version", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/kde/.local/pipx/venvs/bump-my-version/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kde/.local/pipx/venvs/bump-my-version/lib/python3.11/site-packages/rich_click/rich_group.py", line 21, in main
    rv = super().main(*args, standalone_mode=False, **kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kde/.local/pipx/venvs/bump-my-version/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/kde/.local/pipx/venvs/bump-my-version/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kde/.local/pipx/venvs/bump-my-version/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kde/.local/pipx/venvs/bump-my-version/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kde/.local/pipx/venvs/bump-my-version/lib/python3.11/site-packages/bumpversion/cli.py", line 309, in bump
    do_bump(version_part, new_version, config, found_config_file, dry_run)
  File "/Users/kde/.local/pipx/venvs/bump-my-version/lib/python3.11/site-packages/bumpversion/bump.py", line 83, in do_bump
    modify_files(configured_files, version, next_version, ctx, dry_run)
  File "/Users/kde/.local/pipx/venvs/bump-my-version/lib/python3.11/site-packages/bumpversion/files.py", line 212, in modify_files
    _check_files_contain_version(files, current_version, context)
  File "/Users/kde/.local/pipx/venvs/bump-my-version/lib/python3.11/site-packages/bumpversion/files.py", line 227, in _check_files_contain_version
    f.contains_version(current_version, context)
  File "/Users/kde/.local/pipx/venvs/bump-my-version/lib/python3.11/site-packages/bumpversion/files.py", line 68, in contains_version
    if self.contains(search_expression):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kde/.local/pipx/venvs/bump-my-version/lib/python3.11/site-packages/bumpversion/files.py", line 94, in contains
    contents = self.get_file_contents()
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kde/.local/pipx/venvs/bump-my-version/lib/python3.11/site-packages/bumpversion/files.py", line 39, in get_file_contents
    with open(self.path, "rt", encoding="utf-8") as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not NoneType

Instead, I expect bump-my-version to locate the changelog.md file and perform the search and replace action configured in the TOML file.

@kdeldycke kdeldycke added the bug Something isn't working label Sep 6, 2023
@HungryJoe
Copy link

HungryJoe commented Oct 26, 2023

I'm getting the same behavior.

  • bump-my-version version: 0.11.0
  • Python version: 3.10.12
  • Operating System: macOS 13.6

HungryJoe pushed a commit to HungryJoe/bump-my-version that referenced this issue Oct 26, 2023
coordt added a commit that referenced this issue Oct 28, 2023
Fixed bug #65 where glob'd files weren't used
@kdeldycke
Copy link
Collaborator Author

This issue has been fixed by #83 and can be closed.

kdeldycke added a commit to kdeldycke/click-extra that referenced this issue Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants