You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks a lot for the amazing PyType you developed.
When I run the annotate_source on the following file (simplified)
from abc import ABC
from typing import Any, Callable, Generic, Iterator, List, Literal, Optional, Set, TypeVar, Union, cast
T = TypeVar("T")
V = TypeVar("V")
Factory = Optional[Callable[[object], T]] # note the argument is anything, due e.g. memory loader can inject anything
class Convert(ABC, Generic[T]):
"""A class that converts a raw type to a given tox (python) type."""
def to(self, raw: T, of_type: type[V], factory: Factory[V]) -> V: # noqa: PLR0911
"""
Convert given raw type to python type.
:param raw: the raw type
:param of_type: python type
:param factory: factory method to build the object
:return: the converted type
"""
from_module = getattr(of_type, "__module__", None)
if from_module in {"typing", "typing_extensions"}:
return self._to_typing(raw, of_type, factory)
def _to_typing(self, raw: T, of_type: type[V], factory: Factory[V]) -> V: # noqa: C901
origin = getattr(of_type, "__origin__", of_type.__class__)
if origin in {list, List}:
entry_type = of_type.__args__[0] # type: ignore[attr-defined]
result = [self.to(i, entry_type, factory) for i in self.to_list(raw, entry_type)]
PyType crashes with the traceback info:
File "/Users/fuyingbo/Desktop/into_the_wild_dev/venv/lib/python3.9/site-packages/pytype/output.py", line 312, in value_to_pytd_type
elif isinstance(v, (typing_overlay.TypeVar, typing_overlay.ParamSpec)):
pytype.tools.annotate_ast.annotate_ast.PytypeError: Pytype error: RecursionError: maximum recursion depth exceeded in __instancecheck__
I guess one potential reason behind this crash is that Convert.to might call Convert._to_typing while Convert._to_typing might also call Convert.to back, which PyType consider as an infinite recursion and crashes.
Hi,
Thanks a lot for the amazing PyType you developed.
When I run the annotate_source on the following file (simplified)
PyType crashes with the traceback info:
I guess one potential reason behind this crash is that Convert.to might call Convert._to_typing while Convert._to_typing might also call Convert.to back, which PyType consider as an infinite recursion and crashes.
The full file is at https://github.com/tox-dev/tox/blob/main/src/tox/config/loader/convert.py
I am unsure if it is a bug, but an error message might be better than crashes and thus report it.
Thanks a lot.
The text was updated successfully, but these errors were encountered: