callowayproject / bump-my-version

A small command line tool to simplify releasing software by updating all version strings in your source code by the correct increment and optionally commit and tag the changes.
https://callowayproject.github.io/bump-my-version/
MIT License
349 stars 21 forks source link

AttributeError: 'NoneType' object has no attribute 'bump' #225

Closed zerothi closed 3 months ago

zerothi commented 3 months ago

Description

I am trying to get bump-my-version working for my repository: https://github.com/zerothi/sisl/

I am currently on a rc check, and hence I wanted to follow the guide for using rc etc.

What I Did

I used bump-my-version with create config and got this:

$ cat .bumpversion.toml

[tool.bumpversion]

current_version = "0.15.0rc7"
parse = """(?x)
    (?P<major>0|[1-9]\\d*)\\.
    (?P<minor>0|[1-9]\\d*)\\.
    (?P<patch>0|[1-9]\\d*)"
    (?:
        (?P<pre_l>[a-zA-Z]+)
        (?P<pre_n>[1-9]\\d*)
    )?
"""
serialize = [
    "{major}.{minor}.{patch}{pre_l}{pre_n}",
    "{major}.{minor}.{patch}",
]
search = "{current_version}"
replace = "{new_version}"
regex = true
ignore_missing_version = false
ignore_missing_files = false
tag = true
sign_tags = true
tag_name = "v{new_version}"
tag_message = "Bump version: {current_version} → {new_version}"
allow_dirty = true
commit = false
message = "Bump version: {current_version} → {new_version}"
commit_args = ""

[tool.bumpversion.parts.pre_l]
values = ["dev", "rc", "final"]
optional_value = "final"

I then did:

$> bump-my-version show-bump
Traceback (most recent call last):
  File "/home/nicpa/.local/python-3.11-gnu-12.3.0/bin/bump-my-version", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/home/nicpa/.local/python-3.11-gnu-12.3.0/lib/python3.11/site-packages/rich_click/rich_command.py", line 367, in __call__
    return super().__call__(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/gnu/12.3.0/python/3.11.7/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nicpa/.local/python-3.11-gnu-12.3.0/lib/python3.11/site-packages/rich_click/rich_command.py", line 152, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/gnu/12.3.0/python/3.11.7/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/gnu/12.3.0/python/3.11.7/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/gnu/12.3.0/python/3.11.7/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nicpa/.local/python-3.11-gnu-12.3.0/lib/python3.11/site-packages/bumpversion/cli.py", line 585, in show_bump
    visualize(config=config, version_str=version, box_style=box_style)
  File "/home/nicpa/.local/python-3.11-gnu-12.3.0/lib/python3.11/site-packages/bumpversion/visualize.py", line 128, in visualize
    next_version = get_next_version(version, config, part, None)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nicpa/.local/python-3.11-gnu-12.3.0/lib/python3.11/site-packages/bumpversion/bump.py", line 47, in get_next_version
    next_version = current_version.bump(version_part)
                   ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'bump'

Any ideas?

coordt commented 3 months ago

I'll look into it this morning. You might want to use the -vv flag to have it show more information to see where it is failing. I need to have better error checking in there anyway.

If you can add in the verbose (-vv) results in here, it will help.

zerothi commented 3 months ago

I'll look into it this morning. You might want to use the -vv flag to have it show more information to see where it is failing. I need to have better error checking in there anyway.

Thanks!

If you can add in the verbose (-vv) results in here, it will help.

Erhm... I don't think -vv works?

$>  bump-my-version -vv show-bump

 Usage: bump-my-version [OPTIONS] COMMAND [ARGS]...                           

 Try 'bump-my-version -h' for help                                            
╭─ Error ────────────────────────────────────────────────────────────────────╮
│ No such option: -v                                                         │
╰────────────────────────────────────────────────────────────────────────────╯

and

 bump-my-version show-bump -vv

 Usage: bump-my-version show-bump [OPTIONS] [VERSION]                         

 Try 'bump-my-version show-bump -h' for help                                  
╭─ Error ────────────────────────────────────────────────────────────────────╮
│ No such option: -v                                                         │
╰────────────────────────────────────────────────────────────────────────────╯

And:

$> bump-my-version show
{'allow_dirty': True,
 'commit': False,
 'commit_args': '',
 'current_version': '0.15.0',
 'excluded_paths': [],
 'files': [],
 'ignore_missing_files': False,
 'ignore_missing_version': False,
 'included_paths': [],
 'message': 'Bump version: {current_version} → {new_version}',
 'parse': '(?x)\n'
          '    (?P<major>0|[1-9]\\d*)\\.\n'
          '    (?P<minor>0|[1-9]\\d*)\\.\n'
          '    (?P<patch>0|[1-9]\\d*)"\n'
          '    (?:\n'
          '        (?P<pre_l>[a-zA-Z]+)\n'
          '        (?P<pre_n>[1-9]\\d*)\n'
          '    )?\n',
 'parts': {'major': {'always_increment': False,
                     'calver_format': None,
                     'depends_on': None,
                     'first_value': None,
                     'independent': False,
                     'optional_value': None,
                     'values': None},
           'minor': {'always_increment': False,
                     'calver_format': None,
                     'depends_on': None,
                     'first_value': None,
                     'independent': False,
                     'optional_value': None,
                     'values': None},
           'patch': {'always_increment': False,
                     'calver_format': None,
                     'depends_on': None,
                     'first_value': None,
                     'independent': False,
                     'optional_value': None,
                     'values': None},
           'pre_l': {'always_increment': False,
                     'calver_format': None,
                     'depends_on': None,
                     'first_value': None,
                     'independent': False,
                     'optional_value': 'final',
                     'values': ['dev', 'rc', 'final']},
           'pre_n': {'always_increment': False,
                     'calver_format': None,
                     'depends_on': None,
                     'first_value': None,
                     'independent': False,
                     'optional_value': None,
                     'values': None}},
 'regex': True,
 'replace': '{new_version}',
 'scm_info': {'branch_name': 'main',
              'commit_sha': '2157c89ff96682da25a0db6a36ecb562b6dbc7d4',
              'current_version': '0.15.0',
              'dirty': False,
              'distance_to_latest_tag': 1,
              'repository_root': PosixPath('/home/nicpa/codes/sisl'),
              'short_branch_name': 'main',
              'tool': <class 'bumpversion.scm.Git'>},
 'search': '{current_version}',
 'serialize': ('{major}.{minor}.{patch}{pre_l}{pre_n}',
               '{major}.{minor}.{patch}'),
 'sign_tags': True,
 'tag': True,
 'tag_message': 'Bump version: {current_version} → {new_version}',
 'tag_name': 'v{new_version}'}
coordt commented 3 months ago

Crap, you are right. Verbose logging isn't set on the show-bump command.

coordt commented 3 months ago

OK, I have your problem. In your configuration:

[tool.bumpversion]

current_version = "0.15.0rc7"
parse = """(?x)
    (?P<major>0|[1-9]\\d*)\\.
    (?P<minor>0|[1-9]\\d*)\\.
    (?P<patch>0|[1-9]\\d*)"
    (?:
        (?P<pre_l>[a-zA-Z]+)
        (?P<pre_n>[1-9]\\d*)
    )?
"""

You have an " at the end of 4th line of the parse configuration.

I'm also going to fix the exception and have a good error.

zerothi commented 3 months ago

OK, I have your problem. In your configuration:

[tool.bumpversion]

current_version = "0.15.0rc7"
parse = """(?x)
    (?P<major>0|[1-9]\\d*)\\.
    (?P<minor>0|[1-9]\\d*)\\.
    (?P<patch>0|[1-9]\\d*)"
    (?:
        (?P<pre_l>[a-zA-Z]+)
        (?P<pre_n>[1-9]\\d*)
    )?
"""

You have an " at the end of 4th line of the parse configuration.

I'm also going to fix the exception and have a good error.

Thanks! I had completely missed that ;)