[issue38431] dataclasses.InitVar breaks with typing.Optional

2019-10-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Thank you for your contribution Samuel!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38431] dataclasses.InitVar breaks with typing.Optional

2019-10-13 Thread miss-islington


miss-islington  added the comment:


New changeset 6da52ac411947d1a7958bbad831fcf8dfc8c95fe 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


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38431] dataclasses.InitVar breaks with typing.Optional

2019-10-13 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 793cb85437299a3da3d74fe65480d720af330cbb 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


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38431] dataclasses.InitVar breaks with typing.Optional

2019-10-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16321
pull_request: https://github.com/python/cpython/pull/16744

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38431] dataclasses.InitVar breaks with typing.Optional

2019-10-11 Thread Ivan Levkivskyi


Change by Ivan Levkivskyi :


--
nosy: +levkivskyi

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38431] dataclasses.InitVar breaks with typing.Optional

2019-10-10 Thread Samuel Colvin


Change by Samuel Colvin :


--
pull_requests: +16288
pull_request: https://github.com/python/cpython/pull/16702

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38431] dataclasses.InitVar breaks with typing.Optional

2019-10-10 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Oh, Samuel already made a PR. Then I withdraw PR 16701.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38431] dataclasses.InitVar breaks with typing.Optional

2019-10-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +16287
pull_request: https://github.com/python/cpython/pull/16701

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38431] dataclasses.InitVar breaks with typing.Optional

2019-10-10 Thread Samuel Colvin


Change by Samuel Colvin :


--
keywords: +patch
pull_requests: +16286
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/16700

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38431] dataclasses.InitVar breaks with typing.Optional

2019-10-10 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

git blame points to 
https://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.

--
keywords: +3.8regression
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38431] dataclasses.InitVar breaks with typing.Optional

2019-10-10 Thread Samuel Colvin


Samuel Colvin  added the comment:

This is a bug with the `__repr__` method on `InitVar`.

I'm working on a PR now.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38431] dataclasses.InitVar breaks with typing.Optional

2019-10-10 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38431] dataclasses.InitVar breaks with typing.Optional

2019-10-10 Thread Samuel Colvin


New submission from Samuel Colvin :

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 
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)

--
components: Library (Lib)
messages: 354388
nosy: samuelcolvin
priority: normal
severity: normal
status: open
title: dataclasses.InitVar breaks with typing.Optional
type: behavior
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com