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

TypeError: unsupported operand type(s) for |: 'type' and 'type' on Python 3.8 #296

Closed
andy-maier opened this issue Feb 8, 2025 · 1 comment · Fixed by #297
Closed

TypeError: unsupported operand type(s) for |: 'type' and 'type' on Python 3.8 #296

andy-maier opened this issue Feb 8, 2025 · 1 comment · Fixed by #297

Comments

@andy-maier
Copy link

andy-maier commented Feb 8, 2025

We have to use Python 3.8 at the moment, and on that Python version, bump-my-version 0.30.0 is the latest version that supports it.
That's why that version gets installed on Python 3.8 when no other constraints are specified.

Using bump-my-version then leads to the following exception:

$ python3 -m bumpversion bump --new-version 0.0.1-a11.dev2 patch --no-tag --no-commit --allow-dirty
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/[email protected]/3.8.19/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Cellar/[email protected]/3.8.19/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/maiera/virtualenvs/fos38/lib/python3.8/site-packages/bumpversion/__main__.py", line 3, in <module>
    from bumpversion.cli import cli
  File "/Users/maiera/virtualenvs/fos38/lib/python3.8/site-packages/bumpversion/cli.py", line 12, in <module>
    from bumpversion.bump import do_bump
  File "/Users/maiera/virtualenvs/fos38/lib/python3.8/site-packages/bumpversion/bump.py", line 6, in <module>
    from bumpversion.hooks import run_post_commit_hooks, run_pre_commit_hooks, run_setup_hooks
  File "/Users/maiera/virtualenvs/fos38/lib/python3.8/site-packages/bumpversion/hooks.py", line 8, in <module>
    from bumpversion.config.models import Config
  File "/Users/maiera/virtualenvs/fos38/lib/python3.8/site-packages/bumpversion/config/__init__.py", line 8, in <module>
    from bumpversion.config.models import Config
  File "/Users/maiera/virtualenvs/fos38/lib/python3.8/site-packages/bumpversion/config/models.py", line 14, in <module>
    from bumpversion.versioning.models import VersionComponentSpec  # NOQA: TC001
  File "/Users/maiera/virtualenvs/fos38/lib/python3.8/site-packages/bumpversion/versioning/models.py", line 12, in <module>
    from bumpversion.utils import key_val_string
  File "/Users/maiera/virtualenvs/fos38/lib/python3.8/site-packages/bumpversion/utils.py", line 132, in <module>
    def is_subpath(parent: Path | str, path: Path | str) -> bool:
TypeError: unsupported operand type(s) for |: 'type' and 'type'

Version 0.29.0 runs fine on Python 3.8 with that command.

This SO article https://stackoverflow.com/a/33945518/1424462 states that the | syntax requires Python 3.10, and the Python docs also state that here: https://docs.python.org/3/library/stdtypes.html#union-type

So I checked out how it works on Python 3.9:

I can reproduce the above error and in some cases that error on a different source location on Python 3.9 with bump-my-version versions between 0.30.0 and 0.31.0. Version 0.31.1 and higher work on Python 3.9.

My request is:

  1. Please yank version 0.30.0 on Pypi, because users get that version by default on Python 3.8, and the prior version 0.29.0 works on Python 3.8. My current circumvention is to specify bump-my-version==0.29.0.

  2. For the sake of Python 3.9 users, you could also yank versions 0.30.1, 0.30.2, and 0.31.0. However, this change is not so important, because the default version for Python 3.9 is above these versions and works fine.

@coordt coordt linked a pull request Feb 10, 2025 that will close this issue
@andy-maier
Copy link
Author

andy-maier commented Mar 4, 2025

Just for the record: PR #297 was released in version 0.32.1.
Thanks!!

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.

1 participant