py-doq icon indicating copy to clipboard operation
py-doq copied to clipboard

Import error from removal of soft_unicode

Open Icantjuddle opened this issue 1 year ago • 1 comments

See issue here: https://github.com/pallets/markupsafe/issues/304

Traceback (most recent call last):
  File "<redacted>/bin/doq", line 5, in <module>
    from doq.cli import main
  File "<redacted>/lib/python3.10/site-packages/doq/__init__.py", line 7, in <module>
    from doq.template import Template  # noqa F401
  File "<redacted>//lib/python3.10/site-packages/doq/template.py", line 1, in <module>
    from jinja2 import (
  File "<redacted>//lib/python3.10/site-packages/jinja2/__init__.py", line 33, in <module>
    from jinja2.environment import Environment, Template
  File "<redacted>//lib/python3.10/site-packages/jinja2/environment.py", line 15, in <module>
    from jinja2 import nodes
  File "<redacted>//lib/python3.10/site-packages/jinja2/nodes.py", line 19, in <module>
    from jinja2.utils import Markup
  File "<redacted>//lib/python3.10/site-packages/jinja2/utils.py", line 647, in <module>
    from markupsafe import Markup, escape, soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (<redacted>//lib/python3.10/site-packages/markupsafe/__init__.py)

Icantjuddle avatar Feb 14 '24 19:02 Icantjuddle

@Icantjuddle Thank you for report. Could you show me step to reproduce?

In my local works fine.

$ git clone https://github.com/heavenshell/py-doq.git
$ cd py-doq
$ python -m venv .venv
$ source .venv/bin/activate
$ pip install -r requirements.txt
...
Successfully installed GitPython-3.1.42 MarkupSafe-2.1.5 PyYAML-6.0.1 bandit-1.7.6 flake8-6.1.0
flake8-coding-1.3.2 flake8-commas-2.1.0 flake8-comprehensions-3.14.0 flake8-debugger-4.1.2
flake8-docstrings-1.7.0 flake8-import-order-0.18.2 flake8-print-5.0.0 flake8-string-format-0.3.0 gitdb-4.0.11
iniconfig-2.0.0 jinja2-3.1.2 markdown-it-py-3.0.0 mccabe-0.7.0 mdurl-0.1.2 packaging-23.2 
parameterized-0.9.0 parso-0.8.3 pbr-6.0.0 pep8-naming-0.13.3 pluggy-1.4.0 pycodestyle-2.11.1
pydocstyle-6.3.0 pyflakes-3.1.0 pygments-2.17.2 pytest-7.4.3 rich-13.7.0 smmap-5.0.1
snowballstemmer-2.2.0 stevedore-5.2.0 toml-0.10.2

$ cat sample.py
def foo(arg1: str, arg2: str) -> str:
    return arg1 + arg2cat sample.py | python -m doq.cli
$ cat sample.py | python -m doq.cli              
def foo(arg1: str, arg2: str) -> str:
    """foo.

    :param arg1:
    :type arg1: str
    :param arg2:
    :type arg2: str
    :rtype: str
    """
    return arg1 + arg2

heavenshell avatar Feb 23 '24 17:02 heavenshell

I looked deeper into it and it is an issue squarely with Jinja not bounding their dependencies: details here, https://github.com/pallets/jinja/issues/1805

Another package wanted a lower version of Jinja so after making a few upgrades everything works.

Thanks for responding (and making this tool)!

Icantjuddle avatar May 06 '24 14:05 Icantjuddle