Skip to content

Python 3.10 compatibility of :AIimage #169

Open
@Konfekt

Description

@Konfekt

Hello,

Being still stuck on Ubuntu 22.04 with Python 3.10.12 by default which missees datetime.UTC available only in > 3.10, could a backward compatible import

import datetime

try:
    utc = datetime.UTC  # Python 3.11+
except AttributeError:
    utc = datetime.timezone.utc  # Older versions

timestamp = datetime.datetime.now(utc).strftime("%Y%m%dT%H%M%SZ")

in image.py be considered to avoid

Messages maintainer: The Vim Project
Generating...
Error detected while processing function vim_ai#AIImageRun:
line   24:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/konfekt/.config/.vim/plugged/vim-ai/py/image.py", line 38, in run_ai_image
    handle_completion_error(config['provider'], error)
  File "/home/konfekt/.config/.vim/plugged/vim-ai/py/utils.py", line 277, in handle_completion_error
    raise error
  File "/home/konfekt/.config/.vim/plugged/vim-ai/py/image.py", line 31, in run_ai_image
    path = make_image_path(ui)
  File "/home/konfekt/.config/.vim/plugged/vim-ai/py/image.py", line 9, in make_image_path
    timestamp = datetime.datetime.now(datetime.UTC).strftime("%Y%m%dT%H%M%SZ")
AttributeError: module 'datetime' has no attribute 'UTC'

?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions