
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2019-10-10 15:31 bysamuelcolvin, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 16700 | closed | samuelcolvin,2019-10-10 16:00 | |
| PR 16701 | closed | serhiy.storchaka,2019-10-10 16:06 | |
| PR 16702 | merged | samuelcolvin,2019-10-10 16:09 | |
| PR 16744 | merged | miss-islington,2019-10-13 11:45 | |
| Messages (7) | |||
|---|---|---|---|
| msg354388 -(view) | Author: Samuel Colvin (samuelcolvin)* | Date: 2019-10-10 15:31 | |
The following code works fine with python 3.7 but breaks with 3.8:```import dataclassesfrom typing import Optional@dataclasses.dataclassclass 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) | |||
| msg354389 -(view) | Author: Samuel Colvin (samuelcolvin)* | Date: 2019-10-10 15:47 | |
This is a bug with the `__repr__` method on `InitVar`.I'm working on a PR now. | |||
| msg354390 -(view) | Author: Karthikeyan Singaravelan (xtreak)*![]() | Date: 2019-10-10 15:51 | |
git blame points tohttps://github.com/python/cpython/commit/01ee12ba35a333e8a6a25c4153c4a21838e9585c . I am tagging this as a 3.8 regression since the commit was not backported and 3.7 works fine. Feel free to remove it if it's a mistake. | |||
| msg354392 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2019-10-10 16:08 | |
Oh, Samuel already made a PR. Then I withdrawPR 16701. | |||
| msg354574 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2019-10-13 11:45 | |
New changeset793cb85437299a3da3d74fe65480d720af330cbb by Serhiy Storchaka (Samuel Colvin) in branch 'master':bpo-38431: Fix __repr__ method of InitVar to work with typing objects. (GH-16702)https://github.com/python/cpython/commit/793cb85437299a3da3d74fe65480d720af330cbb | |||
| msg354576 -(view) | Author: miss-islington (miss-islington) | Date: 2019-10-13 12:04 | |
New changeset6da52ac411947d1a7958bbad831fcf8dfc8c95fe by Miss Islington (bot) in branch '3.8':bpo-38431: Fix __repr__ method of InitVar to work with typing objects. (GH-16702)https://github.com/python/cpython/commit/6da52ac411947d1a7958bbad831fcf8dfc8c95fe | |||
| msg354578 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2019-10-13 12:50 | |
Thank you for your contribution Samuel! | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:21 | admin | set | github: 82612 |
| 2019-10-13 12:50:54 | serhiy.storchaka | set | status: open -> closed resolution: fixed messages: +msg354578 stage: patch review -> resolved |
| 2019-10-13 12:04:08 | miss-islington | set | nosy: +miss-islington messages: +msg354576 |
| 2019-10-13 11:45:48 | miss-islington | set | pull_requests: +pull_request16321 |
| 2019-10-13 11:45:39 | serhiy.storchaka | set | messages: +msg354574 |
| 2019-10-11 18:24:00 | levkivskyi | set | nosy: +levkivskyi |
| 2019-10-10 16:09:46 | samuelcolvin | set | pull_requests: +pull_request16288 |
| 2019-10-10 16:08:49 | serhiy.storchaka | set | nosy: +serhiy.storchaka messages: +msg354392 |
| 2019-10-10 16:06:56 | serhiy.storchaka | set | pull_requests: +pull_request16287 |
| 2019-10-10 16:00:41 | samuelcolvin | set | keywords: +patch stage: patch review pull_requests: +pull_request16286 |
| 2019-10-10 15:51:50 | xtreak | set | keywords: +3.8regression nosy: +xtreak messages: +msg354390 |
| 2019-10-10 15:47:32 | samuelcolvin | set | messages: +msg354389 |
| 2019-10-10 15:46:54 | xtreak | set | nosy: +eric.smith |
| 2019-10-10 15:31:02 | samuelcolvin | create | |