From 6bffc7d86287fb0cd7b8495b9dcf40b243a484de Mon Sep 17 00:00:00 2001 From: Matthew Painter Date: Fri, 20 Oct 2023 01:32:33 +0100 Subject: [PATCH] Avoid throwing exception on Union types (#1378) Signed-off-by: Matthew Painter Signed-off-by: Nok --- pandera/mypy.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pandera/mypy.py b/pandera/mypy.py index 99c2c38c6..fc044edc0 100644 --- a/pandera/mypy.py +++ b/pandera/mypy.py @@ -136,7 +136,7 @@ class Schema(BaseSchema): if not hasattr(def_, "type") or def_.type is None: continue type_ = def_.type - if get_typename(def_.type) in FIELD_GENERICS_FULLNAMES: + if str(def_.type) in FIELD_GENERICS_FULLNAMES: type_.args = () # erase generic type arg @@ -154,7 +154,3 @@ def get_fullname(x: Union[FuncBase, SymbolNode]) -> str: if callable(fn): # pragma: no cover return fn() return fn - - -def get_typename(x) -> str: - return f"{x.type.module_name}.{x.type.name}"