mohamed-chs / chatgpt-history-export-to-md

A script to effortlessly extract your entire ChatGPT data export from JSON files to nicely-formatted markdown files.
MIT License
707 stars 35 forks source link

`union` operand not supported by python `3.9` #33

Open eevmanu opened 10 months ago

eevmanu commented 10 months ago

Describe the bug The python version used in pyproject.toml

https://github.com/mohamed-chs/chatgpt-history-export-to-md/blob/627449852000f4fe96985ced13ccb3c99f621799/pyproject.toml#L22

doesn't support union type expression with | operand like here

https://github.com/mohamed-chs/chatgpt-history-export-to-md/blob/627449852000f4fe96985ced13ccb3c99f621799/convoviz/models/_message.py#L24

since this is supported since python 3.10

To Reproduce Steps to reproduce the behavior:

  1. create a new venv
  2. install convoviz
  3. run convoviz
  4. see error
Traceback (most recent call last):
  File "$HOME/.pyenv/versions/3.9.18/lib/python3.9/runpy.py", line 188, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "$HOME/.pyenv/versions/3.9.18/lib/python3.9/runpy.py", line 147, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "$HOME/.pyenv/versions/3.9.18/lib/python3.9/runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "$VENV/lib/python3.9/site-packages/convoviz/__init__.py", line 3, in <module>
    from . import configuration, data_analysis, long_runs, models, utils
  File "$VENV/lib/python3.9/site-packages/convoviz/configuration.py", line 18, in <module>
    from .models import Conversation, Message
  File "$VENV/lib/python3.9/site-packages/convoviz/models/__init__.py", line 3, in <module>
    from ._conversation import Conversation
  File "$VENV/lib/python3.9/site-packages/convoviz/models/_conversation.py", line 26, in <module>
    from ._node import Node
  File "$VENV/lib/python3.9/site-packages/convoviz/models/_node.py", line 15, in <module>
    from ._message import Message  # noqa: TCH001
  File "$VENV/lib/python3.9/site-packages/convoviz/models/_message.py", line 20, in <module>
    class MessageAuthor(BaseModel):
  File "$VENV/lib/python3.9/site-packages/pydantic/_internal/_model_construction.py", line 181, in __new__
    set_model_fields(cls, bases, config_wrapper, types_namespace)
  File "$VENV/lib/python3.9/site-packages/pydantic/_internal/_model_construction.py", line 426, in set_model_fields
    fields, class_vars = collect_model_fields(cls, bases, config_wrapper, types_namespace, typevars_map=typevars_map)
  File "$VENV/lib/python3.9/site-packages/pydantic/_internal/_fields.py", line 120, in collect_model_fields
    type_hints = get_cls_type_hints_lenient(cls, types_namespace)
  File "$VENV/lib/python3.9/site-packages/pydantic/_internal/_typing_extra.py", line 212, in get_cls_type_hints_lenient
    hints[name] = eval_type_lenient(value, globalns, localns)
  File "$VENV/lib/python3.9/site-packages/pydantic/_internal/_typing_extra.py", line 224, in eval_type_lenient
    return typing._eval_type(value, globalns, localns)  # type: ignore
  File "$HOME/.pyenv/versions/3.9.18/lib/python3.9/typing.py", line 292, in _eval_type
    return t._evaluate(globalns, localns, recursive_guard)
  File "$HOME/.pyenv/versions/3.9.18/lib/python3.9/typing.py", line 554, in _evaluate
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

Expected behavior upgrade python version on pyproject.toml or change code to be flexible with 3.9

OS