hunyadi / md2conf

Publish Markdown files to Confluence wiki
MIT License
52 stars 27 forks source link

AttributeError: 'str' object has no attribute 'removeprefix' #1

Closed theophile-scrive closed 1 year ago

theophile-scrive commented 1 year ago

Hi! When trying to use md2conf in a GitHub action I am getting this error:

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/runner/.local/lib/python3.8/site-packages/md2conf/__main__.py", line 59, in <module>
    synchronize_page(api, args.mdfile)
  File "/home/runner/.local/lib/python3.8/site-packages/md2conf/application.py", line 28, in synchronize_page
    update_document(api, document, base_path)
  File "/home/runner/.local/lib/python3.8/site-packages/md2conf/application.py", line [11](https://github.com/scrive/…#step:5:12), in update_document
    api.upload_attachment(
  File "/home/runner/.local/lib/python3.8/site-packages/md2conf/api.py", line 240, in upload_attachment
    self._update_attachment(page_id, attachment_id, version, attachment_name)
  File "/home/runner/.local/lib/python3.8/site-packages/md2conf/api.py", line 245, in _update_attachment
    id = attachment_id.removeprefix("att")
AttributeError: 'str' object has no attribute 'removeprefix'

Is it something I can fix on my end?

hunyadi commented 1 year ago

The function removeprefix was introduced in Python 3.9. If you have an older version of Python (the error trace says you have Python 3.8), you might need to substitute that function call with a polyfill.

theophile-scrive commented 1 year ago

Got it, thank you!

hunyadi commented 1 year ago

I have added such a polyfill function for removeprefix in the latest commit to master. This will be included in the next release published to PyPI.