|
68 | 68 | TupleType, |
69 | 69 | Type, |
70 | 70 | TypeOfAny, |
71 | | - TypeType, |
72 | 71 | TypeVarType, |
73 | 72 | UninhabitedType, |
74 | 73 | UnionType, |
@@ -1071,44 +1070,3 @@ def evolve_function_sig_callback(ctx: mypy.plugin.FunctionSigContext) -> Callabl |
1071 | 1070 | fallback=ctx.default_signature.fallback, |
1072 | 1071 | name=f"{ctx.default_signature.name} of {inst_type_str}", |
1073 | 1072 | ) |
1074 | | - |
1075 | | - |
1076 | | -def fields_function_sig_callback(ctx: mypy.plugin.FunctionSigContext) -> CallableType: |
1077 | | - """Provide the signature for `attrs.fields`.""" |
1078 | | - if len(ctx.args) != 1 or len(ctx.args[0]) != 1: |
1079 | | - return ctx.default_signature |
1080 | | - |
1081 | | - proper_type = get_proper_type(ctx.api.get_expression_type(ctx.args[0][0])) |
1082 | | - |
1083 | | - # fields(Any) -> Any, fields(type[Any]) -> Any |
1084 | | - if ( |
1085 | | - isinstance(proper_type, AnyType) |
1086 | | - or isinstance(proper_type, TypeType) |
1087 | | - and isinstance(proper_type.item, AnyType) |
1088 | | - ): |
1089 | | - return ctx.default_signature |
1090 | | - |
1091 | | - cls = None |
1092 | | - arg_types = ctx.default_signature.arg_types |
1093 | | - |
1094 | | - if isinstance(proper_type, TypeVarType): |
1095 | | - inner = get_proper_type(proper_type.upper_bound) |
1096 | | - if isinstance(inner, Instance): |
1097 | | - # We need to work arg_types to compensate for the attrs stubs. |
1098 | | - arg_types = [proper_type] |
1099 | | - cls = inner.type |
1100 | | - elif isinstance(proper_type, CallableType): |
1101 | | - cls = proper_type.type_object() |
1102 | | - |
1103 | | - if cls is not None and MAGIC_ATTR_NAME in cls.names: |
1104 | | - # This is a proper attrs class. |
1105 | | - ret_type = cls.names[MAGIC_ATTR_NAME].type |
1106 | | - assert ret_type is not None |
1107 | | - return ctx.default_signature.copy_modified(arg_types=arg_types, ret_type=ret_type) |
1108 | | - |
1109 | | - ctx.api.fail( |
1110 | | - f'Argument 1 to "fields" has incompatible type "{format_type_bare(proper_type, ctx.api.options)}"; expected an attrs class', |
1111 | | - ctx.context, |
1112 | | - ) |
1113 | | - |
1114 | | - return ctx.default_signature |
0 commit comments