Two tests are failing with python 3.8 on CI:
test_initvars_post_inittest_initvars_post_init_post_parseWe should fix this since 3.8 is close to release. Any help would be much appreciated, I'll looked quickly but can't quite seem what's wrong.
traceback:
โโโโโโโโโโโโโโโโโโโโโโ test_initvars_post_init_post_parse โโโโโโโโโโโโโโโโโโโโโโ
def test_initvars_post_init_post_parse():
@pydantic.dataclasses.dataclass
> class PathDataPostInitPostParse:
tests/test_dataclasses.py:504:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pydantic/dataclasses.py:137: in dataclass
return wrap(_cls)
pydantic/dataclasses.py:132: in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen, config)
pydantic/dataclasses.py:84: in _process_class
cls = dataclasses._process_class(_cls, init, repr, eq, order, unsafe_hash, frozen) # type: ignore
/opt/python/3.8-dev/lib/python3.8/dataclasses.py:967: in _process_class
str(inspect.signature(cls)).replace(' -> None', ''))
/opt/python/3.8-dev/lib/python3.8/inspect.py:3050: in __str__
formatted = str(param)
/opt/python/3.8-dev/lib/python3.8/inspect.py:2568: in __str__
formatannotation(self._annotation))
/opt/python/3.8-dev/lib/python3.8/inspect.py:1202: in formatannotation
return repr(annotation)
/opt/python/3.8-dev/lib/python3.8/dataclasses.py:213: in __repr__
return f'dataclasses.InitVar[{self.type.__name__}]'
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = typing.Union[pathlib.Path, NoneType], attr = '__name__'
def __getattr__(self, attr):
# We are careful for copy and pickle.
# Also for simplicity we just don't relay all dunder names
if '__origin__' in self.__dict__ and not _is_dunder(attr):
return getattr(self.__origin__, attr)
> raise AttributeError(attr)
E AttributeError: __name__
/opt/python/3.8-dev/lib/python3.8/typing.py:757: AttributeError
I gusses this is a bug on python3.8 rc1.
It's happened error when we call repr() with InitVar include Optional
python3.8 --version
Python 3.8.0rc1
from dataclasses import InitVar
from typing import Optional
print(repr(InitVar[str])) # no error
# > 'dataclasses.InitVar[str]'
print(repr(InitVar[Optional[str]])) # error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/dataclasses.py", line 213, in __repr__
return f'dataclasses.InitVar[{self.type.__name__}]'
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/typing.py", line 757, in __getattr__
raise AttributeError(attr)
AttributeError: __name__
PR:
https://github.com/python/cpython/commit/01ee12ba35a333e8a6a25c4153c4a21838e9585c
changelog:
https://docs.python.org/3.8/whatsnew/changelog.html#python-3-8-0-release-candidate-1
yes, I just created an issue.
Working on a fix now.
Great work!!
It was too late to watch the code ๐คฃ
merged and backported to 3.8, just waiting for the new rc to close this.
Most helpful comment
merged and backported to 3.8, just waiting for the new rc to close this.