atom
atom copied to clipboard
Fix handling of TypeVar with an object bound
Because this result in having object in types we use a Value member but the parameters are not empty causing an error when instantiating the member. We should at least reset the parameters in such a case.
Example:
from typing import TypeVar
from atom.api import Atom
T = TypeVar("T")
class A(Atom):
a: T
Error:
Traceback (most recent call last):
File "C:\Users\matthieu.dartiailh\Documents\Coding\BugsRepro\atom\unbound_typevar.py", line 10, in <module>
class A(Atom):
File "c:\users\matthieu.dartiailh\documents\coding\projects\atom\atom\atom.py", line 283, in __new__
generate_members_from_cls_namespace(name, dct, type_containers)
File "c:\users\matthieu.dartiailh\documents\coding\projects\atom\atom\annotation_utils.py", line 136, in generate_members_from_cls_namespace
namespace[name] = generate_member_from_type_or_generic(
File "c:\users\matthieu.dartiailh\documents\coding\projects\atom\atom\annotation_utils.py", line 102, in generate_member_from_type_or_generic
return m_cls(*parameters, **m_kwargs)
File "c:\users\matthieu.dartiailh\documents\coding\projects\atom\atom\instance.py", line 85, in __init__
self.set_validate_mode(Validate.Instance, kind)
TypeError: Expected type or tuple of types. Got a tuple containing an instance of `TypeVar` instead.
Closed by #194 and #207