Author samuelcolvin
Recipients samuelcolvin
Date 2019-10-10.15:31:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1570721462.15.0.939525387822.issue38431@roundup.psfhosted.org>
In-reply-to
Content
The following code works fine with python 3.7 but breaks with 3.8:

```
import dataclasses
from typing import Optional

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

Exception traceback:

```
Traceback (most recent call last):
  File "test.py", line 6, in <module>
    class TestingDataclass:
  File "/usr/local/lib/python3.8/dataclasses.py", line 995, in dataclass
    return wrap(cls)
  File "/usr/local/lib/python3.8/dataclasses.py", line 987, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
  File "/usr/local/lib/python3.8/dataclasses.py", line 967, in _process_class
    str(inspect.signature(cls)).replace(' -> None', ''))
  File "/usr/local/lib/python3.8/inspect.py", line 3050, in __str__
    formatted = str(param)
  File "/usr/local/lib/python3.8/inspect.py", line 2568, in __str__
    formatannotation(self._annotation))
  File "/usr/local/lib/python3.8/inspect.py", line 1202, in formatannotation
    return repr(annotation)
  File "/usr/local/lib/python3.8/dataclasses.py", line 213, in __repr__
    return f'dataclasses.InitVar[{self.type.__name__}]'
  File "/usr/local/lib/python3.8/typing.py", 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](https://travis-ci.org/samuelcolvin/pydantic/jobs/596131963)
History
Date User Action Args
2019-10-10 15:31:02samuelcolvinsetrecipients: + samuelcolvin
2019-10-10 15:31:02samuelcolvinsetmessageid: <1570721462.15.0.939525387822.issue38431@roundup.psfhosted.org>
2019-10-10 15:31:02samuelcolvinlinkissue38431 messages
2019-10-10 15:31:01samuelcolvincreate