[issue36643] Forward reference is not resolved by dataclasses.fields()

2022-03-27 Thread Eric V. Smith


Eric V. Smith  added the comment:

I agree with Jelle here: dataclasses shouldn't be calling get_type_hints().

--
resolution:  -> wont fix
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



[issue36643] Forward reference is not resolved by dataclasses.fields()

2022-01-21 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

I don't think we should merge this change. get_type_hints() is fragile and full 
of corner cases around using the right globals and locals dictionaries. 
dataclasses shouldn't execute it implicitly for you.

--
nosy: +Jelle Zijlstra
versions: +Python 3.11 -Python 3.7

___
Python tracker 

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



[issue36643] Forward reference is not resolved by dataclasses.fields()

2021-07-24 Thread Eric V. Smith


Eric V. Smith  added the comment:

Also, when dataclasses was originally written, it deliberately did not import 
typing, for performance reasons. I don't know if PEP 560 (I think) improved 
performance enough to make a difference. But adding this dependency needs to be 
looked at.

But if we are going to import typing, there are other changes that I'd like to 
make, like improving the ClassVar stuff.

--

___
Python tracker 

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



[issue36643] Forward reference is not resolved by dataclasses.fields()

2021-07-24 Thread Eric V. Smith

Eric V. Smith  added the comment:

I’m deferring any action on this until PEP 649 is ruled on.

--
assignee:  -> eric.smith

___
Python tracker 

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



[issue36643] Forward reference is not resolved by dataclasses.fields()

2021-07-24 Thread Misha Drachuk


Change by Misha Drachuk :


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

___
Python tracker 

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



[issue36643] Forward reference is not resolved by dataclasses.fields()

2021-07-22 Thread Eric V. Smith

Eric V. Smith  added the comment:

It can’t be resolved in fields(): it is still undefined when the fields are 
created. 

I think the best solution is PEP 649.

--

___
Python tracker 

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



[issue36643] Forward reference is not resolved by dataclasses.fields()

2021-07-06 Thread Paolo Lammens


Paolo Lammens  added the comment:

I was about to create the exact same ticket; I'm nudging this.

--
nosy: +plammens

___
Python tracker 

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



[issue36643] Forward reference is not resolved by dataclasses.fields()

2019-04-19 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



[issue36643] Forward reference is not resolved by dataclasses.fields()

2019-04-16 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



[issue36643] Forward reference is not resolved by dataclasses.fields()

2019-04-16 Thread Misha Drachuk


New submission from Misha Drachuk :

Forward reference is not resolved by `dataclasses.fields()`, but it works with 
`typing.get_type_hints()`.

E.g. 

from dataclasses import dataclass, fields
from typing import Optional, get_type_hints

@dataclass
class Nestable:
child: Optional['Nestable']

o = Nestable(None)
print('fields:', fields(o))
print('type hints:', get_type_hints(Nestable))

... outputs the following:
 
fields: (Field(name='child',type=typing.Union[ForwardRef('Nestable'), NoneType] 
... )
type hints: {'child': typing.Union[__main__.Nestable, NoneType]}

--
components: Library (Lib)
messages: 340361
nosy: mdrachuk
priority: normal
severity: normal
status: open
title: Forward reference is not resolved by dataclasses.fields()
type: behavior
versions: Python 3.7

___
Python tracker 

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