reuse-tool icon indicating copy to clipboard operation
reuse-tool copied to clipboard

AttributeError: `TypeVar` object attribute `__doc__` is read-only

Open sschuberth opened this issue 3 years ago • 4 comments

Out of a sudden we start getting error with Python 3.6.15, running reuse in a GitHub action:

Collecting reuse
  Downloading reuse-0.13.0-py3-none-any.whl (140 kB)
Collecting binaryornot
  Downloading binaryornot-0.4.4-py2.py3-none-any.whl (9.0 kB)
Collecting license-expression
  Downloading license_expression-21.6.14-py3-none-any.whl (86 kB)
Collecting requests
  Downloading requests-2.26.0-py2.py3-none-any.whl (62 kB)
Collecting boolean.py
  Downloading boolean.py-3.8-py2.py3-none-any.whl (23 kB)
Collecting python-debian
  Downloading python_debian-0.1.42-py3-none-any.whl (118 kB)
Collecting Jinja2
  Downloading Jinja2-3.0.2-py3-none-any.whl (133 kB)
Collecting chardet>=3.0.2
  Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)
Collecting MarkupSafe>=2.0
  Downloading MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (30 kB)
Collecting certifi>=2017.4.17
  Downloading certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.7-py2.py3-none-any.whl (138 kB)
Collecting idna<4,>=2.5
  Downloading idna-3.3-py3-none-any.whl (61 kB)
Collecting charset-normalizer~=2.0.0
  Downloading charset_normalizer-2.0.7-py3-none-any.whl (38 kB)
Installing collected packages: urllib3, MarkupSafe, idna, charset-normalizer, chardet, certifi, boolean.py, requests, python-debian, license-expression, Jinja2, binaryornot, reuse
Successfully installed Jinja2-3.0.2 MarkupSafe-2.0.1 binaryornot-0.4.4 boolean.py-3.8 certifi-2021.10.8 chardet-4.0.0 charset-normalizer-2.0.7 idna-3.3 license-expression-21.6.14 python-debian-0.1.42 requests-2.26.0 reuse-0.13.0 urllib3-1.26.7
WARNING: You are using pip version 21.2.4; however, version 21.3 is available.
You should consider upgrading via the '/opt/hostedtoolcache/Python/3.6.15/x64/bin/python -m pip install --upgrade pip' command.
Traceback (most recent call last):
  File "/home/runner/.local/bin/reuse", line 5, in <module>
    from reuse._main import main
  File "/home/runner/.local/lib/python3.6/site-packages/reuse/_main.py", line 14, in <module>
    from . import (
  File "/home/runner/.local/lib/python3.6/site-packages/reuse/download.py", line 18, in <module>
    from ._util import (
  File "/home/runner/.local/lib/python3.6/site-packages/reuse/_util.py", line 26, in <module>
    from debian.copyright import Copyright
  File "/home/runner/.local/lib/python3.6/site-packages/debian/copyright.py", line 57, in <module>
    from debian import deb822
  File "/home/runner/.local/lib/python3.6/site-packages/debian/deb822.py", line 309, in <module>
    from debian._util import (
  File "/home/runner/.local/lib/python3.6/site-packages/debian/_util.py", line 15, in <module>
    """
AttributeError: 'TypeVar' object attribute '__doc__' is read-only
Error: Process completed with exit code 1.

Any idea what might cause this?

sschuberth avatar Oct 18 '21 16:10 sschuberth

Downgrading the python-debian dependency to 0.1.40 instead of 0.1.42 seems to fix the issue.

pietroalbini avatar Oct 19 '21 08:10 pietroalbini

@mxmehl - yikes; two python-debian errors in one day!

This is likely a result of the recent (last week) commit to python-debian which moved various functions nearer to the project root and adds a 'docstring' directly (something which isn't allowed in various cases):

T = TypeVar('T')
T.__doc__ = """
Generic type
"""

Since this an upstream error, I'll look into fixing it in the python-debian repository :)

seabass-labrax avatar Oct 19 '21 14:10 seabass-labrax

Since this an upstream error, I'll look into fixing it in the python-debian repository :)

Any update on this @seabass-labrax? Or is the situation any better with Ubuntu 22.04?

sschuberth avatar Aug 14 '22 07:08 sschuberth

Or is the situation any better with Ubuntu 22.04?

Yes it is: This issue does not occur anymore with Ubuntu 22.04 and Python 3.10.

sschuberth avatar Aug 14 '22 07:08 sschuberth

Great. I will close this issue and hope that the improvements tickle down on more recent platforms.

mxmehl avatar Aug 15 '22 12:08 mxmehl