Author samuelcolvin
Recipients samuelcolvin
Date 2019-10-10.15:31:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The following code works fine with python 3.7 but breaks with 3.8:

import dataclasses
from typing import Optional

class TestingDataclass:
    base_path: dataclasses.InitVar[Optional[str]] = None

Exception traceback:

Traceback (most recent call last):
  File "", line 6, in <module>
    class TestingDataclass:
  File "/usr/local/lib/python3.8/", line 995, in dataclass
    return wrap(cls)
  File "/usr/local/lib/python3.8/", line 987, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
  File "/usr/local/lib/python3.8/", line 967, in _process_class
    str(inspect.signature(cls)).replace(' -> None', ''))
  File "/usr/local/lib/python3.8/", line 3050, in __str__
    formatted = str(param)
  File "/usr/local/lib/python3.8/", line 2568, in __str__
  File "/usr/local/lib/python3.8/", line 1202, in formatannotation
    return repr(annotation)
  File "/usr/local/lib/python3.8/", line 213, in __repr__
    return f'dataclasses.InitVar[{self.type.__name__}]'
  File "/usr/local/lib/python3.8/", line 757, in __getattr__
    raise AttributeError(attr)
AttributeError: __name__

The code runs fine with `str` instead of `Optional[str]`.

Tested locally with `Python 3.8.0rc1 (tags/v3.8.0rc1:34214de6ab, Oct 10 2019, 16:15:14)`. The same error can be seen (in a more involved context) on travis [here](
Date User Action Args
2019-10-10 15:31:02samuelcolvinsetrecipients: + samuelcolvin
2019-10-10 15:31:02samuelcolvinsetmessageid: <>
2019-10-10 15:31:02samuelcolvinlinkissue38431 messages
2019-10-10 15:31:01samuelcolvincreate