@@ -967,35 +967,18 @@ def evolve_function_sig_callback(ctx: mypy.plugin.FunctionSigContext) -> Callabl
967967 return ctx .default_signature # evolve(Any, ....) -> Any
968968 # We stringify it first, so that TypeVars maintain their name.
969969 inst_type_str = format_type_bare (inst_type )
970- if isinstance (inst_type , TypeVarType ):
971- attrs_type = inst_type .upper_bound
972- if not isinstance (attrs_type , Instance ):
973- ctx .api .fail (
974- f'Argument 1 to "evolve" has a variable type "{ inst_type_str } " with unexpected upper bounds' ,
975- ctx .context ,
976- )
977- return ctx .default_signature # TODO: is this possible?
970+ attrs_type = inst_type .upper_bound if isinstance (inst_type , TypeVarType ) else inst_type
971+ attrs_init_type = None
972+ if isinstance (attrs_type , Instance ):
978973 attrs_init_type = _get_attrs_init_type (attrs_type )
979- if attrs_init_type is None :
980- ctx .api .fail (
981- f'Argument 1 to "evolve" has a variable type "{ inst_type_str } " not bound to an attrs class' ,
982- ctx .context ,
983- )
984- return ctx .default_signature
985- else :
986- attrs_type = inst_type
987- if not isinstance (attrs_type , Instance ):
988- ctx .api .fail (
989- f'Argument 1 to "evolve" has incompatible type "{ inst_type_str } "' , ctx .context
990- )
991- return ctx .default_signature # TODO: is this possible?
992- attrs_init_type = _get_attrs_init_type (attrs_type )
993- if attrs_init_type is None :
994- ctx .api .fail (
995- f'Argument 1 to "evolve" has incompatible type "{ inst_type_str } "; expected an attrs class' ,
996- ctx .context ,
997- )
998- return ctx .default_signature # TODO: is this possible?
974+ if attrs_init_type is None :
975+ ctx .api .fail (
976+ f'Argument 1 to "evolve" has a variable type "{ inst_type_str } " not bound to an attrs class'
977+ if isinstance (inst_type , TypeVarType )
978+ else f'Argument 1 to "evolve" has incompatible type "{ inst_type_str } "; expected an attrs class' ,
979+ ctx .context ,
980+ )
981+ return ctx .default_signature
999982
1000983 attrs_init_type = expand_type_by_instance (attrs_init_type , attrs_type )
1001984
0 commit comments