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

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

Closed
zerothi opened this issue Aug 13, 2024 · 5 comments · Fixed by #226
Closed

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

zerothi opened this issue Aug 13, 2024 · 5 comments · Fixed by #226

Comments

@zerothi
Copy link

zerothi commented Aug 13, 2024

  • bump-my-version version: 0.25.2
  • Python version: 3.11.7
  • Operating System: debian

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
Copy link
Member

coordt commented Aug 13, 2024

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
Copy link
Author

zerothi commented Aug 13, 2024

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
Copy link
Member

coordt commented Aug 13, 2024

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

@coordt
Copy link
Member

coordt commented Aug 13, 2024

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.

@coordt coordt linked a pull request Aug 13, 2024 that will close this issue
@zerothi
Copy link
Author

zerothi commented Aug 14, 2024

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 ;)

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

Successfully merging a pull request may close this issue.

2 participants