c4urself / bump2version

Version-bump your software with a single command
https://pypi.python.org/pypi/bump2version
MIT License
1.05k stars 135 forks source link

TypeError: 'NoneType' object is not iterable` #93

Open cbartholomee opened 4 years ago

cbartholomee commented 4 years ago

When executing I get the following error:

$ bump2version  part minor --new-version 4.11.0
Traceback (most recent call last):
  File "/usr/local/bin/bump2version", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/bumpversion/cli.py", line 107, in main
    _check_files_contain_version(files, current_version, context)
  File "/usr/local/lib/python2.7/dist-packages/bumpversion/cli.py", line 587, in _check_files_contain_version
    f.should_contain_version(current_version, context)
  File "/usr/local/lib/python2.7/dist-packages/bumpversion/utils.py", line 46, in should_contain_version
    context["current_version"] = self._versionconfig.serialize(version, context)
  File "/usr/local/lib/python2.7/dist-packages/bumpversion/version_part.py", line 282, in serialize
    version, self._choose_serialize_format(version, context), context
  File "/usr/local/lib/python2.7/dist-packages/bumpversion/version_part.py", line 262, in _choose_serialize_format
    version, serialize_format, context, raise_if_incomplete=True
  File "/usr/local/lib/python2.7/dist-packages/bumpversion/version_part.py", line 205, in _serialize
    for k in version:
TypeError: 'NoneType' object is not iterable
cbartholomee commented 4 years ago

Never mind found the issue, command should be: $ bump2version --current-version 4.11.0 --new-version 4.12.0 minor

2 remarks:

  1. to my opinion a wrong syntax should never print a stacktrace
  2. --current-version is a required option, which it should only be during initialisation
ekohl commented 4 years ago

I agree. The method needs a if not current_version with the proper error message (Failed to detect current version or similar). Would you be willing to provide a patch?

cbartholomee commented 4 years ago

About my second remark: I found out my mistake. I should create a .bumpversion.cfg file. RTFM ... :-)

cbartholomee commented 4 years ago

@ekohl I'm not a python dev, but I can have a look

ThomasWaldmann commented 2 years ago

Stumbled over the same issue right now...

In my case, I was just not in the toplevel project directory, but in ./docs ...

gogo2464 commented 1 year ago

I have the same error as well. We must solve this as soon as possible!