From 1b1c43a82d3ac9a487af51550c8d412bdd3228c9 Mon Sep 17 00:00:00 2001 From: KotlinIsland <65446343+kotlinisland@users.noreply.github.com> Date: Fri, 24 Nov 2023 01:50:28 +1000 Subject: [PATCH] fixes from merge --- .mypy/baseline.json | 2252 ++++++++++++------- mypy/binder.py | 26 +- mypy/checker.py | 5 +- mypy/constraints.py | 14 +- mypy/dmypy_server.py | 1 + mypy/errors.py | 8 +- mypy/messages.py | 6 +- mypy/stubdoc.py | 2 +- mypy/stubgen.py | 15 +- mypy/stubgenc.py | 6 +- mypy/stubutil.py | 6 + mypy/subtypes.py | 7 +- mypy/test/teststubgen.py | 106 +- mypy_self_check.ini | 2 +- mypy_self_check_strict.ini | 2 +- test-data/unit/check-async-await.test | 2 +- test-data/unit/check-based-misc.test | 29 +- test-data/unit/check-bound.test | 4 +- test-data/unit/check-dataclasses.test | 4 +- test-data/unit/check-expressions.test | 2 +- test-data/unit/check-functions.test | 8 +- test-data/unit/check-inference-context.test | 2 +- test-data/unit/check-namedtuple.test | 3 +- test-data/unit/check-newsemanal.test | 2 + test-data/unit/check-optional.test | 2 +- test-data/unit/check-overloading.test | 2 +- test-data/unit/check-plugin-attrs.test | 4 +- test-data/unit/check-protocols.test | 2 +- test-data/unit/check-python312.test | 12 +- test-data/unit/check-type-aliases.test | 12 + test-data/unit/check-typeguard.test | 2 +- test-data/unit/check-unions.test | 2 + test-data/unit/stubgen-based.test | 44 +- 33 files changed, 1703 insertions(+), 893 deletions(-) diff --git a/.mypy/baseline.json b/.mypy/baseline.json index f29f0396d..07b3ba9cd 100644 --- a/.mypy/baseline.json +++ b/.mypy/baseline.json @@ -5,7 +5,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"__repr__\" is not using @override but is overriding a method in class \"builtins.object\"", - "offset": 56, + "offset": 61, "src": "def __repr__(self) -> str:", "target": "mypy.binder.Frame.__repr__" } @@ -15,7 +15,7 @@ "code": "no-any-explicit", "column": 4, "message": "Explicit \"Any\" is not allowed", - "offset": 338, + "offset": 339, "src": "plugin_data: Any # config data from plugins", "target": "mypy.build" }, @@ -437,7 +437,7 @@ }, { "code": "no-any-expr", - "column": 13, + "column": 11, "message": "Expression type contains \"Any\" (has type \"Any | str\")", "offset": 1, "src": "return f\"{ver}:{digest}\"", @@ -453,7 +453,7 @@ }, { "code": "helpful-string", - "column": 38, + "column": 22, "message": "The string for \"object\" isn't helpful in a user-facing or semantic string", "offset": 103, "src": "print(f\"{key + ':':24}{value}\")", @@ -1029,7 +1029,7 @@ }, { "code": "no-any-expr", - "column": 74, + "column": 28, "message": "Expression has type \"Any\"", "offset": 1, "src": "manager.log(f\"Invalid or missing fine-grained deps cache: {meta['path']}\")", @@ -1741,20 +1741,12 @@ }, { "code": "helpful-string", - "column": 70, + "column": 28, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 21, "src": "manager.log(f\"Deferring module to fine-grained update {path} ({id})\")", "target": "mypy.build.State.__init__" }, - { - "code": "helpful-string", - "column": 78, - "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 0, - "src": "manager.log(f\"Deferring module to fine-grained update {path} ({id})\")", - "target": "mypy.build.State.__init__" - }, { "code": "no-any-explicit", "column": 4, @@ -1847,7 +1839,7 @@ "code": "no-any-expr", "column": 40, "message": "Expression type contains \"Any\" (has type \"(str, CacheMeta | None)\")", - "offset": 402, + "offset": 404, "src": "new_interface_hash, self.meta = write_cache(", "target": "mypy.build.State.write_cache" }, @@ -1885,7 +1877,7 @@ }, { "code": "no-any-expr", - "column": 32, + "column": 26, "message": "Expression has type \"Any\"", "offset": 1, "src": "manager.trace(f\" {pth}\")", @@ -1977,7 +1969,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"type_context\" is not using @override but is overriding a method in class \"mypy.plugin.CheckerPluginInterface\"", - "offset": 438, + "offset": 449, "src": "def type_context(self) -> list[Type | None]:", "target": "mypy.checker" }, @@ -2009,7 +2001,7 @@ "code": "redundant-expr", "column": 31, "message": "Condition is always true", - "offset": 477, + "offset": 483, "src": "if new_frame is None:", "target": "mypy.checker.TypeChecker.check_func_def" }, @@ -2017,7 +2009,7 @@ "code": "no-any-expr", "column": 12, "message": "Expression type contains \"Any\" (has type \"tuple[Any, ...]\")", - "offset": 586, + "offset": 585, "src": "for substitutions in itertools.product(*subst):", "target": "mypy.checker.TypeChecker.expand_typevars" }, @@ -2057,7 +2049,7 @@ "code": "redundant-expr", "column": 11, "message": "Condition is always false", - "offset": 287, + "offset": 290, "src": "if isinstance(sym.node, FuncBase):", "target": "mypy.checker.TypeChecker.determine_type_of_member" }, @@ -2121,7 +2113,7 @@ "code": "truthy-bool", "column": 24, "message": "\"rvalue_type\" has type \"Type\" which does not implement __bool__ or __len__ so it could always be true in boolean context", - "offset": 160, + "offset": 161, "src": "and rvalue_type", "target": "mypy.checker.TypeChecker.check_assignment" }, @@ -2145,7 +2137,7 @@ "code": "redundant-expr", "column": 27, "message": "Condition is always false", - "offset": 40, + "offset": 69, "src": "if iterable_type is not None and iterable_type != self.iterable_item_type(", "target": "mypy.checker.TypeChecker.check_assignment_to_multiple_lvalues" }, @@ -2201,7 +2193,7 @@ "code": "no-any-expr", "column": 36, "message": "Expression type contains \"Any\" (has type \"zip[tuple[Any, ...]]\")", - "offset": 155, + "offset": 186, "src": "types, declared_types = zip(*clean_items)", "target": "mypy.checker.TypeChecker.check_multi_assignment_from_union" }, @@ -2233,7 +2225,7 @@ "code": "truthy-bool", "column": 11, "message": "\"var\" has type \"Var\" which does not implement __bool__ or __len__ so it could always be true in boolean context", - "offset": 332, + "offset": 360, "src": "if var and not self.current_node_deferred:", "target": "mypy.checker.TypeChecker.set_inferred_type" }, @@ -2329,7 +2321,7 @@ "code": "redundant-expr", "column": 23, "message": "Condition is always true", - "offset": 80, + "offset": 70, "src": "if native_int is None:", "target": "mypy.checker.TypeChecker.analyze_range_native_int_type" }, @@ -2425,7 +2417,7 @@ "code": "redundant-expr", "column": 15, "message": "Condition is always false", - "offset": 487, + "offset": 519, "src": "if target and not is_same_type(target, expr_type):", "target": "mypy.checker.TypeChecker.refine_identity_comparison_expression" }, @@ -2449,7 +2441,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"named_generic_type\" is not using @override but is overriding a method in class \"mypy.plugin.CheckerPluginInterface\"", - "offset": 298, + "offset": 566, "src": "def named_generic_type(self, name: str, args: list[Type]) -> Instance:", "target": "mypy.checker.TypeChecker.named_generic_type" }, @@ -2481,7 +2473,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"type\" is not using @override but is overriding a method in class \"mypy.treetransform.TransformVisitor\"", - "offset": 323, + "offset": 349, "src": "def type(self, type: Type) -> Type:", "target": "mypy.checker.TypeTransformVisitor.type" }, @@ -2489,7 +2481,7 @@ "code": "redundant-expr", "column": 9, "message": "Condition is always true", - "offset": 126, + "offset": 130, "src": "elif isinstance(t, FunctionLike):", "target": "mypy.checker.is_more_general_arg_prefix" }, @@ -2505,7 +2497,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_uninhabited_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.BoolTypeQuery\"", - "offset": 65, + "offset": 81, "src": "def visit_uninhabited_type(self, t: UninhabitedType) -> bool:", "target": "mypy.checker.InvalidInferredTypes.visit_uninhabited_type" }, @@ -2633,9 +2625,9 @@ "mypy/checkexpr.py": [ { "code": "helpful-string", - "column": 61, + "column": 33, "message": "The type \"type[mypy.nodes.RefExpr]\" doesn't define a __format__, __str__ or __repr__ method", - "offset": 277, + "offset": 284, "src": "raise AssertionError(f\"Unknown RefExpr subclass: {type(expr)}\")", "target": "mypy.checkexpr.extract_refexpr_names" }, @@ -2643,7 +2635,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_name_expr\" is not using @override but is overriding a method in class \"mypy.visitor.ExpressionVisitor\"", - "offset": 64, + "offset": 78, "src": "def visit_name_expr(self, e: NameExpr) -> Type:", "target": "mypy.checkexpr.ExpressionChecker.visit_name_expr" }, @@ -2667,7 +2659,7 @@ "code": "possibly-undefined", "column": 23, "message": "Name \"actual_types\" may be undefined", - "offset": 1685, + "offset": 1724, "src": "assert len(actual_types) == len(actuals) == len(actual_kinds)", "target": "mypy.checkexpr" }, @@ -2691,7 +2683,7 @@ "code": "possibly-undefined", "column": 48, "message": "Name \"callee_arg_kinds\" may be undefined", - "offset": 6, + "offset": 8, "src": "assert len(callee_arg_types) == len(callee_arg_kinds)", "target": "mypy.checkexpr" }, @@ -2715,7 +2707,7 @@ "code": "no-any-expr", "column": 46, "message": "Expression type contains \"Any\" (has type \"zip[tuple[Any, ...]]\")", - "offset": 131, + "offset": 135, "src": "returns, inferred_types = zip(*unioned_return)", "target": "mypy.checkexpr.ExpressionChecker.check_overload_call" }, @@ -2745,9 +2737,9 @@ }, { "code": "helpful-string", - "column": 46, + "column": 19, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 614, + "offset": 620, "src": "name = f\"{context.callee.name} of {object_type}\"", "target": "mypy.checkexpr.ExpressionChecker.check_intersection_call" }, @@ -2763,7 +2755,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_int_expr\" is not using @override but is overriding a method in class \"mypy.visitor.ExpressionVisitor\"", - "offset": 97, + "offset": 98, "src": "def visit_int_expr(self, e: IntExpr) -> Type:", "target": "mypy.checkexpr.ExpressionChecker.visit_int_expr" }, @@ -2815,11 +2807,19 @@ "src": "def visit_op_expr(self, e: OpExpr) -> Type:", "target": "mypy.checkexpr.ExpressionChecker.visit_op_expr" }, + { + "code": "redundant-expr", + "column": 17, + "message": "Condition is always true", + "offset": 93, + "src": "elif use_reverse is UseReverse.ALWAYS:", + "target": "mypy.checkexpr.ExpressionChecker.visit_op_expr" + }, { "code": "explicit-override", "column": 4, "message": "Method \"visit_comparison_expr\" is not using @override but is overriding a method in class \"mypy.visitor.ExpressionVisitor\"", - "offset": 35, + "offset": 16, "src": "def visit_comparison_expr(self, e: ComparisonExpr) -> Type:", "target": "mypy.checkexpr.ExpressionChecker.visit_comparison_expr" }, @@ -2843,7 +2843,7 @@ "code": "possibly-undefined", "column": 16, "message": "Name \"left_map\" may be undefined", - "offset": 533, + "offset": 541, "src": "and left_map is None", "target": "mypy.checkexpr" }, @@ -2883,7 +2883,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_unary_expr\" is not using @override but is overriding a method in class \"mypy.visitor.ExpressionVisitor\"", - "offset": 8, + "offset": 11, "src": "def visit_unary_expr(self, e: UnaryExpr) -> Type:", "target": "mypy.checkexpr.ExpressionChecker.visit_unary_expr" }, @@ -2899,7 +2899,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_cast_expr\" is not using @override but is overriding a method in class \"mypy.visitor.ExpressionVisitor\"", - "offset": 205, + "offset": 294, "src": "def visit_cast_expr(self, expr: CastExpr) -> Type:", "target": "mypy.checkexpr.ExpressionChecker.visit_cast_expr" }, @@ -2923,7 +2923,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_type_application\" is not using @override but is overriding a method in class \"mypy.visitor.ExpressionVisitor\"", - "offset": 47, + "offset": 72, "src": "def visit_type_application(self, tapp: TypeApplication) -> Type:", "target": "mypy.checkexpr.ExpressionChecker.visit_type_application" }, @@ -2939,7 +2939,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_list_expr\" is not using @override but is overriding a method in class \"mypy.visitor.ExpressionVisitor\"", - "offset": 137, + "offset": 160, "src": "def visit_list_expr(self, e: ListExpr) -> Type:", "target": "mypy.checkexpr.ExpressionChecker.visit_list_expr" }, @@ -2955,7 +2955,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_tuple_expr\" is not using @override but is overriding a method in class \"mypy.visitor.ExpressionVisitor\"", - "offset": 72, + "offset": 85, "src": "def visit_tuple_expr(self, e: TupleExpr) -> Type:", "target": "mypy.checkexpr.ExpressionChecker.visit_tuple_expr" }, @@ -2963,7 +2963,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_dict_expr\" is not using @override but is overriding a method in class \"mypy.visitor.ExpressionVisitor\"", - "offset": 120, + "offset": 163, "src": "def visit_dict_expr(self, e: DictExpr) -> Type:", "target": "mypy.checkexpr.ExpressionChecker.visit_dict_expr" }, @@ -3325,7 +3325,7 @@ "code": "truthy-bool", "column": 7, "message": "\"result\" has type \"Type\" which does not implement __bool__ or __len__ so it could always be true in boolean context", - "offset": 480, + "offset": 497, "src": "if result and not mx.is_lvalue and not implicit:", "target": "mypy.checkmember.analyze_var" }, @@ -3341,7 +3341,7 @@ "code": "unreachable", "column": 48, "message": "Right operand of \"and\" is never evaluated", - "offset": 204, + "offset": 206, "src": "isinstance(node.node, FuncBase) and node.node.is_class", "target": "mypy.checkmember.analyze_class_attribute_access" }, @@ -3375,7 +3375,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_as_pattern\" is not using @override but is overriding a method in class \"mypy.visitor.PatternVisitor\"", - "offset": 130, + "offset": 134, "src": "def visit_as_pattern(self, o: AsPattern) -> PatternType:", "target": "mypy.checkpattern.PatternChecker.visit_as_pattern" }, @@ -3423,7 +3423,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_starred_pattern\" is not using @override but is overriding a method in class \"mypy.visitor.PatternVisitor\"", - "offset": 152, + "offset": 215, "src": "def visit_starred_pattern(self, o: StarredPattern) -> PatternType:", "target": "mypy.checkpattern.PatternChecker.visit_starred_pattern" }, @@ -3447,7 +3447,7 @@ "code": "helpful-string", "column": 20, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 138, + "offset": 152, "src": "message_registry.CLASS_PATTERN_UNKNOWN_KEYWORD.format(", "target": "mypy.checkpattern.PatternChecker.visit_class_pattern" } @@ -3457,7 +3457,7 @@ "code": "helpful-string", "column": 16, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 719, + "offset": 722, "src": "\"Only index and member expressions are allowed in\"", "target": "mypy.checkstrformat.StringFormatterChecker.validate_and_transform_accessors" }, @@ -3473,7 +3473,7 @@ "code": "redundant-expr", "column": 13, "message": "Condition is always true", - "offset": 147, + "offset": 163, "src": "elif isinstance(expr, StrExpr):", "target": "mypy.checkstrformat.StringFormatterChecker.build_dict_type" } @@ -3617,7 +3617,7 @@ }, { "code": "possibly-undefined", - "column": 19, + "column": 17, "message": "Name \"file_read\" may be undefined", "offset": 1, "src": "prefix = f\"{file_read}: [mypy]: \"", @@ -3683,7 +3683,7 @@ "code": "no-any-explicit", "column": 0, "message": "Explicit \"Any\" is not allowed", - "offset": 48, + "offset": 53, "src": "def destructure_overrides(toml_data: dict[str, Any]) -> dict[str, Any]:", "target": "mypy.config_parser.destructure_overrides" }, @@ -3929,25 +3929,17 @@ }, { "code": "no-any-expr", - "column": 30, - "message": "Expression type contains \"Any\" (has type \"(str, Any)\")", - "offset": 6, - "src": "% (module, new_key)", - "target": "mypy.config_parser.destructure_overrides" - }, - { - "code": "no-any-expr", - "column": 39, + "column": 28, "message": "Expression has type \"Any\"", - "offset": 0, - "src": "% (module, new_key)", + "offset": 3, + "src": "\"toml config file contains \"", "target": "mypy.config_parser.destructure_overrides" }, { "code": "no-any-expr", "column": 20, "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", - "offset": 2, + "offset": 4, "src": "result[old_config_name][new_key] = new_value", "target": "mypy.config_parser.destructure_overrides" }, @@ -4019,7 +4011,7 @@ "code": "no-any-expr", "column": 15, "message": "Expression type contains \"Any\" (has type \"Mapping[str, Any]\")", - "offset": 14, + "offset": 22, "src": "for key in section:", "target": "mypy.config_parser.parse_section" }, @@ -4047,11 +4039,27 @@ "src": "ct = config_types[key]", "target": "mypy.config_parser.parse_section" }, + { + "code": "no-any-expr", + "column": 16, + "message": "Expression has type \"Any\"", + "offset": 3, + "src": "f\"{prefix}Unrecognized option: {key} = {section[key]}\"", + "target": "mypy.config_parser.parse_section" + }, + { + "code": "no-any-expr", + "column": 56, + "message": "Expression type contains \"Any\" (has type \"Mapping[str, Any]\")", + "offset": 0, + "src": "f\"{prefix}Unrecognized option: {key} = {section[key]}\"", + "target": "mypy.config_parser.parse_section" + }, { "code": "no-any-expr", "column": 21, "message": "Expression type contains \"Any\" (has type \"Any | None\")", - "offset": 7, + "offset": 11, "src": "dv = getattr(template, key, None)", "target": "mypy.config_parser.parse_section" }, @@ -4081,7 +4089,7 @@ }, { "code": "no-any-expr", - "column": 65, + "column": 26, "message": "Expression has type \"Any\"", "offset": 21, "src": "print(f\"{prefix}Unrecognized option: {key} = {section[key]}\", file=stderr)", @@ -4331,11 +4339,19 @@ "src": "incomplete_star_mapping = True", "target": "mypy.constraints.infer_constraints_for_callable" }, + { + "code": "redundant-expr", + "column": 17, + "message": "Condition is always true", + "offset": 52, + "src": "elif isinstance(unpacked_type, TupleType):", + "target": "mypy.constraints.infer_constraints_for_callable" + }, { "code": "redundant-expr", "column": 19, "message": "Condition is always true", - "offset": 384, + "offset": 367, "src": "if option is not None:", "target": "mypy.constraints.any_constraints" }, @@ -4463,7 +4479,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_instance\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 16, + "offset": 13, "src": "def visit_instance(self, template: Instance) -> list[Constraint]:", "target": "mypy.constraints.ConstraintBuilderVisitor.visit_instance" }, @@ -4471,7 +4487,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_callable_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 313, + "offset": 303, "src": "def visit_callable_type(self, template: CallableType) -> list[Constraint]:", "target": "mypy.constraints.ConstraintBuilderVisitor.visit_callable_type" }, @@ -4479,7 +4495,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_tuple_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 171, + "offset": 172, "src": "def visit_tuple_type(self, template: TupleType) -> list[Constraint]:", "target": "mypy.constraints.ConstraintBuilderVisitor.visit_tuple_type" }, @@ -4487,7 +4503,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_typeddict_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 51, + "offset": 97, "src": "def visit_typeddict_type(self, template: TypedDictType) -> list[Constraint]:", "target": "mypy.constraints.ConstraintBuilderVisitor.visit_typeddict_type" }, @@ -4519,7 +4535,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_overloaded\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 15, + "offset": 20, "src": "def visit_overloaded(self, template: Overloaded) -> list[Constraint]:", "target": "mypy.constraints.ConstraintBuilderVisitor.visit_overloaded" }, @@ -4849,7 +4865,7 @@ }, { "code": "no-any-expr", - "column": 28, + "column": 14, "message": "Expression has type \"Any\"", "offset": 1, "src": "print(f\"Restarting: {response['restart']}\")", @@ -5779,7 +5795,7 @@ "code": "no-any-expr", "column": 15, "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", - "offset": 28, + "offset": 40, "src": "return {\"error\": str(err)}", "target": "mypy.dmypy.client.request" }, @@ -5787,7 +5803,7 @@ "code": "no-any-explicit", "column": 0, "message": "Explicit \"Any\" is not allowed", - "offset": 28, + "offset": 17, "src": "def check_status(data: dict[str, Any]) -> tuple[int, str]:", "target": "mypy.dmypy.client.check_status" }, @@ -5893,7 +5909,7 @@ "code": "no-any-expr", "column": 26, "message": "Expression type contains \"Any\" (has type \"dict[Any, Any]\")", - "offset": 8, + "offset": 12, "src": "json.dump({\"pid\": os.getpid(), \"connection_name\": server.connection_name}, f)", "target": "mypy.dmypy_server.Server.serve" }, @@ -5909,7 +5925,7 @@ "code": "no-any-explicit", "column": 20, "message": "Explicit \"Any\" is not allowed", - "offset": 5, + "offset": 4, "src": "resp: dict[str, Any] = {}", "target": "mypy.dmypy_server.Server.serve" }, @@ -5974,23 +5990,15 @@ "column": 32, "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", "offset": 1, - "src": "resp[\"stdout\"] = debug_stdout.getvalue()", + "src": "resp[\"final\"] = True", "target": "mypy.dmypy_server.Server.serve" }, { "code": "no-any-expr", - "column": 32, - "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", - "offset": 1, - "src": "resp[\"stderr\"] = debug_stderr.getvalue()", - "target": "mypy.dmypy_server.Server.serve" - }, - { - "code": "no-any-expr", - "column": 56, + "column": 45, "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", "offset": 1, - "src": "server.write(json.dumps(resp).encode(\"utf8\"))", + "src": "send(server, resp)", "target": "mypy.dmypy_server.Server.serve" }, { @@ -5998,15 +6006,7 @@ "column": 20, "message": "Expression type contains \"Any\" (has type \"dict[str, Any] | dict[str, object]\")", "offset": 2, - "src": "resp[\"stdout\"] = debug_stdout.getvalue()", - "target": "mypy.dmypy_server.Server.serve" - }, - { - "code": "no-any-expr", - "column": 20, - "message": "Expression type contains \"Any\" (has type \"dict[str, Any] | dict[str, object]\")", - "offset": 1, - "src": "resp[\"stderr\"] = debug_stderr.getvalue()", + "src": "resp[\"final\"] = True", "target": "mypy.dmypy_server.Server.serve" }, { @@ -6019,10 +6019,10 @@ }, { "code": "no-any-expr", - "column": 48, + "column": 37, "message": "Expression type contains \"Any\" (has type \"dict[str, Any] | dict[str, object]\")", "offset": 1, - "src": "server.write(json.dumps(resp).encode(\"utf8\"))", + "src": "send(server, resp)", "target": "mypy.dmypy_server.Server.serve" }, { @@ -6045,7 +6045,7 @@ "code": "no-any-expr", "column": 15, "message": "Expression type contains \"Any\" (has type \"Any | None\")", - "offset": 9, + "offset": 13, "src": "if command != \"stop\":", "target": "mypy.dmypy_server.Server.serve" }, @@ -6213,7 +6213,7 @@ "code": "no-any-expr", "column": 23, "message": "Expression type contains \"Any\" (has type \"CacheMeta | None\")", - "offset": 18, + "offset": 19, "src": "meta = state.meta", "target": "mypy.dmypy_server.Server.initialize_fine_grained" }, @@ -6253,7 +6253,7 @@ "code": "no-any-expr", "column": 15, "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", - "offset": 45, + "offset": 46, "src": "return {\"out\": \"\".join(s + \"\\n\" for s in messages), \"err\": \"\", \"status\": status}", "target": "mypy.dmypy_server.Server.initialize_fine_grained" }, @@ -6400,7 +6400,7 @@ "column": 15, "message": "Expression has type \"Any\"", "offset": 10, - "src": "data = json.loads(bdata.decode(\"utf8\"))", + "src": "data = json.loads(bdata)", "target": "mypy.dmypy_util.receive" }, { @@ -6413,7 +6413,7 @@ }, { "code": "no-any-expr", - "column": 53, + "column": 22, "message": "Expression type contains \"Any\" (has type \"type[Any]\")", "offset": 1, "src": "raise OSError(f\"Data received is not a dict ({type(data)})\")", @@ -6421,7 +6421,7 @@ }, { "code": "helpful-string", - "column": 53, + "column": 22, "message": "The type \"type[Any]\" doesn't define a __format__, __str__ or __repr__ method", "offset": 0, "src": "raise OSError(f\"Data received is not a dict ({type(data)})\")", @@ -6434,6 +6434,46 @@ "offset": 0, "src": "raise OSError(f\"Data received is not a dict ({type(data)})\")", "target": "mypy.dmypy_util.receive" + }, + { + "code": "no-any-explicit", + "column": 0, + "message": "Explicit \"Any\" is not allowed", + "offset": 4, + "src": "def send(connection: IPCBase, data: Any) -> None:", + "target": "mypy.dmypy_util.send" + }, + { + "code": "no-any-expr", + "column": 32, + "message": "Expression has type \"Any\"", + "offset": 6, + "src": "connection.write(json.dumps(data))", + "target": "mypy.dmypy_util.send" + }, + { + "code": "no-any-explicit", + "column": 8, + "message": "Explicit \"Any\" is not allowed", + "offset": 11, + "src": "resp: dict[str, Any] = {}", + "target": "mypy.dmypy_util.WriteToConn.write" + }, + { + "code": "no-any-expr", + "column": 8, + "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", + "offset": 1, + "src": "resp[self.output_key] = output", + "target": "mypy.dmypy_util.WriteToConn.write" + }, + { + "code": "no-any-expr", + "column": 26, + "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", + "offset": 1, + "src": "send(self.server, resp)", + "target": "mypy.dmypy_util.WriteToConn.write" } ], "mypy/erasetype.py": [ @@ -6505,7 +6545,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_type_var\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 3, + "offset": 14, "src": "def visit_type_var(self, t: TypeVarType) -> ProperType:", "target": "mypy.erasetype.EraseTypeVisitor.visit_type_var" }, @@ -6537,7 +6577,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_unpack_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 3, + "offset": 5, "src": "def visit_unpack_type(self, t: UnpackType) -> ProperType:", "target": "mypy.erasetype.EraseTypeVisitor.visit_unpack_type" }, @@ -6621,11 +6661,27 @@ "src": "def visit_type_var(self, t: TypeVarType) -> Type:", "target": "mypy.erasetype.TypeVarEraser.visit_type_var" }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"visit_instance\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeTranslator\"", + "offset": 7, + "src": "def visit_instance(self, t: Instance) -> Type:", + "target": "mypy.erasetype.TypeVarEraser.visit_instance" + }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"visit_tuple_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeTranslator\"", + "offset": 13, + "src": "def visit_tuple_type(self, t: TupleType) -> Type:", + "target": "mypy.erasetype.TypeVarEraser.visit_tuple_type" + }, { "code": "explicit-override", "column": 4, "message": "Method \"visit_type_var_tuple\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeTranslator\"", - "offset": 5, + "offset": 17, "src": "def visit_type_var_tuple(self, t: TypeVarTupleType) -> Type:", "target": "mypy.erasetype.TypeVarEraser.visit_type_var_tuple" }, @@ -7201,7 +7257,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_type_var\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeTranslator\"", - "offset": 7, + "offset": 12, "src": "def visit_type_var(self, t: TypeVarType) -> Type:", "target": "mypy.expandtype.ExpandTypeVisitor.visit_type_var" }, @@ -7217,7 +7273,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_type_var_tuple\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeTranslator\"", - "offset": 24, + "offset": 25, "src": "def visit_type_var_tuple(self, t: TypeVarTupleType) -> Type:", "target": "mypy.expandtype.ExpandTypeVisitor.visit_type_var_tuple" }, @@ -7241,7 +7297,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_callable_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeTranslator\"", - "offset": 28, + "offset": 23, "src": "def visit_callable_type(self, t: CallableType) -> CallableType:", "target": "mypy.expandtype.ExpandTypeVisitor.visit_callable_type" }, @@ -7249,7 +7305,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_overloaded\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeTranslator\"", - "offset": 54, + "offset": 57, "src": "def visit_overloaded(self, t: Overloaded) -> Type:", "target": "mypy.expandtype.ExpandTypeVisitor.visit_overloaded" }, @@ -7257,7 +7313,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_tuple_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeTranslator\"", - "offset": 32, + "offset": 19, "src": "def visit_tuple_type(self, t: TupleType) -> Type:", "target": "mypy.expandtype.ExpandTypeVisitor.visit_tuple_type" }, @@ -7265,7 +7321,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_typeddict_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeTranslator\"", - "offset": 21, + "offset": 18, "src": "def visit_typeddict_type(self, t: TypedDictType) -> Type:", "target": "mypy.expandtype.ExpandTypeVisitor.visit_typeddict_type" }, @@ -7321,7 +7377,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_typeguard_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 10, + "offset": 7, "src": "def visit_typeguard_type(self, t: TypeGuardType) -> Type:", "target": "mypy.expandtype.ExpandTypeVisitor.visit_typeguard_type" } @@ -7331,7 +7387,7 @@ "code": "redundant-expr", "column": 23, "message": "Condition is always false", - "offset": 158, + "offset": 161, "src": "if name is not None:", "target": "mypy.exprtotype.expr_to_unanalyzed_type" } @@ -7341,7 +7397,15 @@ "code": "no-any-explicit", "column": 4, "message": "Explicit \"Any\" is not allowed", - "offset": 163, + "offset": 154, + "src": "ast_TypeAlias = Any", + "target": "mypy.fastparse" + }, + { + "code": "no-any-explicit", + "column": 4, + "message": "Explicit \"Any\" is not allowed", + "offset": 14, "src": "Match = Any", "target": "mypy.fastparse" }, @@ -7621,7 +7685,7 @@ "code": "no-any-expr", "column": 19, "message": "Expression type contains \"Any\" (has type \"Any | None\")", - "offset": 71, + "offset": 79, "src": "end_line = getattr(n, \"end_lineno\", None)", "target": "mypy.fastparse.ASTConverter.do_func_def" }, @@ -7901,7 +7965,7 @@ "code": "no-any-expr", "column": 22, "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", - "offset": 7, + "offset": 15, "src": "metaclass=dict(keywords).get(\"metaclass\"),", "target": "mypy.fastparse.ASTConverter.visit_ClassDef" }, @@ -9321,11 +9385,51 @@ "src": "node = OrPattern([self.visit(pattern) for pattern in n.patterns])", "target": "mypy.fastparse.ASTConverter.visit_MatchOr" }, + { + "code": "no-any-expr", + "column": 12, + "message": "Expression has type \"Any\"", + "offset": 6, + "src": "n.lineno,", + "target": "mypy.fastparse.ASTConverter.visit_TypeAlias" + }, + { + "code": "no-any-expr", + "column": 12, + "message": "Expression has type \"Any\"", + "offset": 1, + "src": "n.col_offset,", + "target": "mypy.fastparse.ASTConverter.visit_TypeAlias" + }, + { + "code": "no-any-expr", + "column": 40, + "message": "Expression has type \"Any\"", + "offset": 3, + "src": "node = AssignmentStmt([NameExpr(n.name.id)], self.visit(n.value))", + "target": "mypy.fastparse.ASTConverter.visit_TypeAlias" + }, + { + "code": "no-any-expr", + "column": 53, + "message": "Expression has type \"Any\"", + "offset": 0, + "src": "node = AssignmentStmt([NameExpr(n.name.id)], self.visit(n.value))", + "target": "mypy.fastparse.ASTConverter.visit_TypeAlias" + }, + { + "code": "no-any-expr", + "column": 64, + "message": "Expression has type \"Any\"", + "offset": 0, + "src": "node = AssignmentStmt([NameExpr(n.name.id)], self.visit(n.value))", + "target": "mypy.fastparse.ASTConverter.visit_TypeAlias" + }, { "code": "no-any-expr", "column": 55, "message": "Expression type contains \"Any\" (has type \"Any | int\")", - "offset": 41, + "offset": 40, "src": "None, \"typing.Any\", line=self.line, column=getattr(node, \"col_offset\", -1), note=note", "target": "mypy.fastparse.TypeConverter.invalid_type" }, @@ -9533,7 +9637,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_assignment_stmt\" is not using @override but is overriding a method in class \"mypy.traverser.TraverserVisitor\"", - "offset": 65, + "offset": 60, "src": "def visit_assignment_stmt(self, s: AssignmentStmt) -> None:", "target": "mypy.fastparse.FindAttributeAssign.visit_assignment_stmt" }, @@ -9625,7 +9729,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_func_def\" is not using @override but is overriding a method in class \"mypy.visitor.NodeVisitor\"", - "offset": 72, + "offset": 93, "src": "def visit_func_def(self, func: FuncDef) -> None:", "target": "mypy.fixup.NodeFixer.visit_func_def" }, @@ -9673,7 +9777,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_type_var_expr\" is not using @override but is overriding a method in class \"mypy.visitor.NodeVisitor\"", - "offset": 8, + "offset": 4, "src": "def visit_type_var_expr(self, tv: TypeVarExpr) -> None:", "target": "mypy.fixup.NodeFixer.visit_type_var_expr" }, @@ -9697,7 +9801,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_var\" is not using @override but is overriding a method in class \"mypy.visitor.NodeVisitor\"", - "offset": 4, + "offset": 5, "src": "def visit_var(self, v: Var) -> None:", "target": "mypy.fixup.NodeFixer.visit_var" }, @@ -9945,7 +10049,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_unpack_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 4, + "offset": 5, "src": "def visit_unpack_type(self, u: UnpackType) -> None:", "target": "mypy.fixup.TypeFixer.visit_unpack_type" }, @@ -9989,19 +10093,11 @@ "src": "def visit_intersection_type(self, it: IntersectionType):", "target": "mypy.fixup.TypeFixer.visit_intersection_type" }, - { - "code": "no-any-explicit", - "column": 4, - "message": "Explicit \"Any\" is not allowed", - "offset": 4, - "src": "def visit_void(self, o: Any) -> None:", - "target": "mypy.fixup.TypeFixer.visit_void" - }, { "code": "explicit-override", "column": 4, "message": "Method \"visit_type_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 3, + "offset": 4, "src": "def visit_type_type(self, t: TypeType) -> None:", "target": "mypy.fixup.TypeFixer.visit_type_type" } @@ -10200,7 +10296,7 @@ "column": 4, "message": "Method \"visit_intersection_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", "offset": 3, - "src": "def visit_intersection_type(self, t: types.IntersectionType) -> Set[str]:", + "src": "def visit_intersection_type(self, t: types.IntersectionType) -> set[str]:", "target": "mypy.indirection.TypeIndirectionVisitor.visit_intersection_type" }, { @@ -10231,17 +10327,9 @@ "mypy/inspections.py": [ { "code": "helpful-string", - "column": 43, - "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 58, - "src": "return f\"{expr.line}:{expr.column + 1}:{expr.end_line}:{expr.end_column}\"", - "target": "mypy.inspections.expr_span" - }, - { - "code": "helpful-string", - "column": 59, + "column": 11, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 0, + "offset": 57, "src": "return f\"{expr.line}:{expr.column + 1}:{expr.end_line}:{expr.end_column}\"", "target": "mypy.inspections.expr_span" }, @@ -10263,19 +10351,29 @@ }, { "code": "helpful-string", - "column": 17, + "column": 15, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 197, + "offset": 187, "src": "return f\"{module.path}:{node.line}:{node.column + 1}:{node.name}\"", "target": "mypy.inspections.InspectionEngine.format_node" } ], + "mypy/ipc.py": [ + { + "code": "redundant-expr", + "column": 18, + "message": "Condition is always true", + "offset": 105, + "src": "while True:", + "target": "mypy.ipc.IPCBase.read" + } + ], "mypy/join.py": [ { "code": "redundant-expr", "column": 15, "message": "Condition is always true", - "offset": 137, + "offset": 170, "src": "if best is None or is_better(res, best):", "target": "mypy.join.InstanceJoiner.join_instances_via_supertype" }, @@ -10395,7 +10493,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_instance\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 12, + "offset": 15, "src": "def visit_instance(self, t: Instance) -> ProperType:", "target": "mypy.join.TypeJoinVisitor.visit_instance" }, @@ -10419,7 +10517,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_tuple_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 53, + "offset": 160, "src": "def visit_tuple_type(self, t: TupleType) -> ProperType:", "target": "mypy.join.TypeJoinVisitor.visit_tuple_type" }, @@ -10427,7 +10525,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_typeddict_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 29, + "offset": 32, "src": "def visit_typeddict_type(self, t: TypedDictType) -> ProperType:", "target": "mypy.join.TypeJoinVisitor.visit_typeddict_type" }, @@ -10867,11 +10965,19 @@ } ], "mypy/main.py": [ + { + "code": "helpful-string", + "column": 12, + "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", + "offset": 218, + "src": "\"Warning: unused section(s) in {}: {}\".format(", + "target": "mypy.main.run_build" + }, { "code": "explicit-override", "column": 4, "message": "Method \"_fill_text\" is not using @override but is overriding a method in class \"argparse.HelpFormatter\"", - "offset": 251, + "offset": 32, "src": "def _fill_text(self, text: str, width: int, indent: str) -> str:", "target": "mypy.main.AugmentedHelpFormatter._fill_text" }, @@ -11127,7 +11233,7 @@ "code": "no-any-expr", "column": 67, "message": "Expression type contains \"Any\" (has type \"list[Any]\")", - "offset": 289, + "offset": 284, "src": "\"--package-root\", metavar=\"ROOT\", action=\"append\", default=[], help=argparse.SUPPRESS", "target": "mypy.main.process_options" }, @@ -11135,7 +11241,7 @@ "code": "no-any-expr", "column": 16, "message": "Expression type contains \"Any\" (has type \"list[Any]\")", - "offset": 44, + "offset": 41, "src": "default=[],", "target": "mypy.main.process_options" }, @@ -11189,7 +11295,7 @@ }, { "code": "no-any-expr", - "column": 48, + "column": 21, "message": "Expression has type \"Any\"", "offset": 1, "src": "parser.error(f\"Cannot find config file '{config_file}'\")", @@ -11359,7 +11465,7 @@ "code": "no-any-expr", "column": 7, "message": "Expression has type \"Any\"", - "offset": 55, + "offset": 51, "src": "if special_opts.find_occurrences:", "target": "mypy.main.process_options" }, @@ -11463,13 +11569,13 @@ "code": "no-any-expr", "column": 8, "message": "Expression has type \"Any\"", - "offset": 29, + "offset": 30, "src": "[f\"module:{el}\" for el in special_opts.modules]", "target": "mypy.main.process_options" }, { "code": "no-any-expr", - "column": 18, + "column": 9, "message": "Expression has type \"Any\"", "offset": 0, "src": "[f\"module:{el}\" for el in special_opts.modules]", @@ -11493,7 +11599,7 @@ }, { "code": "no-any-expr", - "column": 21, + "column": 11, "message": "Expression has type \"Any\"", "offset": 0, "src": "+ [f\"package:{el}\" for el in special_opts.packages]", @@ -11517,7 +11623,7 @@ }, { "code": "no-any-expr", - "column": 18, + "column": 11, "message": "Expression has type \"Any\"", "offset": 0, "src": "+ [f\"file:{el}\" for el in special_opts.files]", @@ -11581,7 +11687,7 @@ }, { "code": "no-any-expr", - "column": 37, + "column": 21, "message": "Expression has type \"Any\"", "offset": 1, "src": "fail(f\"Package name '{p}' cannot have a slash in it.\", stderr, options)", @@ -11597,7 +11703,7 @@ }, { "code": "no-any-expr", - "column": 43, + "column": 21, "message": "Expression has type \"Any\"", "offset": 2, "src": "fail(f\"Can't find package '{p}'\", stderr, options)", @@ -11677,7 +11783,7 @@ }, { "code": "no-any-expr", - "column": 56, + "column": 25, "message": "Expression has type \"Any\"", "offset": 1, "src": "parser.error(f\"Duplicate --cache-map source {source})\")", @@ -11701,7 +11807,7 @@ }, { "code": "no-any-expr", - "column": 54, + "column": 25, "message": "Expression has type \"Any\"", "offset": 1, "src": "parser.error(f\"Invalid --cache-map source {source} (triple[0] must be *.py[i])\")", @@ -11783,17 +11889,9 @@ "mypy/meet.py": [ { "code": "helpful-string", - "column": 40, - "message": "The type \"type[mypy.types.ProperType]\" doesn't define a __format__, __str__ or __repr__ method", - "offset": 569, - "src": "assert type(left) != type(right), f\"{type(left)} vs {type(right)}\"", - "target": "mypy.meet.is_overlapping_types" - }, - { - "code": "helpful-string", - "column": 56, + "column": 38, "message": "The type \"type[mypy.types.ProperType]\" doesn't define a __format__, __str__ or __repr__ method", - "offset": 0, + "offset": 577, "src": "assert type(left) != type(right), f\"{type(left)} vs {type(right)}\"", "target": "mypy.meet.is_overlapping_types" }, @@ -11913,7 +12011,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_callable_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 52, + "offset": 85, "src": "def visit_callable_type(self, t: CallableType) -> ProperType:", "target": "mypy.meet.TypeMeetVisitor.visit_callable_type" }, @@ -11929,7 +12027,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_tuple_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 19, + "offset": 97, "src": "def visit_tuple_type(self, t: TupleType) -> ProperType:", "target": "mypy.meet.TypeMeetVisitor.visit_tuple_type" }, @@ -11937,7 +12035,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_typeddict_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 16, + "offset": 20, "src": "def visit_typeddict_type(self, t: TypedDictType) -> ProperType:", "target": "mypy.meet.TypeMeetVisitor.visit_typeddict_type" }, @@ -12237,7 +12335,7 @@ "code": "no-any-explicit", "column": 4, "message": "Explicit \"Any\" is not allowed", - "offset": 553, + "offset": 567, "src": "def unsupported_operand_types(", "target": "mypy.messages.MessageBuilder.unsupported_operand_types" }, @@ -12275,7 +12373,7 @@ }, { "code": "helpful-string", - "column": 46, + "column": 20, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 350, "src": "f'This is likely because \"{original_caller_type.name}\" has named arguments: '", @@ -12341,15 +12439,15 @@ "code": "redundant-expr", "column": 13, "message": "Condition is always true", - "offset": 209, + "offset": 202, "src": "elif isinstance(tp, Overloaded):", "target": "mypy.messages.MessageBuilder.pretty_callable_or_overload" }, { "code": "helpful-string", - "column": 37, + "column": 26, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 487, + "offset": 503, "src": "self.note(f\" {k}: {v.accept(visitor) if v is not None else None}\", context)", "target": "mypy.messages.MessageBuilder.reveal_locals" }, @@ -12389,7 +12487,7 @@ "code": "no-any-explicit", "column": 4, "message": "Explicit \"Any\" is not allowed", - "offset": 184, + "offset": 187, "src": "def print_more(", "target": "mypy.messages.MessageBuilder.print_more" }, @@ -12411,15 +12509,15 @@ }, { "code": "helpful-string", - "column": 37, + "column": 35, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 156, + "offset": 158, "src": "arg_strings.append(f\"{arg_name}: {format(arg_type)}\")", "target": "mypy.messages.format_callable_args" }, { "code": "helpful-string", - "column": 37, + "column": 35, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 3, "src": "arg_strings.append(f\"{arg_name}: {format(arg_type)}\")", @@ -12427,7 +12525,7 @@ }, { "code": "helpful-string", - "column": 37, + "column": 35, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 6, "src": "arg_strings.append(f\"{arg_name}: {format(arg_type)}=...\")", @@ -12435,7 +12533,7 @@ }, { "code": "helpful-string", - "column": 37, + "column": 35, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 3, "src": "arg_strings.append(f\"{arg_name}: {format(arg_type)} = ...\")", @@ -12453,7 +12551,7 @@ "code": "redundant-expr", "column": 9, "message": "Condition is always false", - "offset": 259, + "offset": 263, "src": "elif typ is None:", "target": "mypy.messages.format_type_inner" }, @@ -12965,7 +13063,7 @@ "code": "no-any-expr", "column": 11, "message": "Expression type contains \"Any\" (has type \"Any | str\")", - "offset": 13, + "offset": 17, "src": "name = getattr(package, \"__name__\", package_id)", "target": "mypy.moduleinspect.get_package_properties" }, @@ -13065,7 +13163,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"__str__\" is not using @override but is overriding a method in class \"builtins.object\"", - "offset": 110, + "offset": 99, "src": "def __str__(self) -> str:", "target": "mypy.nodes.Node.__str__" }, @@ -13085,6 +13183,14 @@ "src": "return repr(self)", "target": "mypy.nodes.Node.__str__" }, + { + "code": "unreachable", + "column": 12, + "message": "See https://kotlinisland.github.io/basedmypy/_refs.html#code-unreachable for more info", + "offset": 0, + "src": "return repr(self)", + "target": null + }, { "code": "explicit-override", "column": 4, @@ -13105,7 +13211,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"name\" is not using @override but is overriding a method in class \"mypy.nodes.SymbolNode\"", - "offset": 144, + "offset": 147, "src": "def name(self) -> str:", "target": "mypy.nodes" }, @@ -13129,7 +13235,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"serialize\" is not using @override but is overriding a method in class \"mypy.nodes.SymbolNode\"", - "offset": 9, + "offset": 15, "src": "def serialize(self) -> JsonDict:", "target": "mypy.nodes.MypyFile.serialize" }, @@ -13201,7 +13307,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"name\" is not using @override but is overriding a method in class \"mypy.nodes.FuncBase\"", - "offset": 91, + "offset": 89, "src": "def name(self) -> str:", "target": "mypy.nodes" }, @@ -13289,7 +13395,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"name\" is not using @override but is overriding a method in class \"mypy.nodes.FuncBase\"", - "offset": 145, + "offset": 144, "src": "def name(self) -> str:", "target": "mypy.nodes" }, @@ -13841,7 +13947,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"accept\" is not using @override but is overriding a method in class \"mypy.nodes.Expression\"", - "offset": 23, + "offset": 28, "src": "def accept(self, visitor: ExpressionVisitor[T]) -> T:", "target": "mypy.nodes.RevealExpr.accept" }, @@ -14481,7 +14587,7 @@ "code": "redundant-expr", "column": 15, "message": "Condition is always true", - "offset": 29, + "offset": 31, "src": "if prefix is not None:", "target": "mypy.nodes.SymbolTableNode.serialize" }, @@ -14575,7 +14681,7 @@ }, { "code": "helpful-string", - "column": 13, + "column": 11, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 21, "src": "return f\"{initial}.{expr.name}\"", @@ -14651,7 +14757,7 @@ "code": "no-any-expr", "column": 18, "message": "Expression has type \"Any\"", - "offset": 125, + "offset": 128, "src": "MACHDEP = sysconfig.get_config_var(\"MACHDEP\")", "target": "mypy.options.Options.__init__" }, @@ -14675,7 +14781,7 @@ "code": "no-any-explicit", "column": 8, "message": "Explicit \"Any\" is not allowed", - "offset": 268, + "offset": 267, "src": "self.transform_source: Callable[[Any], Any] | None = None", "target": "mypy.options.Options.__init__" }, @@ -14683,7 +14789,7 @@ "code": "no-any-expr", "column": 17, "message": "Expression type contains \"Any\" (has type \"Any | Iterable[(Any, Any)]\")", - "offset": 55, + "offset": 56, "src": "d = dict(getattr(self, \"__dict__\", ()))", "target": "mypy.options.Options.snapshot" }, @@ -15095,14 +15201,6 @@ "src": "def add_symbol_table_node(self, name: str, stnode: SymbolTableNode) -> Any:", "target": "mypy.plugin" }, - { - "code": "no-any-decorated", - "column": 4, - "message": "See https://kotlinisland.github.io/basedmypy/_refs.html#code-no-any-decorated for more info", - "offset": 0, - "src": "def add_symbol_table_node(self, name: str, stnode: SymbolTableNode) -> Any:", - "target": null - }, { "code": "explicit-override", "column": 4, @@ -15435,15 +15533,15 @@ }, { "code": "helpful-string", - "column": 24, + "column": 21, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 207, + "offset": 214, "src": "ctx.api.fail(f'\"{ctx.default_signature.name}\" has unexpected type annotation', ctx.context)", "target": "mypy.plugins.attrs.evolve_function_sig_callback" }, { "code": "helpful-string", - "column": 15, + "column": 13, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 21, "src": "name=f\"{ctx.default_signature.name} of {inst_type_str}\",", @@ -15455,7 +15553,7 @@ "code": "redundant-expr", "column": 13, "message": "Condition is always true", - "offset": 134, + "offset": 135, "src": "elif of == \"__post_init__\":", "target": "mypy.plugins.dataclasses.DataclassAttribute.to_argument" }, @@ -15479,7 +15577,7 @@ "code": "no-any-expr", "column": 37, "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", - "offset": 212, + "offset": 210, "src": "info.metadata[\"dataclass\"] = {", "target": "mypy.plugins.dataclasses.DataclassTransformer.transform" }, @@ -15503,7 +15601,7 @@ "code": "no-any-expr", "column": 12, "message": "Expression has type \"Any\"", - "offset": 140, + "offset": 146, "src": "for data in info.metadata[\"dataclass\"][\"attributes\"]:", "target": "mypy.plugins.dataclasses.DataclassTransformer.collect_attributes" }, @@ -15527,21 +15625,21 @@ "code": "no-any-expr", "column": 37, "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", - "offset": 386, + "offset": 390, "src": "info.metadata[\"dataclass_tag\"] = {}", "target": "mypy.plugins.dataclasses.add_dataclass_tag" }, { "code": "helpful-string", - "column": 24, + "column": 21, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 151, + "offset": 128, "src": "ctx.api.fail(f'\"{ctx.default_signature.name}\" has unexpected type annotation', ctx.context)", "target": "mypy.plugins.dataclasses.replace_function_sig_callback" }, { "code": "helpful-string", - "column": 15, + "column": 13, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 21, "src": "name=f\"{ctx.default_signature.name} of {inst_type_str}\",", @@ -15577,7 +15675,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"get_method_hook\" is not using @override but is overriding a method in class \"mypy.plugin.Plugin\"", - "offset": 21, + "offset": 30, "src": "def get_method_hook(self, fullname: str) -> Callable[[MethodContext], Type] | None:", "target": "mypy.plugins.default.DefaultPlugin.get_method_hook" }, @@ -15609,7 +15707,7 @@ "code": "redundant-expr", "column": 9, "message": "Condition is always false", - "offset": 355, + "offset": 360, "src": "elif isinstance(ctx.type, LiteralType):", "target": "mypy.plugins.default.tuple_mul_callback" }, @@ -15666,6 +15764,16 @@ "target": "mypy.plugins.functools._analyze_class" } ], + "mypy/plugins/proper_plugin.py": [ + { + "code": "explicit-override", + "column": 4, + "message": "Method \"get_function_hook\" is not using @override but is overriding a method in class \"mypy.plugin.Plugin\"", + "offset": 45, + "src": "def get_function_hook(self, fullname: str) -> Callable[[FunctionContext], Type] | None:", + "target": "mypy.plugins.proper_plugin.ProperTypePlugin.get_function_hook" + } + ], "mypy/plugins/re.py": [ { "code": "no-any-expr", @@ -15985,7 +16093,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"on_finish\" is not using @override but is overriding a method in class \"mypy.report.AbstractReporter\"", - "offset": 32, + "offset": 36, "src": "def on_finish(self) -> None:", "target": "mypy.report.LineCountReporter.on_finish" }, @@ -16893,7 +17001,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"type\" is not using @override but is overriding a method in class \"mypy.semanal_shared.SemanticAnalyzerCoreInterface\"", - "offset": 479, + "offset": 474, "src": "def type(self) -> TypeInfo | None:", "target": "mypy.semanal" }, @@ -16925,7 +17033,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_func_def\" is not using @override but is overriding a method in class \"mypy.visitor.NodeVisitor\"", - "offset": 325, + "offset": 328, "src": "def visit_func_def(self, defn: FuncDef) -> None:", "target": "mypy.semanal.SemanticAnalyzer.visit_func_def" }, @@ -16955,7 +17063,7 @@ }, { "code": "helpful-string", - "column": 39, + "column": 36, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 60, "src": "overlapped = \", \".join([f'\"{name}\"' for name in overlap])", @@ -17011,7 +17119,7 @@ }, { "code": "helpful-string", - "column": 59, + "column": 26, "message": "The type \"type[mypy.types.ProperType]\" doesn't define a __format__, __str__ or __repr__ method", "offset": 113, "src": "assert False, f\"Unexpected special alias type: {type(target)}\"", @@ -17029,7 +17137,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"get_and_bind_all_tvars\" is not using @override but is overriding a method in class \"mypy.semanal_shared.SemanticAnalyzerInterface\"", - "offset": 110, + "offset": 114, "src": "def get_and_bind_all_tvars(self, type_exprs: list[Expression]) -> list[TypeVarLikeType]:", "target": "mypy.semanal.SemanticAnalyzer.get_and_bind_all_tvars" }, @@ -17037,7 +17145,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_import\" is not using @override but is overriding a method in class \"mypy.visitor.NodeVisitor\"", - "offset": 419, + "offset": 420, "src": "def visit_import(self, i: Import) -> None:", "target": "mypy.semanal.SemanticAnalyzer.visit_import" }, @@ -17109,7 +17217,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"analyze_simple_literal_type\" is not using @override but is overriding a method in class \"mypy.plugin.SemanticAnalyzerPluginInterface\"", - "offset": 245, + "offset": 252, "src": "def analyze_simple_literal_type(", "target": "mypy.semanal.SemanticAnalyzer.analyze_simple_literal_type" }, @@ -17131,9 +17239,9 @@ }, { "code": "helpful-string", - "column": 71, + "column": 20, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 759, + "offset": 768, "src": "f'{message_registry.TYPEVAR_UNEXPECTED_ARGUMENT}: \"{param_name}\"', context", "target": "mypy.semanal.SemanticAnalyzer.process_typevar_parameters" }, @@ -17147,7 +17255,7 @@ }, { "code": "helpful-string", - "column": 57, + "column": 26, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 134, "src": "self.fail(f'Unexpected keyword argument \"{param_name}\" for \"TypeVarTuple\"', s)", @@ -17157,7 +17265,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"basic_new_typeinfo\" is not using @override but is overriding a method in class \"mypy.semanal_shared.SemanticAnalyzerInterface\"", - "offset": 33, + "offset": 31, "src": "def basic_new_typeinfo(self, name: str, basetype_or_fallback: Instance, line: int) -> TypeInfo:", "target": "mypy.semanal.SemanticAnalyzer.basic_new_typeinfo" }, @@ -17441,11 +17549,35 @@ "src": "def visit_call_expr(self, expr: CallExpr) -> None:", "target": "mypy.semanal.SemanticAnalyzer.visit_call_expr" }, + { + "code": "redundant-expr", + "column": 16, + "message": "Condition is always false", + "offset": 42, + "src": "reveal_type_node", + "target": "mypy.semanal.SemanticAnalyzer.visit_call_expr" + }, + { + "code": "unreachable", + "column": 20, + "message": "Right operand of \"and\" is never evaluated", + "offset": 2, + "src": "and reveal_type_node.fullname in IMPORTED_REVEAL_TYPE_NAMES", + "target": "mypy.semanal.SemanticAnalyzer.visit_call_expr" + }, + { + "code": "unreachable", + "column": 16, + "message": "Statement is unreachable", + "offset": 2, + "src": "reveal_imported = True", + "target": "mypy.semanal.SemanticAnalyzer.visit_call_expr" + }, { "code": "no-any-expr", "column": 23, "message": "Expression type contains \"Any\" (has type \"Any | bool\")", - "offset": 56, + "offset": 20, "src": "if getattr(n.node, \"is_inferred\", False) and isinstance(n.node, Var)", "target": "mypy.semanal.SemanticAnalyzer.visit_call_expr" }, @@ -17509,7 +17641,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_slice_expr\" is not using @override but is overriding a method in class \"mypy.visitor.NodeVisitor\"", - "offset": 124, + "offset": 126, "src": "def visit_slice_expr(self, expr: SliceExpr) -> None:", "target": "mypy.semanal.SemanticAnalyzer.visit_slice_expr" }, @@ -17685,7 +17817,7 @@ "code": "possibly-undefined", "column": 23, "message": "Name \"implicit_node\" may be undefined", - "offset": 62, + "offset": 65, "src": "return implicit_node", "target": "mypy.semanal" }, @@ -17965,7 +18097,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"anal_type\" is not using @override but is overriding a method in class \"mypy.semanal_shared.SemanticAnalyzerInterface\"", - "offset": 97, + "offset": 99, "src": "def anal_type(", "target": "mypy.semanal.SemanticAnalyzer.anal_type" }, @@ -18037,7 +18169,7 @@ "mypy/semanal_enum.py": [ { "code": "helpful-string", - "column": 71, + "column": 40, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 157, "src": "self.fail_enum_call_arg(f'Unexpected keyword argument \"{arg_name}\"', call)", @@ -18083,7 +18215,7 @@ "code": "redundant-expr", "column": 19, "message": "Condition is always true", - "offset": 393, + "offset": 392, "src": "if not is_StrExpr_list(listexpr.items):", "target": "mypy.semanal_namedtuple.NamedTupleAnalyzer.parse_namedtuple_args" }, @@ -18107,7 +18239,7 @@ "code": "no-any-expr", "column": 38, "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", - "offset": 109, + "offset": 108, "src": "info.metadata[\"namedtuple\"] = {\"fields\": items.copy()}", "target": "mypy.semanal_namedtuple.NamedTupleAnalyzer.build_namedtuple_typeinfo" } @@ -18223,7 +18355,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_placeholder_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.BoolTypeQuery\"", - "offset": 349, + "offset": 367, "src": "def visit_placeholder_type(self, t: PlaceholderType) -> bool:", "target": "mypy.semanal_shared.HasPlaceholders.visit_placeholder_type" } @@ -18233,7 +18365,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_mypy_file\" is not using @override but is overriding a method in class \"mypy.traverser.TraverserVisitor\"", - "offset": 57, + "offset": 63, "src": "def visit_mypy_file(self, o: MypyFile) -> None:", "target": "mypy.semanal_typeargs.TypeArgumentAnalyzer.visit_mypy_file" }, @@ -18271,9 +18403,9 @@ }, { "code": "helpful-string", - "column": 57, + "column": 36, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 12, + "offset": 8, "src": "assert t.alias is not None, f\"Unfixed type alias {t.type_ref}\"", "target": "mypy.semanal_typeargs.TypeArgumentAnalyzer.visit_type_alias_type" }, @@ -18281,7 +18413,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_tuple_type\" is not using @override but is overriding a method in class \"mypy.typetraverser.TypeTraverserVisitor\"", - "offset": 32, + "offset": 7, "src": "def visit_tuple_type(self, t: TupleType) -> None:", "target": "mypy.semanal_typeargs.TypeArgumentAnalyzer.visit_tuple_type" }, @@ -18305,7 +18437,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_unpack_type\" is not using @override but is overriding a method in class \"mypy.typetraverser.TypeTraverserVisitor\"", - "offset": 100, + "offset": 94, "src": "def visit_unpack_type(self, typ: UnpackType) -> None:", "target": "mypy.semanal_typeargs.TypeArgumentAnalyzer.visit_unpack_type" } @@ -18313,9 +18445,9 @@ "mypy/semanal_typeddict.py": [ { "code": "helpful-string", - "column": 47, + "column": 16, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 427, + "offset": 431, "src": "f'Unexpected keyword argument \"{call.arg_names[2]}\" for \"TypedDict\"', call", "target": "mypy.semanal_typeddict.TypedDictAnalyzer.parse_typeddict_args" } @@ -18325,7 +18457,7 @@ "code": "redundant-expr", "column": 7, "message": "Condition is always false", - "offset": 234, + "offset": 235, "src": "if isinstance(node, FuncBase):", "target": "mypy.server.astdiff.snapshot_definition" }, @@ -18445,7 +18577,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_tuple_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 31, + "offset": 32, "src": "def visit_tuple_type(self, typ: TupleType) -> SnapshotItem:", "target": "mypy.server.astdiff.SnapshotTypeVisitor.visit_tuple_type" }, @@ -19524,7 +19656,7 @@ "column": 4, "message": "Method \"visit_intersection_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", "offset": 6, - "src": "def visit_intersection_type(self, typ: IntersectionType) -> List[str]:", + "src": "def visit_intersection_type(self, typ: IntersectionType) -> list[str]:", "target": "mypy.server.deps.TypeTriggersVisitor.visit_intersection_type" } ], @@ -19547,7 +19679,7 @@ }, { "code": "helpful-string", - "column": 29, + "column": 26, "message": "The string for \"object\" isn't helpful in a user-facing or semantic string", "offset": 44, "src": "result += f\".{attr}({t}:{obj.name})\"", @@ -19555,7 +19687,7 @@ }, { "code": "helpful-string", - "column": 29, + "column": 26, "message": "The string for \"object\" isn't helpful in a user-facing or semantic string", "offset": 4, "src": "result += f\".{attr}\"", @@ -19563,7 +19695,7 @@ }, { "code": "helpful-string", - "column": 29, + "column": 26, "message": "The string for \"object\" isn't helpful in a user-facing or semantic string", "offset": 2, "src": "result += f\".{attr}({t})\"", @@ -20069,15 +20201,31 @@ "code": "possibly-undefined", "column": 23, "message": "Name \"solvable_tv\" may be undefined", - "offset": 200, + "offset": 212, "src": "s_batch.remove(solvable_tv)", "target": "mypy.solve" }, + { + "code": "truthy-iterable", + "column": 26, + "message": "\"lowers\" has type \"Iterable[Type]\" which can always be true in boolean context. Consider using \"Collection[Type]\" instead.", + "offset": 49, + "src": "if not uppers and not lowers:", + "target": "mypy.solve.solve_one" + }, + { + "code": "truthy-iterable", + "column": 26, + "message": "See https://kotlinisland.github.io/basedmypy/_refs.html#code-truthy-iterable for more info", + "offset": 0, + "src": "if not uppers and not lowers:", + "target": null + }, { "code": "redundant-expr", "column": 11, "message": "Condition is always true", - "offset": 44, + "offset": 9, "src": "if bottom is None:", "target": "mypy.solve.solve_one" }, @@ -20561,7 +20709,7 @@ "mypy/strconv.py": [ { "code": "helpful-string", - "column": 22, + "column": 19, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 52, "src": "return f\"<{self.get_id(o)}>\"", @@ -20569,7 +20717,7 @@ }, { "code": "helpful-string", - "column": 22, + "column": 19, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 14, "src": "tag += f\"<{self.get_id(obj)}>\"", @@ -21337,7 +21485,7 @@ }, { "code": "helpful-string", - "column": 27, + "column": 22, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 5, "src": "pretty += f\" = {o.node.final_value}\"", @@ -21345,7 +21493,7 @@ }, { "code": "helpful-string", - "column": 21, + "column": 17, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 22, "src": "n += f\" [{fullname}{id}]\"", @@ -21383,6 +21531,14 @@ "src": "if o.expr:", "target": "mypy.strconv.StrConv.visit_yield_from_expr" }, + { + "code": "truthy-bool", + "column": 11, + "message": "See https://kotlinisland.github.io/basedmypy/_refs.html#code-truthy-bool for more info", + "offset": 0, + "src": "if o.expr:", + "target": null + }, { "code": "explicit-override", "column": 4, @@ -21841,7 +21997,7 @@ }, { "code": "helpful-string", - "column": 56, + "column": 15, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 1, "src": "return f\"NamedTupleExpr:{o.line}({o.info.name}, {self.stringify_type(o.info.tuple_type) if o.info.tuple_type is not None else None})\"", @@ -22149,7 +22305,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"__repr__\" is not using @override but is overriding a method in class \"builtins.object\"", - "offset": 44, + "offset": 51, "src": "def __repr__(self) -> str:", "target": "mypy.stubdoc.ArgSig.__repr__" }, @@ -22182,54 +22338,22 @@ { "code": "explicit-override", "column": 4, - "message": "Method \"visit_any\" is not using @override but is overriding a method in class \"mypy.types.TypeStrVisitor\"", - "offset": 328, - "src": "def visit_any(self, t: AnyType) -> str:", - "target": "mypy.stubgen.AnnotationPrinter.visit_any" - }, - { - "code": "explicit-override", - "column": 4, - "message": "Method \"visit_unbound_type\" is not using @override but is overriding a method in class \"mypy.types.TypeStrVisitor\"", - "offset": 5, - "src": "def visit_unbound_type(self, t: UnboundType) -> str:", - "target": "mypy.stubgen.AnnotationPrinter.visit_unbound_type" - }, - { - "code": "explicit-override", - "column": 4, - "message": "Method \"visit_none_type\" is not using @override but is overriding a method in class \"mypy.types.TypeStrVisitor\"", - "offset": 7, - "src": "def visit_none_type(self, t: NoneType) -> str:", - "target": "mypy.stubgen.AnnotationPrinter.visit_none_type" - }, - { - "code": "explicit-override", - "column": 4, - "message": "Method \"visit_type_list\" is not using @override but is overriding a method in class \"mypy.types.TypeStrVisitor\"", - "offset": 3, - "src": "def visit_type_list(self, t: TypeList) -> str:", - "target": "mypy.stubgen.AnnotationPrinter.visit_type_list" - }, - { - "code": "explicit-override", - "column": 4, - "message": "Method \"visit_union_type\" is not using @override but is overriding a method in class \"mypy.types.TypeStrVisitor\"", - "offset": 3, - "src": "def visit_union_type(self, t: UnionType) -> str:", - "target": "mypy.stubgen.AnnotationPrinter.visit_union_type" + "message": "Method \"__repr__\" is not using @override but is overriding a method in class \"builtins.object\"", + "offset": 237, + "src": "def __repr__(self) -> str:", + "target": "mypy.stubgen.StubSource.__repr__" }, { "code": "explicit-override", "column": 4, "message": "Method \"visit_call_expr\" is not using @override but is overriding a method in class \"mypy.visitor.NodeVisitor\"", - "offset": 30, + "offset": 37, "src": "def visit_call_expr(self, node: CallExpr) -> str:", "target": "mypy.stubgen.AliasPrinter.visit_call_expr" }, { "code": "helpful-string", - "column": 30, + "column": 28, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 13, "src": "args.append(f\"{name}={arg.accept(self)}\")", @@ -22311,7 +22435,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_class_def\" is not using @override but is overriding a method in class \"mypy.traverser.TraverserVisitor\"", - "offset": 132, + "offset": 19, "src": "def visit_class_def(self, o: ClassDef) -> None:", "target": "mypy.stubgen.DefinitionFinder.visit_class_def" }, @@ -22327,7 +22451,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_block\" is not using @override but is overriding a method in class \"mypy.traverser.TraverserVisitor\"", - "offset": 20, + "offset": 24, "src": "def visit_block(self, block: Block) -> None:", "target": "mypy.stubgen.ReferenceFinder.visit_block" }, @@ -22375,49 +22499,49 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_mypy_file\" is not using @override but is overriding a method in class \"mypy.traverser.TraverserVisitor\"", - "offset": 54, + "offset": 38, "src": "def visit_mypy_file(self, o: MypyFile) -> None:", - "target": "mypy.stubgen.StubGenerator.visit_mypy_file" + "target": "mypy.stubgen.ASTStubGenerator.visit_mypy_file" }, { "code": "explicit-override", "column": 4, "message": "Method \"visit_overloaded_func_def\" is not using @override but is overriding a method in class \"mypy.traverser.TraverserVisitor\"", - "offset": 28, + "offset": 8, "src": "def visit_overloaded_func_def(self, o: OverloadedFuncDef) -> None:", - "target": "mypy.stubgen.StubGenerator.visit_overloaded_func_def" + "target": "mypy.stubgen.ASTStubGenerator.visit_overloaded_func_def" }, { "code": "explicit-override", "column": 4, "message": "Method \"visit_func_def\" is not using @override but is overriding a method in class \"mypy.traverser.TraverserVisitor\"", - "offset": 20, + "offset": 131, "src": "def visit_func_def(self, o: FuncDef) -> None:", - "target": "mypy.stubgen.StubGenerator.visit_func_def" + "target": "mypy.stubgen.ASTStubGenerator.visit_func_def" }, { "code": "explicit-override", "column": 4, "message": "Method \"visit_decorator\" is not using @override but is overriding a method in class \"mypy.traverser.TraverserVisitor\"", - "offset": 122, + "offset": 56, "src": "def visit_decorator(self, o: Decorator) -> None:", - "target": "mypy.stubgen.StubGenerator.visit_decorator" + "target": "mypy.stubgen.ASTStubGenerator.visit_decorator" }, { "code": "explicit-override", "column": 4, "message": "Method \"visit_class_def\" is not using @override but is overriding a method in class \"mypy.traverser.TraverserVisitor\"", - "offset": 72, + "offset": 73, "src": "def visit_class_def(self, o: ClassDef) -> None:", - "target": "mypy.stubgen.StubGenerator.visit_class_def" + "target": "mypy.stubgen.ASTStubGenerator.visit_class_def" }, { "code": "explicit-override", "column": 4, "message": "Method \"visit_block\" is not using @override but is overriding a method in class \"mypy.traverser.TraverserVisitor\"", - "offset": 87, + "offset": 104, "src": "def visit_block(self, o: Block) -> None:", - "target": "mypy.stubgen.StubGenerator.visit_block" + "target": "mypy.stubgen.ASTStubGenerator.visit_block" }, { "code": "explicit-override", @@ -22425,15 +22549,15 @@ "message": "Method \"visit_assignment_stmt\" is not using @override but is overriding a method in class \"mypy.traverser.TraverserVisitor\"", "offset": 6, "src": "def visit_assignment_stmt(self, o: AssignmentStmt) -> None:", - "target": "mypy.stubgen.StubGenerator.visit_assignment_stmt" + "target": "mypy.stubgen.ASTStubGenerator.visit_assignment_stmt" }, { "code": "explicit-override", "column": 4, "message": "Method \"visit_if_stmt\" is not using @override but is overriding a method in class \"mypy.traverser.TraverserVisitor\"", - "offset": 235, + "offset": 238, "src": "def visit_if_stmt(self, o: IfStmt) -> None:", - "target": "mypy.stubgen.StubGenerator.visit_if_stmt" + "target": "mypy.stubgen.ASTStubGenerator.visit_if_stmt" }, { "code": "explicit-override", @@ -22441,7 +22565,7 @@ "message": "Method \"visit_import_all\" is not using @override but is overriding a method in class \"mypy.visitor.NodeVisitor\"", "offset": 13, "src": "def visit_import_all(self, o: ImportAll) -> None:", - "target": "mypy.stubgen.StubGenerator.visit_import_all" + "target": "mypy.stubgen.ASTStubGenerator.visit_import_all" }, { "code": "explicit-override", @@ -22449,21 +22573,29 @@ "message": "Method \"visit_import_from\" is not using @override but is overriding a method in class \"mypy.traverser.TraverserVisitor\"", "offset": 3, "src": "def visit_import_from(self, o: ImportFrom) -> None:", - "target": "mypy.stubgen.StubGenerator.visit_import_from" + "target": "mypy.stubgen.ASTStubGenerator.visit_import_from" }, { "code": "explicit-override", "column": 4, "message": "Method \"visit_import\" is not using @override but is overriding a method in class \"mypy.traverser.TraverserVisitor\"", - "offset": 65, + "offset": 37, "src": "def visit_import(self, o: Import) -> None:", - "target": "mypy.stubgen.StubGenerator.visit_import" + "target": "mypy.stubgen.ASTStubGenerator.visit_import" + }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"should_reexport\" is not using @override but is overriding a method in class \"mypy.stubutil.BaseStubGenerator\"", + "offset": 138, + "src": "def should_reexport(self, name: str, full_module: str, name_is_alias: bool) -> bool:", + "target": "mypy.stubgen.ASTStubGenerator.should_reexport" }, { "code": "explicit-override", "column": 4, "message": "Method \"visit_assignment_stmt\" is not using @override but is overriding a method in class \"mypy.traverser.TraverserVisitor\"", - "offset": 219, + "offset": 34, "src": "def visit_assignment_stmt(self, o: AssignmentStmt) -> None:", "target": "mypy.stubgen.SelfTraverser.visit_assignment_stmt" }, @@ -22471,7 +22603,7 @@ "code": "no-any-expr", "column": 16, "message": "Expression type contains \"Any\" (has type \"list[Any]\")", - "offset": 450, + "offset": 466, "src": "default=[],", "target": "mypy.stubgen.parse_options" }, @@ -22523,6 +22655,22 @@ "src": "if ns.quiet and ns.verbose:", "target": "mypy.stubgen.parse_options" }, + { + "code": "no-any-expr", + "column": 7, + "message": "Expression has type \"Any\"", + "offset": 2, + "src": "if ns.inspect and ns.parse_only:", + "target": "mypy.stubgen.parse_options" + }, + { + "code": "no-any-expr", + "column": 22, + "message": "Expression has type \"Any\"", + "offset": 0, + "src": "if ns.inspect and ns.parse_only:", + "target": "mypy.stubgen.parse_options" + }, { "code": "no-any-expr", "column": 26, @@ -22547,6 +22695,14 @@ "src": "no_import=ns.no_import,", "target": "mypy.stubgen.parse_options" }, + { + "code": "no-any-expr", + "column": 16, + "message": "Expression has type \"Any\"", + "offset": 1, + "src": "inspect=ns.inspect,", + "target": "mypy.stubgen.parse_options" + }, { "code": "no-any-expr", "column": 16, @@ -22664,674 +22820,1042 @@ { "code": "explicit-override", "column": 4, - "message": "Method \"get_function_sig\" is not using @override but is overriding a method in class \"mypy.stubgenc.SignatureGenerator\"", - "offset": 82, + "message": "Method \"get_function_sig\" is not using @override but is overriding a method in class \"mypy.stubutil.SignatureGenerator\"", + "offset": 66, "src": "def get_function_sig(", "target": "mypy.stubgenc.ExternalSignatureGenerator.get_function_sig" }, { "code": "explicit-override", "column": 4, - "message": "Method \"get_method_sig\" is not using @override but is overriding a method in class \"mypy.stubgenc.SignatureGenerator\"", - "offset": 14, - "src": "def get_method_sig(", - "target": "mypy.stubgenc.ExternalSignatureGenerator.get_method_sig" + "message": "Method \"get_property_type\" is not using @override but is overriding a method in class \"mypy.stubutil.SignatureGenerator\"", + "offset": 34, + "src": "def get_property_type(self, default_type: str | None, ctx: FunctionContext) -> str | None:", + "target": "mypy.stubgenc.ExternalSignatureGenerator.get_property_type" }, { "code": "explicit-override", "column": 4, - "message": "Method \"get_function_sig\" is not using @override but is overriding a method in class \"mypy.stubgenc.SignatureGenerator\"", - "offset": 20, + "message": "Method \"get_function_sig\" is not using @override but is overriding a method in class \"mypy.stubutil.SignatureGenerator\"", + "offset": 5, "src": "def get_function_sig(", "target": "mypy.stubgenc.DocstringSignatureGenerator.get_function_sig" }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"get_property_type\" is not using @override but is overriding a method in class \"mypy.stubutil.SignatureGenerator\"", + "offset": 20, + "src": "def get_property_type(self, default_type: str | None, ctx: FunctionContext) -> str | None:", + "target": "mypy.stubgenc.DocstringSignatureGenerator.get_property_type" + }, + { + "code": "no-any-expr", + "column": 26, + "message": "Expression type contains \"Any\" (has type \"FullArgSpec\")", + "offset": 122, + "src": "argspec = inspect.getfullargspec(func)", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 11, + "message": "Expression type contains \"Any\" (has type \"FullArgSpec | None\")", + "offset": 4, + "src": "if argspec is None:", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 15, + "message": "Expression type contains \"Any\" (has type \"FullArgSpec\")", + "offset": 17, + "src": "args = argspec.args", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 19, + "message": "Expression type contains \"Any\" (has type \"FullArgSpec\")", + "offset": 1, + "src": "defaults = argspec.defaults", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 19, + "message": "Expression type contains \"Any\" (has type \"tuple[Any, ...] | None\")", + "offset": 0, + "src": "defaults = argspec.defaults", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 18, + "message": "Expression type contains \"Any\" (has type \"FullArgSpec\")", + "offset": 1, + "src": "varargs = argspec.varargs", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, { "code": "no-any-expr", "column": 17, - "message": "Expression type contains \"Any\" (has type \"Any | None\")", + "message": "Expression type contains \"Any\" (has type \"FullArgSpec\")", + "offset": 1, + "src": "kwargs = argspec.varkw", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 22, + "message": "Expression type contains \"Any\" (has type \"FullArgSpec\")", + "offset": 1, + "src": "annotations = argspec.annotations", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 22, + "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", + "offset": 0, + "src": "annotations = argspec.annotations", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 26, + "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", "offset": 3, - "src": "docstr = getattr(func, \"__doc__\", None)", - "target": "mypy.stubgenc.DocstringSignatureGenerator.get_function_sig" + "src": "if key not in annotations:", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" }, { "code": "no-any-expr", - "column": 44, - "message": "Expression type contains \"Any\" (has type \"Any | None\")", + "column": 22, + "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", + "offset": 2, + "src": "argtype = annotations[key]", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 22, + "message": "Expression has type \"Any\"", + "offset": 0, + "src": "argtype = annotations[key]", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 15, + "message": "Expression has type \"Any\"", "offset": 1, - "src": "inferred = infer_sig_from_docstring(docstr, name)", - "target": "mypy.stubgenc.DocstringSignatureGenerator.get_function_sig" + "src": "if argtype is None:", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" }, { "code": "no-any-expr", - "column": 19, - "message": "Expression type contains \"Any\" (has type \"Any | None\")", + "column": 30, + "message": "Expression has type \"Any\"", "offset": 2, - "src": "assert docstr is not None", - "target": "mypy.stubgenc.DocstringSignatureGenerator.get_function_sig" + "src": "if not isinstance(argtype, str):", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" }, { "code": "no-any-expr", - "column": 57, + "column": 46, "message": "Expression has type \"Any\"", "offset": 1, - "src": "if is_pybind11_overloaded_function_docstring(docstr, name):", - "target": "mypy.stubgenc.DocstringSignatureGenerator.get_function_sig" + "src": "return self.get_type_fullname(argtype)", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" }, { - "code": "explicit-override", - "column": 4, - "message": "Method \"get_method_sig\" is not using @override but is overriding a method in class \"mypy.stubgenc.SignatureGenerator\"", + "code": "no-any-expr", + "column": 15, + "message": "Expression type contains \"Any\" (has type \"tuple[Any, ...] | None\")", + "offset": 7, + "src": "if defaults and i >= len(args) - len(defaults):", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 15, + "message": "Expression type contains \"Any\" (has type \"tuple[Any, ...] | None | bool\")", + "offset": 0, + "src": "if defaults and i >= len(args) - len(defaults):", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 49, + "message": "Expression type contains \"Any\" (has type \"tuple[Any, ...]\")", + "offset": 0, + "src": "if defaults and i >= len(args) - len(defaults):", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 32, + "message": "Expression type contains \"Any\" (has type \"tuple[Any, ...]\")", + "offset": 1, + "src": "default_value = defaults[i - (len(args) - len(defaults))]", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 32, + "message": "Expression has type \"Any\"", + "offset": 0, + "src": "default_value = defaults[i - (len(args) - len(defaults))]", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 62, + "message": "Expression type contains \"Any\" (has type \"tuple[Any, ...]\")", + "offset": 0, + "src": "default_value = defaults[i - (len(args) - len(defaults))]", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 26, + "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", + "offset": 1, + "src": "if arg in annotations:", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 30, + "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", + "offset": 1, + "src": "argtype = annotations[arg]", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 30, + "message": "Expression has type \"Any\"", + "offset": 0, + "src": "argtype = annotations[arg]", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 55, + "message": "Expression has type \"Any\"", + "offset": 2, + "src": "argtype = self.get_type_annotation(default_value)", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 23, + "message": "Expression has type \"Any\"", + "offset": 1, + "src": "if argtype == \"None\":", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" + }, + { + "code": "no-any-expr", + "column": 43, + "message": "Expression has type \"Any\"", "offset": 5, - "src": "def get_method_sig(", - "target": "mypy.stubgenc.DocstringSignatureGenerator.get_method_sig" + "src": "arglist.append(ArgSig(arg, argtype, default=True))", + "target": "mypy.stubgenc.InspectionStubGenerator.get_default_function_sig" }, { "code": "explicit-override", "column": 4, - "message": "Method \"get_function_sig\" is not using @override but is overriding a method in class \"mypy.stubgenc.SignatureGenerator\"", - "offset": 17, - "src": "def get_function_sig(", - "target": "mypy.stubgenc.FallbackSignatureGenerator.get_function_sig" + "message": "Method \"get_sig_generators\" is not using @override but is overriding a method in class \"mypy.stubutil.BaseStubGenerator\"", + "offset": 25, + "src": "def get_sig_generators(self) -> list[SignatureGenerator]:", + "target": "mypy.stubgenc.InspectionStubGenerator.get_sig_generators" }, { - "code": "explicit-override", - "column": 4, - "message": "Method \"get_method_sig\" is not using @override but is overriding a method in class \"mypy.stubgenc.SignatureGenerator\"", - "offset": 11, - "src": "def get_method_sig(", - "target": "mypy.stubgenc.FallbackSignatureGenerator.get_method_sig" + "code": "no-any-expr", + "column": 15, + "message": "Expression type contains \"Any\" (has type \"Any | None\")", + "offset": 26, + "src": "return getattr(obj, \"__module__\", None)", + "target": "mypy.stubgenc.InspectionStubGenerator.get_obj_module" }, { "code": "no-any-expr", - "column": 12, + "column": 20, "message": "Expression type contains \"Any\" (has type \"list[(str, Any)]\")", - "offset": 39, - "src": "items = sorted(get_members(module), key=lambda x: x[0])", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "offset": 8, + "src": "all_items = self.get_members(self.module)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 19, + "column": 31, "message": "Expression type contains \"Any\" (has type \"list[(str, Any)]\")", - "offset": 0, - "src": "items = sorted(get_members(module), key=lambda x: x[0])", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "offset": 2, + "src": "all_items = sorted(all_items, key=lambda x: x[0])", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 44, + "column": 46, "message": "Expression type contains \"Any\" (has type \"(x: (str, Any)) -> str\")", "offset": 0, - "src": "items = sorted(get_members(module), key=lambda x: x[0])", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "src": "all_items = sorted(all_items, key=lambda x: x[0])", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 54, + "column": 56, "message": "Expression type contains \"Any\" (has type \"(str, Any)\")", "offset": 0, - "src": "items = sorted(get_members(module), key=lambda x: x[0])", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "src": "all_items = sorted(all_items, key=lambda x: x[0])", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 4, + "column": 8, "message": "Expression type contains \"Any\" (has type \"(str, Any)\")", - "offset": 1, - "src": "for name, obj in items:", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "offset": 2, + "src": "for name, obj in all_items:", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 4, + "column": 8, "message": "Expression has type \"Any\"", "offset": 0, - "src": "for name, obj in items:", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "src": "for name, obj in all_items:", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 21, + "column": 25, "message": "Expression type contains \"Any\" (has type \"list[(str, Any)]\")", "offset": 0, - "src": "for name, obj in items:", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "src": "for name, obj in all_items:", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 25, + "column": 32, "message": "Expression has type \"Any\"", "offset": 1, - "src": "if is_c_function(obj):", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "src": "if inspect.ismodule(obj) and obj.__name__ in self.known_modules:", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 16, + "column": 43, "message": "Expression has type \"Any\"", - "offset": 4, - "src": "obj,", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "offset": 12, + "src": "elif self.is_defined_in_module(obj) and not inspect.ismodule(obj):", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 4, - "message": "Expression type contains \"Any\" (has type \"(str, Any)\")", - "offset": 9, - "src": "for name, obj in items:", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "column": 73, + "message": "Expression has type \"Any\"", + "offset": 0, + "src": "elif self.is_defined_in_module(obj) and not inspect.ismodule(obj):", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 4, - "message": "Expression has type \"Any\"", + "column": 16, + "message": "Expression type contains \"Any\" (has type \"list[(str, Any)]\")", + "offset": 2, + "src": "items.append((name, obj))", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" + }, + { + "code": "no-any-expr", + "column": 29, + "message": "Expression type contains \"Any\" (has type \"(str, Any)\")", "offset": 0, - "src": "for name, obj in items:", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "src": "items.append((name, obj))", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 21, - "message": "Expression type contains \"Any\" (has type \"list[(str, Any)]\")", + "column": 36, + "message": "Expression has type \"Any\"", "offset": 0, - "src": "for name, obj in items:", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "src": "items.append((name, obj))", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 21, + "column": 54, "message": "Expression has type \"Any\"", "offset": 3, - "src": "if is_c_type(obj):", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "src": "obj_module_name = self.get_obj_module(obj)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 16, + "column": 35, + "message": "Expression type contains \"Any\" (has type \"(str, Any)\")", + "offset": 6, + "src": "self.set_defined_names(set([name for name, obj in all_items if not inspect.ismodule(obj)]))", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" + }, + { + "code": "no-any-expr", + "column": 35, "message": "Expression has type \"Any\"", - "offset": 4, - "src": "obj,", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "offset": 0, + "src": "self.set_defined_names(set([name for name, obj in all_items if not inspect.ismodule(obj)]))", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 4, + "column": 58, + "message": "Expression type contains \"Any\" (has type \"list[(str, Any)]\")", + "offset": 0, + "src": "self.set_defined_names(set([name for name, obj in all_items if not inspect.ismodule(obj)]))", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" + }, + { + "code": "no-any-expr", + "column": 92, + "message": "Expression has type \"Any\"", + "offset": 0, + "src": "self.set_defined_names(set([name for name, obj in all_items if not inspect.ismodule(obj)]))", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" + }, + { + "code": "no-any-expr", + "column": 8, "message": "Expression type contains \"Any\" (has type \"(str, Any)\")", - "offset": 9, + "offset": 10, "src": "for name, obj in items:", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 4, + "column": 8, "message": "Expression has type \"Any\"", "offset": 0, "src": "for name, obj in items:", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 21, + "column": 25, "message": "Expression type contains \"Any\" (has type \"list[(str, Any)]\")", "offset": 0, "src": "for name, obj in items:", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 53, + "column": 32, "message": "Expression has type \"Any\"", - "offset": 3, - "src": "if name not in done and not inspect.ismodule(obj):", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "offset": 1, + "src": "if self.is_function(obj):", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 34, + "column": 50, + "message": "Expression has type \"Any\"", + "offset": 1, + "src": "self.generate_function_stub(name, obj, output=functions)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" + }, + { + "code": "no-any-expr", + "column": 33, + "message": "Expression has type \"Any\"", + "offset": 1, + "src": "elif inspect.isclass(obj):", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" + }, + { + "code": "no-any-expr", + "column": 47, "message": "Expression type contains \"Any\" (has type \"type[Any]\")", - "offset": 2, - "src": "get_type_fullname(type(obj)), module, known_modules, imports", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "offset": 1, + "src": "self.generate_class_stub(name, obj, output=types)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" }, { "code": "no-any-expr", - "column": 39, + "column": 50, "message": "Expression has type \"Any\"", - "offset": 0, - "src": "get_type_fullname(type(obj)), module, known_modules, imports", - "target": "mypy.stubgenc.generate_stub_for_c_module" + "offset": 2, + "src": "self.generate_variable_stub(name, obj, output=variables)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_module" + }, + { + "code": "possibly-undefined", + "column": 37, + "message": "Name \"output\" may be undefined", + "offset": 16, + "src": "for i, line in enumerate(output):", + "target": "mypy.stubgenc" }, { "code": "no-any-explicit", - "column": 0, + "column": 4, "message": "Explicit \"Any\" is not allowed", - "offset": 32, - "src": "def get_members(obj: object) -> list[tuple[str, Any]]:", - "target": "mypy.stubgenc.get_members" + "offset": 36, + "src": "def get_members(self, obj: object) -> list[tuple[str, Any]]:", + "target": "mypy.stubgenc.InspectionStubGenerator.get_members" }, { "code": "no-any-explicit", - "column": 4, + "column": 8, "message": "Explicit \"Any\" is not allowed", "offset": 1, "src": "obj_dict: Mapping[str, Any] = getattr(obj, \"__dict__\") # noqa: B009", - "target": "mypy.stubgenc.get_members" + "target": "mypy.stubgenc.InspectionStubGenerator.get_members" }, { "code": "no-any-expr", - "column": 16, + "column": 20, "message": "Expression type contains \"Any\" (has type \"Mapping[str, Any]\")", "offset": 2, "src": "for name in obj_dict:", - "target": "mypy.stubgenc.get_members" + "target": "mypy.stubgenc.InspectionStubGenerator.get_members" }, { "code": "no-any-expr", - "column": 20, + "column": 24, "message": "Expression has type \"Any\"", "offset": 5, "src": "value = getattr(obj, name)", - "target": "mypy.stubgenc.get_members" + "target": "mypy.stubgenc.InspectionStubGenerator.get_members" }, { "code": "no-any-expr", - "column": 12, + "column": 16, "message": "Expression type contains \"Any\" (has type \"list[(str, Any)]\")", "offset": 4, "src": "results.append((name, value))", - "target": "mypy.stubgenc.get_members" + "target": "mypy.stubgenc.InspectionStubGenerator.get_members" }, { "code": "no-any-expr", - "column": 27, + "column": 31, "message": "Expression type contains \"Any\" (has type \"(str, Any)\")", "offset": 0, "src": "results.append((name, value))", - "target": "mypy.stubgenc.get_members" + "target": "mypy.stubgenc.InspectionStubGenerator.get_members" }, { "code": "no-any-expr", - "column": 34, + "column": 38, "message": "Expression has type \"Any\"", "offset": 0, "src": "results.append((name, value))", - "target": "mypy.stubgenc.get_members" + "target": "mypy.stubgenc.InspectionStubGenerator.get_members" }, { "code": "no-any-expr", - "column": 11, + "column": 15, "message": "Expression type contains \"Any\" (has type \"list[(str, Any)]\")", "offset": 1, "src": "return results", - "target": "mypy.stubgenc.get_members" + "target": "mypy.stubgenc.InspectionStubGenerator.get_members" + }, + { + "code": "no-any-expr", + "column": 60, + "message": "Expression type contains \"Any\" (has type \"type[Any]\")", + "offset": 10, + "src": "return \"type[{}]\".format(self.get_type_fullname(obj))", + "target": "mypy.stubgenc.InspectionStubGenerator.get_type_annotation" + }, + { + "code": "no-any-expr", + "column": 16, + "message": "Expression has type \"Any\"", + "offset": 39, + "src": "inspect.getattr_static(class_info.cls, name), staticmethod", + "target": "mypy.stubgenc.InspectionStubGenerator.is_staticmethod" + }, + { + "code": "no-any-expr", + "column": 15, + "message": "Expression type contains \"Any\" (has type \"Any | bool\")", + "offset": 5, + "src": "return getattr(obj, \"__abstractmethod__\", False)", + "target": "mypy.stubgenc.InspectionStubGenerator.is_abstract_method" }, { "code": "no-any-explicit", - "column": 0, + "column": 4, "message": "Explicit \"Any\" is not allowed", - "offset": 26, - "src": "def is_c_property_readonly(prop: Any) -> bool:", - "target": "mypy.stubgenc.is_c_property_readonly" + "offset": 7, + "src": "def is_property_readonly(prop: Any) -> bool:", + "target": "mypy.stubgenc.InspectionStubGenerator.is_property_readonly" + }, + { + "code": "no-any-decorated", + "column": 4, + "message": "Type of decorated function contains type \"Any\" (\"(prop: Any) -> bool\")", + "offset": 0, + "src": "def is_property_readonly(prop: Any) -> bool:", + "target": "mypy.stubgenc" + }, + { + "code": "no-any-decorated", + "column": 4, + "message": "See https://kotlinisland.github.io/basedmypy/_refs.html#code-no-any-decorated for more info", + "offset": 0, + "src": "def is_property_readonly(prop: Any) -> bool:", + "target": null }, { "code": "no-any-expr", - "column": 19, + "column": 23, "message": "Expression has type \"Any\"", "offset": 1, "src": "return hasattr(prop, \"fset\") and prop.fset is None", - "target": "mypy.stubgenc.is_c_property_readonly" + "target": "mypy.stubgenc.InspectionStubGenerator.is_property_readonly" }, { "code": "no-any-expr", - "column": 37, + "column": 41, "message": "Expression has type \"Any\"", "offset": 0, "src": "return hasattr(prop, \"fset\") and prop.fset is None", - "target": "mypy.stubgenc.is_c_property_readonly" + "target": "mypy.stubgenc.InspectionStubGenerator.is_property_readonly" }, { - "code": "redundant-expr", - "column": 15, - "message": "Condition is always false", - "offset": 90, - "src": "if include_docstrings and docstr:", - "target": "mypy.stubgenc.generate_c_function_stub" + "code": "no-any-explicit", + "column": 8, + "message": "Explicit \"Any\" is not allowed", + "offset": 28, + "src": "docstring: Any = getattr(obj, \"__doc__\", None)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_function_stub" }, { - "code": "unreachable", - "column": 16, - "message": "Statement is unreachable", + "code": "no-any-expr", + "column": 25, + "message": "Expression type contains \"Any\" (has type \"Any | None\")", + "offset": 0, + "src": "docstring: Any = getattr(obj, \"__doc__\", None)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_function_stub" + }, + { + "code": "no-any-expr", + "column": 26, + "message": "Expression has type \"Any\"", "offset": 1, - "src": "docstr_quoted = mypy.util.quote_docstring(docstr.strip())", - "target": "mypy.stubgenc.generate_c_function_stub" + "src": "if not isinstance(docstring, str):", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_function_stub" }, { - "code": "unreachable", - "column": 16, - "message": "See https://kotlinisland.github.io/basedmypy/_refs.html#code-unreachable for more info", - "offset": 0, - "src": "docstr_quoted = mypy.util.quote_docstring(docstr.strip())", - "target": null + "code": "no-any-expr", + "column": 22, + "message": "Expression has type \"Any\"", + "offset": 6, + "src": "docstring=docstring,", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_function_stub" }, { - "code": "truthy-bool", - "column": 7, - "message": "\"module\" has type Module which does not implement __bool__ or __len__ so it could always be true in boolean context", - "offset": 24, - "src": "if module:", - "target": "mypy.stubgenc.strip_or_import" + "code": "no-any-expr", + "column": 86, + "message": "Expression has type \"Any\"", + "offset": 30, + "src": "output.extend(self.format_func_def(inferred, decorators=decorators, docstring=docstring))", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_function_stub" }, { - "code": "truthy-bool", - "column": 7, - "message": "See https://kotlinisland.github.io/basedmypy/_refs.html#code-truthy-bool for more info", - "offset": 0, - "src": "if module:", - "target": null + "code": "no-any-expr", + "column": 34, + "message": "Expression type contains \"Any\" (has type \"MappingProxyType[str, Any]\")", + "offset": 13, + "src": "and \"__iter__\" not in ctx.class_info.cls.__dict__", + "target": "mypy.stubgenc.InspectionStubGenerator._fix_iter" }, { - "code": "possibly-undefined", - "column": 11, - "message": "Name \"arg_module\" may be undefined", - "offset": 22, - "src": "if arg_module not in local_modules:", - "target": "mypy.stubgenc" + "code": "no-any-expr", + "column": 20, + "message": "Expression type contains \"Any\" (has type \"Any | None\")", + "offset": 32, + "src": "docstring = getattr(raw_obj, \"__doc__\", None)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_property_stub" }, { - "code": "possibly-undefined", + "code": "no-any-expr", + "column": 15, + "message": "Expression type contains \"Any\" (has type \"Any | None\")", + "offset": 1, + "src": "fget = getattr(raw_obj, \"fget\", None)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_property_stub" + }, + { + "code": "no-any-expr", "column": 11, - "message": "See https://kotlinisland.github.io/basedmypy/_refs.html#code-possibly-undefined for more info", - "offset": 0, - "src": "if arg_module not in local_modules:", - "target": null + "message": "Expression type contains \"Any\" (has type \"Any | None\")", + "offset": 1, + "src": "if fget:", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_property_stub" }, { "code": "no-any-expr", - "column": 31, + "column": 25, "message": "Expression type contains \"Any\" (has type \"Any | None\")", - "offset": 39, - "src": "inferred = infer_prop_type(getattr(obj, \"__doc__\", None))", - "target": "mypy.stubgenc.generate_c_property_stub" + "offset": 1, + "src": "alt_docstr = getattr(fget, \"__doc__\", None)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_property_stub" + }, + { + "code": "no-any-expr", + "column": 33, + "message": "Expression has type \"Any\"", + "offset": 0, + "src": "alt_docstr = getattr(fget, \"__doc__\", None)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_property_stub" }, { "code": "no-any-expr", "column": 15, "message": "Expression type contains \"Any\" (has type \"Any | None\")", - "offset": 2, - "src": "fget = getattr(obj, \"fget\", None)", - "target": "mypy.stubgenc.generate_c_property_stub" + "offset": 1, + "src": "if alt_docstr and docstring:", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_property_stub" }, { "code": "no-any-expr", - "column": 35, + "column": 30, "message": "Expression type contains \"Any\" (has type \"Any | None\")", + "offset": 0, + "src": "if alt_docstr and docstring:", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_property_stub" + }, + { + "code": "no-any-expr", + "column": 16, + "message": "Expression has type \"Any\"", "offset": 1, - "src": "inferred = infer_prop_type(getattr(fget, \"__doc__\", None))", - "target": "mypy.stubgenc.generate_c_property_stub" + "src": "docstring += alt_docstr", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_property_stub" }, { "code": "no-any-expr", - "column": 43, - "message": "Expression type contains \"Any\" (has type \"Any | None\")", + "column": 29, + "message": "Expression has type \"Any\"", "offset": 0, - "src": "inferred = infer_prop_type(getattr(fget, \"__doc__\", None))", - "target": "mypy.stubgenc.generate_c_property_stub" + "src": "docstring += alt_docstr", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_property_stub" }, { "code": "no-any-expr", "column": 17, + "message": "Expression type contains \"Any\" (has type \"Any | None\")", + "offset": 1, + "src": "elif alt_docstr:", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_property_stub" + }, + { + "code": "no-any-expr", + "column": 28, "message": "Expression has type \"Any\"", - "offset": 33, - "src": "raw_lookup = getattr(obj, \"__dict__\") # noqa: B009", - "target": "mypy.stubgenc.generate_c_type_stub" + "offset": 1, + "src": "docstring = alt_docstr", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_property_stub" }, { "code": "no-any-expr", - "column": 12, + "column": 46, + "message": "Expression type contains \"Any\" (has type \"Any | None\")", + "offset": 3, + "src": "self.module_name, name, docstring=docstring, is_abstract=False, class_info=class_info", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_property_stub" + }, + { + "code": "no-any-expr", + "column": 19, + "message": "Expression type contains \"Any\" (has type \"Any | str\")", + "offset": 44, + "src": "typename = getattr(typ, \"__qualname__\", typ.__name__)", + "target": "mypy.stubgenc.InspectionStubGenerator.get_type_fullname" + }, + { + "code": "no-any-expr", + "column": 23, + "message": "Expression type contains \"Any\" (has type \"Any | str\")", + "offset": 4, + "src": "typename = f\"{module_name}.{typename}\"", + "target": "mypy.stubgenc.InspectionStubGenerator.get_type_fullname" + }, + { + "code": "no-any-expr", + "column": 15, + "message": "Expression type contains \"Any\" (has type \"Any | str\")", + "offset": 1, + "src": "return typename", + "target": "mypy.stubgenc.InspectionStubGenerator.get_type_fullname" + }, + { + "code": "no-any-expr", + "column": 21, + "message": "Expression has type \"Any\"", + "offset": 26, + "src": "raw_lookup = getattr(cls, \"__dict__\") # noqa: B009", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" + }, + { + "code": "no-any-expr", + "column": 16, "message": "Expression type contains \"Any\" (has type \"list[(str, Any)]\")", "offset": 1, - "src": "items = sorted(get_members(obj), key=lambda x: method_name_sort_key(x[0]))", - "target": "mypy.stubgenc.generate_c_type_stub" + "src": "items = self.get_members(cls)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 19, + "column": 27, "message": "Expression type contains \"Any\" (has type \"list[(str, Any)]\")", - "offset": 0, - "src": "items = sorted(get_members(obj), key=lambda x: method_name_sort_key(x[0]))", - "target": "mypy.stubgenc.generate_c_type_stub" + "offset": 2, + "src": "items = sorted(items, key=lambda x: method_name_sort_key(x[0]))", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 41, + "column": 38, "message": "Expression type contains \"Any\" (has type \"(x: (str, Any)) -> (int, str)\")", "offset": 0, - "src": "items = sorted(get_members(obj), key=lambda x: method_name_sort_key(x[0]))", - "target": "mypy.stubgenc.generate_c_type_stub" + "src": "items = sorted(items, key=lambda x: method_name_sort_key(x[0]))", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 72, + "column": 69, "message": "Expression type contains \"Any\" (has type \"(str, Any)\")", "offset": 0, - "src": "items = sorted(get_members(obj), key=lambda x: method_name_sort_key(x[0]))", - "target": "mypy.stubgenc.generate_c_type_stub" + "src": "items = sorted(items, key=lambda x: method_name_sort_key(x[0]))", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 12, + "column": 19, "message": "Expression type contains \"Any\" (has type \"(str, Any)\")", "offset": 1, - "src": "names = {x[0] for x in items}", - "target": "mypy.stubgenc.generate_c_type_stub" + "src": "names = set(x[0] for x in items)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 13, + "column": 20, "message": "Expression type contains \"Any\" (has type \"(str, Any)\")", "offset": 0, - "src": "names = {x[0] for x in items}", - "target": "mypy.stubgenc.generate_c_type_stub" + "src": "names = set(x[0] for x in items)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 27, + "column": 34, "message": "Expression type contains \"Any\" (has type \"list[(str, Any)]\")", "offset": 0, - "src": "names = {x[0] for x in items}", - "target": "mypy.stubgenc.generate_c_type_stub" + "src": "names = set(x[0] for x in items)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-explicit", - "column": 4, + "column": 8, "message": "Explicit \"Any\" is not allowed", "offset": 6, "src": "attrs: list[tuple[str, Any]] = []", - "target": "mypy.stubgenc.generate_c_type_stub" + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 4, + "column": 47, + "message": "Expression type contains \"Any\" (has type \"Any | None\")", + "offset": 5, + "src": "class_info = ClassInfo(class_name, \"\", getattr(cls, \"__doc__\", None), cls)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" + }, + { + "code": "no-any-expr", + "column": 8, "message": "Expression type contains \"Any\" (has type \"(str, Any)\")", - "offset": 1, + "offset": 2, "src": "for attr, value in items:", - "target": "mypy.stubgenc.generate_c_type_stub" + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 4, + "column": 8, "message": "Expression has type \"Any\"", "offset": 0, "src": "for attr, value in items:", - "target": "mypy.stubgenc.generate_c_type_stub" + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 23, + "column": 27, "message": "Expression type contains \"Any\" (has type \"list[(str, Any)]\")", "offset": 0, "src": "for attr, value in items:", - "target": "mypy.stubgenc.generate_c_type_stub" + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 20, + "column": 24, "message": "Expression has type \"Any\"", "offset": 2, "src": "raw_value = raw_lookup.get(attr, value)", - "target": "mypy.stubgenc.generate_c_type_stub" + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 41, + "column": 45, "message": "Expression has type \"Any\"", "offset": 0, "src": "raw_value = raw_lookup.get(attr, value)", - "target": "mypy.stubgenc.generate_c_type_stub" + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 23, + "column": 48, "message": "Expression has type \"Any\"", "offset": 1, - "src": "if is_c_method(value) or is_c_classmethod(value):", - "target": "mypy.stubgenc.generate_c_type_stub" + "src": "if self.is_method(class_info, attr, value) or self.is_classmethod(", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 50, + "column": 34, "message": "Expression has type \"Any\"", - "offset": 0, - "src": "if is_c_method(value) or is_c_classmethod(value):", - "target": "mypy.stubgenc.generate_c_type_stub" + "offset": 1, + "src": "class_info, attr, value", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 32, + "column": 57, "message": "Expression has type \"Any\"", - "offset": 9, - "src": "if is_c_classmethod(value):", - "target": "mypy.stubgenc.generate_c_type_stub" + "offset": 11, + "src": "if self.is_classmethod(class_info, attr, value):", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 16, + "column": 50, "message": "Expression has type \"Any\"", - "offset": 7, - "src": "value,", - "target": "mypy.stubgenc.generate_c_type_stub" + "offset": 4, + "src": "self.generate_function_stub(attr, value, output=methods, class_info=class_info)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 27, + "column": 52, "message": "Expression has type \"Any\"", - "offset": 10, - "src": "elif is_c_property(raw_value):", - "target": "mypy.stubgenc.generate_c_type_stub" + "offset": 1, + "src": "elif self.is_property(class_info, attr, raw_value):", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 16, + "column": 20, "message": "Expression has type \"Any\"", "offset": 3, "src": "raw_value,", - "target": "mypy.stubgenc.generate_c_type_stub" + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 39, + "column": 20, "message": "Expression has type \"Any\"", - "offset": 4, - "src": "is_c_property_readonly(raw_value),", - "target": "mypy.stubgenc.generate_c_type_stub" + "offset": 1, + "src": "value,", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 23, + "column": 33, "message": "Expression has type \"Any\"", - "offset": 5, - "src": "elif is_c_type(value):", - "target": "mypy.stubgenc.generate_c_type_stub" + "offset": 6, + "src": "elif inspect.isclass(value) and self.is_defined_in_module(value):", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 16, - "message": "Expression has type \"Any\"", - "offset": 4, - "src": "value,", - "target": "mypy.stubgenc.generate_c_type_stub" + "column": 70, + "message": "Expression type contains \"Any\" (has type \"type[Any]\")", + "offset": 0, + "src": "elif inspect.isclass(value) and self.is_defined_in_module(value):", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 12, + "column": 47, + "message": "Expression type contains \"Any\" (has type \"type[Any]\")", + "offset": 1, + "src": "self.generate_class_stub(attr, value, types)", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" + }, + { + "code": "no-any-expr", + "column": 16, "message": "Expression type contains \"Any\" (has type \"list[(str, Any)]\")", - "offset": 8, + "offset": 2, "src": "attrs.append((attr, value))", - "target": "mypy.stubgenc.generate_c_type_stub" + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 25, + "column": 29, "message": "Expression type contains \"Any\" (has type \"(str, Any)\")", "offset": 0, "src": "attrs.append((attr, value))", - "target": "mypy.stubgenc.generate_c_type_stub" + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 32, + "column": 36, "message": "Expression has type \"Any\"", "offset": 0, "src": "attrs.append((attr, value))", - "target": "mypy.stubgenc.generate_c_type_stub" + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 4, + "column": 8, "message": "Expression type contains \"Any\" (has type \"(str, Any)\")", "offset": 2, "src": "for attr, value in attrs:", - "target": "mypy.stubgenc.generate_c_type_stub" + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 4, + "column": 8, "message": "Expression has type \"Any\"", "offset": 0, "src": "for attr, value in attrs:", - "target": "mypy.stubgenc.generate_c_type_stub" + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 23, + "column": 27, "message": "Expression type contains \"Any\" (has type \"list[(str, Any)]\")", "offset": 0, "src": "for attr, value in attrs:", - "target": "mypy.stubgenc.generate_c_type_stub" + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 50, - "message": "Expression type contains \"Any\" (has type \"type[Any]\")", - "offset": 4, - "src": "strip_or_import(get_type_fullname(type(value)), module, known_modules, imports),", - "target": "mypy.stubgenc.generate_c_type_stub" + "column": 38, + "message": "Expression has type \"Any\"", + "offset": 1, + "src": "if attr == \"__hash__\" and value is None:", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" }, { "code": "no-any-expr", - "column": 55, + "column": 75, "message": "Expression has type \"Any\"", - "offset": 0, - "src": "strip_or_import(get_type_fullname(type(value)), module, known_modules, imports),", - "target": "mypy.stubgenc.generate_c_type_stub" - }, - { - "code": "helpful-string", - "column": 30, - "message": "The string for \"object\" isn't helpful in a user-facing or semantic string", - "offset": 49, - "src": "return f\"{typ.__module__}.{getattr(typ, '__qualname__', typ.__name__)}\"", - "target": "mypy.stubgenc.get_type_fullname" + "offset": 3, + "src": "prop_type_name = self.strip_or_import(self.get_type_annotation(value))", + "target": "mypy.stubgenc.InspectionStubGenerator.generate_class_stub" } ], "mypy/stubtest.py": [ @@ -23449,7 +23973,7 @@ }, { "code": "helpful-string", - "column": 68, + "column": 16, "message": "The type \"\" doesn't define a __format__, __str__ or __repr__ method", "offset": 4, "src": "f\"encountered unexpected error, {type(e).__name__}: {e}\",", @@ -23688,17 +24212,17 @@ "target": "mypy.stubtest._verify_metaclass" }, { - "code": "helpful-string", + "code": "no-any-expr", "column": 29, - "message": "The type \"type[type[Any]]\" doesn't define a __format__, __str__ or __repr__ method", + "message": "Expression type contains \"Any\" (has type \"type[type[Any]]\")", "offset": 2, "src": "runtime_desc=f\"{runtime_metaclass}\",", "target": "mypy.stubtest._verify_metaclass" }, { - "code": "no-any-expr", - "column": 31, - "message": "Expression type contains \"Any\" (has type \"type[type[Any]]\")", + "code": "helpful-string", + "column": 29, + "message": "The type \"type[type[Any]]\" doesn't define a __format__, __str__ or __repr__ method", "offset": 0, "src": "runtime_desc=f\"{runtime_metaclass}\",", "target": "mypy.stubtest._verify_metaclass" @@ -24073,17 +24597,17 @@ }, { "code": "no-any-expr", - "column": 49, + "column": 24, "message": "Expression has type \"Any\"", - "offset": 5, - "src": "f\"has a default value of {runtime_arg.default!r}, \"", + "offset": 4, + "src": "f'runtime argument \"{runtime_arg.name}\" '", "target": "mypy.stubtest._verify_arg_default_value" }, { "code": "explicit-override", "column": 4, "message": "Method \"__str__\" is not using @override but is overriding a method in class \"builtins.object\"", - "offset": 27, + "offset": 28, "src": "def __str__(self) -> str:", "target": "mypy.stubtest.Signature.__str__" }, @@ -24203,7 +24727,7 @@ "code": "no-any-expr", "column": 65, "message": "Expression type contains \"Any\" (has type \"set[Any]\")", - "offset": 195, + "offset": 198, "src": "if runtime.varkw is None or not set(runtime.kwonly).issubset(set(stub.kwonly)):", "target": "mypy.stubtest._verify_signature" }, @@ -24545,7 +25069,7 @@ }, { "code": "helpful-string", - "column": 66, + "column": 29, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 6, "src": "object_path, f\"variable differs from runtime type {runtime_type}\", stub, runtime", @@ -25499,11 +26023,59 @@ "mypy/stubutil.py": [ { "code": "helpful-string", - "column": 45, + "column": 10, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 121, + "offset": 129, "src": "print(f\"{mod}: Failed to import, skipping{message}\")", "target": "mypy.stubutil.report_missing" + }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"visit_any\" is not using @override but is overriding a method in class \"mypy.types.TypeStrVisitor\"", + "offset": 93, + "src": "def visit_any(self, t: AnyType) -> str:", + "target": "mypy.stubutil.AnnotationPrinter.visit_any" + }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"visit_unbound_type\" is not using @override but is overriding a method in class \"mypy.types.TypeStrVisitor\"", + "offset": 5, + "src": "def visit_unbound_type(self, t: UnboundType) -> str:", + "target": "mypy.stubutil.AnnotationPrinter.visit_unbound_type" + }, + { + "code": "possibly-undefined", + "column": 15, + "message": "Name \"arg_module\" may be undefined", + "offset": 13, + "src": "if arg_module not in self.local_modules:", + "target": "mypy.stubutil" + }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"visit_none_type\" is not using @override but is overriding a method in class \"mypy.types.TypeStrVisitor\"", + "offset": 12, + "src": "def visit_none_type(self, t: NoneType) -> str:", + "target": "mypy.stubutil.AnnotationPrinter.visit_none_type" + }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"visit_type_list\" is not using @override but is overriding a method in class \"mypy.types.TypeStrVisitor\"", + "offset": 3, + "src": "def visit_type_list(self, t: TypeList) -> str:", + "target": "mypy.stubutil.AnnotationPrinter.visit_type_list" + }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"visit_union_type\" is not using @override but is overriding a method in class \"mypy.types.TypeStrVisitor\"", + "offset": 3, + "src": "def visit_union_type(self, t: UnionType) -> str:", + "target": "mypy.stubutil.AnnotationPrinter.visit_union_type" } ], "mypy/subtypes.py": [ @@ -25511,7 +26083,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_unbound_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 405, + "offset": 431, "src": "def visit_unbound_type(self, left: UnboundType) -> bool:", "target": "mypy.subtypes.SubtypeVisitor.visit_unbound_type" }, @@ -25567,7 +26139,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_type_var\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 206, + "offset": 176, "src": "def visit_type_var(self, left: TypeVarType) -> bool:", "target": "mypy.subtypes.SubtypeVisitor.visit_type_var" }, @@ -25615,7 +26187,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_tuple_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 63, + "offset": 64, "src": "def visit_tuple_type(self, left: TupleType) -> bool:", "target": "mypy.subtypes.SubtypeVisitor.visit_tuple_type" }, @@ -25623,7 +26195,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_typeddict_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 50, + "offset": 131, "src": "def visit_typeddict_type(self, left: TypedDictType) -> bool:", "target": "mypy.subtypes.SubtypeVisitor.visit_typeddict_type" }, @@ -25647,7 +26219,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_union_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 81, + "offset": 83, "src": "def visit_union_type(self, left: UnionType) -> bool:", "target": "mypy.subtypes.SubtypeVisitor.visit_union_type" }, @@ -25687,7 +26259,7 @@ "code": "no-any-explicit", "column": 4, "message": "Explicit \"Any\" is not allowed", - "offset": 747, + "offset": 780, "src": "def report(*args: Any) -> None:", "target": "mypy.subtypes.unify_generic_callable" }, @@ -25993,7 +26565,7 @@ }, { "code": "possibly-undefined", - "column": 52, + "column": 34, "message": "Name \"severity\" may be undefined", "offset": 87, "src": "output.append(f\"{fnam}:{i + 1}: {severity}: {message}\")", @@ -26001,7 +26573,7 @@ }, { "code": "possibly-undefined", - "column": 58, + "column": 34, "message": "Name \"severity\" may be undefined", "offset": 2, "src": "output.append(f\"{fnam}:{i + 1}:{col}: {severity}: {message}\")", @@ -26245,7 +26817,7 @@ "code": "no-any-expr", "column": 54, "message": "Expression type contains \"Any\" (has type \"set[Any]\")", - "offset": 117, + "offset": 144, "src": "actual_normalized = sorted(set(actual).difference({\"__main__\"}))", "target": "mypy.test.helpers.assert_module_equivalence" }, @@ -26253,7 +26825,7 @@ "code": "no-any-explicit", "column": 0, "message": "Explicit \"Any\" is not allowed", - "offset": 148, + "offset": 136, "src": "def retry_on_error(func: Callable[[], Any], max_wait: float = 1.0) -> None:", "target": "mypy.test.helpers.retry_on_error" }, @@ -26282,6 +26854,24 @@ "target": "mypy.test.helpers.normalize_file_output" } ], + "mypy/test/meta/_pytest.py": [ + { + "code": "possibly-undefined", + "column": 19, + "message": "Name \"proc\" may be undefined", + "offset": 68, + "src": "stdout=proc.stdout.decode(),", + "target": "mypy.test.meta._pytest" + }, + { + "code": "possibly-undefined", + "column": 19, + "message": "See https://kotlinisland.github.io/basedmypy/_refs.html#code-possibly-undefined for more info", + "offset": 0, + "src": "stdout=proc.stdout.decode(),", + "target": null + } + ], "mypy/test/test_find_sources.py": [ { "code": "explicit-override", @@ -26367,7 +26957,7 @@ }, { "code": "no-any-expr", - "column": 23, + "column": 21, "message": "Expression has type \"Any\"", "offset": 1, "src": "a.append(f\"{item['line']}:{item['column']}:{item['target']}\")", @@ -26381,14 +26971,6 @@ "src": "a.append(f\"{item['line']}:{item['column']}:{item['target']}\")", "target": "mypy.test.test_ref_info.RefInfoSuite.run_case" }, - { - "code": "no-any-expr", - "column": 38, - "message": "Expression has type \"Any\"", - "offset": 0, - "src": "a.append(f\"{item['line']}:{item['column']}:{item['target']}\")", - "target": "mypy.test.test_ref_info.RefInfoSuite.run_case" - }, { "code": "no-any-expr", "column": 39, @@ -26397,14 +26979,6 @@ "src": "a.append(f\"{item['line']}:{item['column']}:{item['target']}\")", "target": "mypy.test.test_ref_info.RefInfoSuite.run_case" }, - { - "code": "no-any-expr", - "column": 55, - "message": "Expression has type \"Any\"", - "offset": 0, - "src": "a.append(f\"{item['line']}:{item['column']}:{item['target']}\")", - "target": "mypy.test.test_ref_info.RefInfoSuite.run_case" - }, { "code": "no-any-expr", "column": 56, @@ -26437,7 +27011,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"run_case\" is not using @override but is overriding a method in class \"mypy.test.data.DataSuite\"", - "offset": 60, + "offset": 61, "src": "def run_case(self, testcase: DataDrivenTestCase) -> None:", "target": "mypy.test.testcheck.TypeCheckSuite.run_case" }, @@ -26453,7 +27027,7 @@ "code": "no-any-expr", "column": 11, "message": "Expression type contains \"Any\" (has type \"False | Untyped\")", - "offset": 142, + "offset": 140, "src": "if output != a and testcase.config.getoption(\"--update-data\", False):", "target": "mypy.test.testcheck.TypeCheckSuite.run_case_once" }, @@ -26573,7 +27147,7 @@ }, { "code": "no-any-expr", - "column": 41, + "column": 23, "message": "Expression type contains \"Any\" (has type \"int | Any\")", "offset": 1, "src": "out.append(f\"== Return code: {result}\")", @@ -26667,7 +27241,7 @@ "code": "no-any-expr", "column": 19, "message": "Expression type contains \"Any\" (has type \"dict[str, Any]\")", - "offset": 94, + "offset": 93, "src": "response = server.check(sources, export_types=True, is_tty=False, terminal_width=-1)", "target": "mypy.test.testfinegrained.FineGrainedSuite.run_check" }, @@ -27205,7 +27779,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"run_case\" is not using @override but is overriding a method in class \"mypy.test.data.DataSuite\"", - "offset": 57, + "offset": 56, "src": "def run_case(self, testcase: DataDrivenTestCase) -> None:", "target": "mypy.test.testsemanal.SemAnalSuite.run_case" }, @@ -27257,7 +27831,7 @@ "code": "no-any-expr", "column": 5, "message": "Expression type contains \"Any\" (has type \"[_FT: (...) -> Any] (_FT) -> _FT\")", - "offset": 53, + "offset": 51, "src": "@unittest.skipIf(sys.platform == \"win32\", \"clean up fails on Windows\")", "target": "mypy.test.teststubgen" }, @@ -27265,7 +27839,7 @@ "code": "no-any-expr", "column": 5, "message": "Expression type contains \"Any\" (has type \"[_FT: (...) -> Any] (_FT) -> _FT\")", - "offset": 26, + "offset": 27, "src": "@unittest.skipIf(sys.platform == \"win32\", \"clean up fails on Windows\")", "target": "mypy.test.teststubgen" }, @@ -27273,7 +27847,7 @@ "code": "no-any-expr", "column": 5, "message": "Expression type contains \"Any\" (has type \"[_FT: (...) -> Any] (_FT) -> _FT\")", - "offset": 25, + "offset": 26, "src": "@unittest.skipIf(sys.platform == \"win32\", \"clean up fails on Windows\")", "target": "mypy.test.teststubgen" }, @@ -27345,7 +27919,7 @@ "code": "no-any-expr", "column": 32, "message": "Expression type contains \"Any\" (has type \"(self: Any) -> str\")", - "offset": 541, + "offset": 458, "src": "test.__doc__ = property(lambda self: \"test(arg0: str) -> None\") # type: ignore[assignment]", "target": "mypy.test.teststubgen.StubgencSuite.test_generate_c_function_no_crash_for_non_str_docstring" }, @@ -27357,21 +27931,53 @@ "src": "test.__doc__ = property(lambda self: \"test(arg0: str) -> None\") # type: ignore[assignment]", "target": null }, + { + "code": "no-any-expr", + "column": 12, + "message": "Expression type contains \"Any\" (has type \"MappingProxyType[str, Any]\")", + "offset": 30, + "src": "TestClass.__dict__[\"attribute\"],", + "target": "mypy.test.teststubgen.StubgencSuite.test_generate_c_property_with_pybind11" + }, { "code": "no-any-expr", "column": 12, "message": "Expression has type \"Any\"", - "offset": 32, - "src": "TestClass.attribute,", + "offset": 0, + "src": "TestClass.__dict__[\"attribute\"],", "target": "mypy.test.teststubgen.StubgencSuite.test_generate_c_property_with_pybind11" }, { "code": "no-any-expr", - "column": 35, + "column": 12, "message": "Expression has type \"Any\"", - "offset": 4, - "src": "is_c_property_readonly(TestClass.attribute),", + "offset": 1, + "src": "TestClass.attribute,", "target": "mypy.test.teststubgen.StubgencSuite.test_generate_c_property_with_pybind11" + }, + { + "code": "no-any-expr", + "column": 12, + "message": "Expression type contains \"Any\" (has type \"MappingProxyType[str, Any]\")", + "offset": 29, + "src": "TestClass.__dict__[\"attribute\"],", + "target": "mypy.test.teststubgen.StubgencSuite.test_generate_c_property_with_rw_property" + }, + { + "code": "no-any-expr", + "column": 12, + "message": "Expression has type \"Any\"", + "offset": 0, + "src": "TestClass.__dict__[\"attribute\"],", + "target": "mypy.test.teststubgen.StubgencSuite.test_generate_c_property_with_rw_property" + }, + { + "code": "no-any-expr", + "column": 26, + "message": "Expression type contains \"Any\" (has type \"Any | None\")", + "offset": 173, + "src": "docstring=getattr(TestClass, \"__doc__\", None),", + "target": "mypy.test.teststubgen.StubgencSuite.test_generate_c_type_with_overload_shiboken" } ], "mypy/test/teststubtest.py": [ @@ -28071,7 +28677,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"run_case\" is not using @override but is overriding a method in class \"mypy.test.data.DataSuite\"", - "offset": 29, + "offset": 28, "src": "def run_case(self, testcase: DataDrivenTestCase) -> None:", "target": "mypy.test.testtransform.TransformSuite.run_case" } @@ -28099,7 +28705,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"setUp\" is not using @override but is overriding a method in class \"unittest.case.TestCase\"", - "offset": 60, + "offset": 61, "src": "def setUp(self) -> None:", "target": "mypy.test.testtypes.TypesSuite.setUp" }, @@ -28123,7 +28729,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"setUp\" is not using @override but is overriding a method in class \"unittest.case.TestCase\"", - "offset": 355, + "offset": 403, "src": "def setUp(self) -> None:", "target": "mypy.test.testtypes.MeetSuite.setUp" }, @@ -28131,7 +28737,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"setUp\" is not using @override but is overriding a method in class \"unittest.case.TestCase\"", - "offset": 219, + "offset": 247, "src": "def setUp(self) -> None:", "target": "mypy.test.testtypes.SameTypeSuite.setUp" }, @@ -28179,7 +28785,7 @@ }, { "code": "helpful-string", - "column": 30, + "column": 24, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 43, "src": "file_path = f\"tmp/{test_item.arg}\"", @@ -28225,7 +28831,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_mypy_file\" is not using @override but is overriding a method in class \"mypy.visitor.NodeVisitor\"", - "offset": 112, + "offset": 113, "src": "def visit_mypy_file(self, o: MypyFile) -> None:", "target": "mypy.traverser.TraverserVisitor.visit_mypy_file" }, @@ -30697,7 +31303,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_unbound_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 263, + "offset": 264, "src": "def visit_unbound_type(self, t: UnboundType, defining_literal: bool = False) -> Type:", "target": "mypy.typeanal.TypeAnalyser.visit_unbound_type" }, @@ -30705,7 +31311,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_any\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 677, + "offset": 664, "src": "def visit_any(self, t: AnyType) -> Type:", "target": "mypy.typeanal.TypeAnalyser.visit_any" }, @@ -30809,7 +31415,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_parameters\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 6, + "offset": 9, "src": "def visit_parameters(self, t: Parameters) -> Type:", "target": "mypy.typeanal.TypeAnalyser.visit_parameters" }, @@ -30825,7 +31431,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_overloaded\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 120, + "offset": 138, "src": "def visit_overloaded(self, t: Overloaded) -> Type:", "target": "mypy.typeanal.TypeAnalyser.visit_overloaded" }, @@ -30921,15 +31527,15 @@ "code": "explicit-override", "column": 4, "message": "Method \"analyze_callable_args\" is not using @override but is overriding a method in class \"mypy.plugin.TypeAnalyzerPluginInterface\"", - "offset": 173, + "offset": 171, "src": "def analyze_callable_args(", "target": "mypy.typeanal.TypeAnalyser.analyze_callable_args" }, { "code": "helpful-string", - "column": 62, + "column": 30, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 20, + "offset": 21, "src": "self.fail(f'Invalid argument constructor \"{found.fullname}\"', arg)", "target": "mypy.typeanal.TypeAnalyser.analyze_callable_args" }, @@ -30937,7 +31543,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"analyze_type\" is not using @override but is overriding a method in class \"mypy.plugin.TypeAnalyzerPluginInterface\"", - "offset": 144, + "offset": 149, "src": "def analyze_type(self, t: Type) -> Type:", "target": "mypy.typeanal.TypeAnalyser.analyze_type" }, @@ -30961,7 +31567,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_unbound_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeQuery\"", - "offset": 325, + "offset": 358, "src": "def visit_unbound_type(self, t: UnboundType) -> TypeVarLikeList:", "target": "mypy.typeanal.TypeVarLikeQuery.visit_unbound_type" }, @@ -30983,7 +31589,7 @@ }, { "code": "helpful-string", - "column": 57, + "column": 36, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 1, "src": "assert t.alias is not None, f\"Unfixed type alias {t.type_ref}\"", @@ -31029,19 +31635,11 @@ "src": "def query_types(self, types: Iterable[Type]) -> list[Type]:", "target": "mypy.typeanal.CollectAllInnerTypesQuery.query_types" }, - { - "code": "explicit-override", - "column": 4, - "message": "Method \"visit_instance\" is not using @override but is overriding a method in class \"mypy.typetraverser.TypeTraverserVisitor\"", - "offset": 45, - "src": "def visit_instance(self, typ: Instance) -> None:", - "target": "mypy.typeanal.InstanceFixer.visit_instance" - }, { "code": "explicit-override", "column": 4, "message": "Method \"visit_unbound_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.BoolTypeQuery\"", - "offset": 22, + "offset": 97, "src": "def visit_unbound_type(self, t: UnboundType) -> bool:", "target": "mypy.typeanal.HasSelfType.visit_unbound_type" } @@ -31051,7 +31649,7 @@ "code": "redundant-expr", "column": 19, "message": "Condition is always true", - "offset": 478, + "offset": 481, "src": "if extra_attrs_set is None:", "target": "mypy.typeops.make_simplified_union" }, @@ -31107,7 +31705,7 @@ "code": "no-any-explicit", "column": 4, "message": "Explicit \"Any\" is not allowed", - "offset": 365, + "offset": 364, "src": "sum_types: dict[str, tuple[set[Any], list[int]]] = {}", "target": "mypy.typeops.try_contracting_literals_in_union" }, @@ -31237,7 +31835,7 @@ "code": "no-any-explicit", "column": 0, "message": "Explicit \"Any\" is not allowed", - "offset": 128, + "offset": 125, "src": "_dummy: Final[Any] = object()", "target": "mypy.types" }, @@ -31725,7 +32323,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"serialize\" is not using @override but is overriding a method in class \"mypy.types.TypeVarLikeType\"", - "offset": 33, + "offset": 39, "src": "def serialize(self) -> JsonDict:", "target": "mypy.types.TypeVarTupleType.serialize" }, @@ -31741,7 +32339,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"deserialize\" is not using @override but is overriding a method in class \"mypy.types.TypeVarLikeType\"", - "offset": 11, + "offset": 12, "src": "def deserialize(cls, data: JsonDict) -> TypeVarTupleType:", "target": "mypy.types" }, @@ -31757,7 +32355,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"accept\" is not using @override but is overriding a method in class \"mypy.types.Type\"", - "offset": 10, + "offset": 11, "src": "def accept(self, visitor: TypeVisitor[T]) -> T:", "target": "mypy.types.TypeVarTupleType.accept" }, @@ -31817,6 +32415,14 @@ "src": "default: Bogus[Type] = _dummy,", "target": "mypy.types.TypeVarTupleType.copy_modified" }, + { + "code": "no-any-expr", + "column": 30, + "message": "Expression has type \"Any\"", + "offset": 1, + "src": "min_len: Bogus[int] = _dummy,", + "target": "mypy.types.TypeVarTupleType.copy_modified" + }, { "code": "no-any-expr", "column": 29, @@ -31841,11 +32447,19 @@ "src": "self.default if default is _dummy else default,", "target": "mypy.types.TypeVarTupleType.copy_modified" }, + { + "code": "no-any-expr", + "column": 47, + "message": "Expression has type \"Any\"", + "offset": 3, + "src": "min_len=self.min_len if min_len is _dummy else min_len,", + "target": "mypy.types.TypeVarTupleType.copy_modified" + }, { "code": "no-any-expr", "column": 65, "message": "Expression has type \"Any\"", - "offset": 60, + "offset": 58, "src": "def copy_modified(self, args: Bogus[Sequence[Type] | None] = _dummy) -> UnboundType:", "target": "mypy.types.UnboundType.copy_modified" }, @@ -31997,7 +32611,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"accept\" is not using @override but is overriding a method in class \"mypy.types.Type\"", - "offset": 22, + "offset": 25, "src": "def accept(self, visitor: TypeVisitor[T]) -> T:", "target": "mypy.types.UnpackType.accept" }, @@ -32509,7 +33123,7 @@ "code": "no-any-expr", "column": 43, "message": "Expression has type \"Any\"", - "offset": 98, + "offset": 101, "src": "arg_types: Bogus[Sequence[Type]] = _dummy,", "target": "mypy.types.Parameters.copy_modified" }, @@ -32757,7 +33371,7 @@ "code": "no-any-explicit", "column": 4, "message": "Explicit \"Any\" is not allowed", - "offset": 49, + "offset": 47, "src": "def __init__(", "target": "mypy.types.CallableType.__init__" }, @@ -33165,7 +33779,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"__hash__\" is not using @override but is overriding a method in class \"builtins.object\"", - "offset": 128, + "offset": 118, "src": "def __hash__(self) -> int:", "target": "mypy.types.CallableType.__hash__" }, @@ -33573,7 +34187,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"accept\" is not using @override but is overriding a method in class \"mypy.types.Type\"", - "offset": 17, + "offset": 28, "src": "def accept(self, visitor: TypeVisitor[T]) -> T:", "target": "mypy.types.TupleType.accept" }, @@ -33661,7 +34275,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"accept\" is not using @override but is overriding a method in class \"mypy.types.Type\"", - "offset": 65, + "offset": 109, "src": "def accept(self, visitor: TypeVisitor[T]) -> T:", "target": "mypy.types.TypedDictType.accept" }, @@ -34014,7 +34628,7 @@ "column": 4, "message": "Method \"accept\" is not using @override but is overriding a method in class \"mypy.types.Type\"", "offset": 26, - "src": "def accept(self, visitor: \"TypeVisitor[T]\") -> T:", + "src": "def accept(self, visitor: TypeVisitor[T]) -> T:", "target": "mypy.types.IntersectionType.accept" }, { @@ -34054,7 +34668,7 @@ "column": 4, "message": "Method \"deserialize\" is not using @override but is overriding a method in class \"mypy.types.Type\"", "offset": 3, - "src": "def deserialize(cls, data: JsonDict) -> \"IntersectionType\":", + "src": "def deserialize(cls, data: JsonDict) -> IntersectionType:", "target": "mypy.types" }, { @@ -34195,7 +34809,7 @@ }, { "code": "helpful-string", - "column": 68, + "column": 22, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 3, "src": "assert False, f\"Internal error: unresolved placeholder type {self.fullname}\"", @@ -34227,7 +34841,7 @@ }, { "code": "helpful-string", - "column": 21, + "column": 19, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 3, "src": "return f\"{t.constructor}({typ})\"", @@ -34235,7 +34849,7 @@ }, { "code": "helpful-string", - "column": 21, + "column": 19, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 2, "src": "return f\"{t.constructor}({typ}, {t.name})\"", @@ -34269,7 +34883,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_erased_type\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 5, + "offset": 3, "src": "def visit_erased_type(self, t: ErasedType) -> str:", "target": "mypy.types.TypeStrVisitor.visit_erased_type" }, @@ -34293,7 +34907,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_type_var\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 41, + "offset": 43, "src": "def visit_type_var(self, t: TypeVarType) -> str:", "target": "mypy.types.TypeStrVisitor.visit_type_var" }, @@ -34389,7 +35003,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_overloaded\" is not using @override but is overriding a method in class \"mypy.type_visitor.TypeVisitor\"", - "offset": 95, + "offset": 96, "src": "def visit_overloaded(self, t: Overloaded) -> str:", "target": "mypy.types.TypeStrVisitor.visit_overloaded" }, @@ -34491,7 +35105,7 @@ }, { "code": "helpful-string", - "column": 30, + "column": 15, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 1, "src": "return f\"\"", @@ -34669,7 +35283,7 @@ "mypy/types_utils.py": [ { "code": "helpful-string", - "column": 50, + "column": 29, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 64, "src": "assert target.alias, f\"Unfixed type alias {target.type_ref}\"", @@ -36321,39 +36935,15 @@ "code": "explicit-override", "column": 4, "message": "Method \"__str__\" is not using @override but is overriding a method in class \"builtins.object\"", - "offset": 73, + "offset": 74, "src": "def __str__(self) -> str:", "target": "mypyc.analysis.dataflow.CFG.__str__" }, - { - "code": "no-any-expr", - "column": 35, - "message": "Expression type contains \"Any\" (has type \"list[Any]\")", - "offset": 2, - "src": "lines.append(\"exits: %s\" % sorted(self.exits, key=lambda e: int(e.label)))", - "target": "mypyc.analysis.dataflow.CFG.__str__" - }, - { - "code": "no-any-expr", - "column": 58, - "message": "Expression type contains \"Any\" (has type \"(e: Any) -> int\")", - "offset": 0, - "src": "lines.append(\"exits: %s\" % sorted(self.exits, key=lambda e: int(e.label)))", - "target": "mypyc.analysis.dataflow.CFG.__str__" - }, - { - "code": "no-any-expr", - "column": 72, - "message": "Expression has type \"Any\"", - "offset": 0, - "src": "lines.append(\"exits: %s\" % sorted(self.exits, key=lambda e: int(e.label)))", - "target": "mypyc.analysis.dataflow.CFG.__str__" - }, { "code": "explicit-override", "column": 4, "message": "Method \"__str__\" is not using @override but is overriding a method in class \"builtins.object\"", - "offset": 92, + "offset": 91, "src": "def __str__(self) -> str:", "target": "mypyc.analysis.dataflow.AnalysisResult.__str__" }, @@ -36605,6 +37195,14 @@ "src": "def visit_keep_alive(self, op: KeepAlive) -> GenAndKill[T]:", "target": "mypyc.analysis.dataflow.BaseAnalysisVisitor.visit_keep_alive" }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"visit_unborrow\" is not using @override but is overriding a method in class \"mypyc.ir.ops.OpVisitor\"", + "offset": 3, + "src": "def visit_unborrow(self, op: Unborrow) -> GenAndKill[T]:", + "target": "mypyc.analysis.dataflow.BaseAnalysisVisitor.visit_unborrow" + }, { "code": "explicit-override", "column": 4, @@ -36851,7 +37449,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"__eq__\" is not using @override but is overriding a method in class \"builtins.object\"", - "offset": 76, + "offset": 77, "src": "def __eq__(self, other: object) -> bool:", "target": "mypyc.analysis.ircheck.FnError.__eq__" }, @@ -36865,7 +37463,7 @@ }, { "code": "helpful-string", - "column": 32, + "column": 15, "message": "The type \"mypyc.ir.ops.Op\" doesn't define a __format__, __str__ or __repr__ method", "offset": 1, "src": "return f\"FnError(source={self.source}, desc={self.desc})\"", @@ -36873,7 +37471,7 @@ }, { "code": "helpful-string", - "column": 32, + "column": 15, "message": "The type \"mypyc.ir.ops.BasicBlock\" doesn't define a __format__, __str__ or __repr__ method", "offset": 0, "src": "return f\"FnError(source={self.source}, desc={self.desc})\"", @@ -36937,7 +37535,7 @@ }, { "code": "helpful-string", - "column": 72, + "column": 30, "message": "The type \"type[object]\" doesn't define a __format__, __str__ or __repr__ method", "offset": 9, "src": "self.fail(op, f\"Invalid type for item of tuple literal: {type(x)})\")", @@ -36945,7 +37543,7 @@ }, { "code": "helpful-string", - "column": 76, + "column": 30, "message": "The type \"type[object]\" doesn't define a __format__, __str__ or __repr__ method", "offset": 11, "src": "self.fail(op, f\"Invalid type for item of frozenset literal: {type(x)})\")", @@ -37190,6 +37788,14 @@ "offset": 3, "src": "def visit_keep_alive(self, op: KeepAlive) -> None:", "target": "mypyc.analysis.ircheck.OpChecker.visit_keep_alive" + }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"visit_unborrow\" is not using @override but is overriding a method in class \"mypyc.ir.ops.OpVisitor\"", + "offset": 3, + "src": "def visit_unborrow(self, op: Unborrow) -> None:", + "target": "mypyc.analysis.ircheck.OpChecker.visit_unborrow" } ], "mypyc/analysis/selfleaks.py": [ @@ -37197,7 +37803,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_goto\" is not using @override but is overriding a method in class \"mypyc.ir.ops.OpVisitor\"", - "offset": 66, + "offset": 67, "src": "def visit_goto(self, op: Goto) -> GenAndKill:", "target": "mypyc.analysis.selfleaks.SelfLeakedVisitor.visit_goto" }, @@ -37464,6 +38070,14 @@ "offset": 3, "src": "def visit_keep_alive(self, op: KeepAlive) -> GenAndKill:", "target": "mypyc.analysis.selfleaks.SelfLeakedVisitor.visit_keep_alive" + }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"visit_unborrow\" is not using @override but is overriding a method in class \"mypyc.ir.ops.OpVisitor\"", + "offset": 3, + "src": "def visit_unborrow(self, op: Unborrow) -> GenAndKill:", + "target": "mypyc.analysis.selfleaks.SelfLeakedVisitor.visit_unborrow" } ], "mypyc/build.py": [ @@ -37471,7 +38085,7 @@ "code": "no-any-expr", "column": 78, "message": "Expression has type \"Any\"", - "offset": 111, + "offset": 108, "src": "write_junit_xml(dt, serious, messages, options.junit_xml, py_version, options.platform)", "target": "mypyc.build.emit_messages" }, @@ -37561,7 +38175,7 @@ "mypyc/codegen/emitclass.py": [ { "code": "helpful-string", - "column": 44, + "column": 41, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 253, "src": "fields[f\"tp_{table_name}\"] = f\"&{table_struct_name}\"", @@ -37581,7 +38195,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_goto\" is not using @override but is overriding a method in class \"mypyc.ir.ops.OpVisitor\"", - "offset": 194, + "offset": 195, "src": "def visit_goto(self, op: Goto) -> None:", "target": "mypyc.codegen.emitfunc.FunctionEmitterVisitor.visit_goto" }, @@ -37613,7 +38227,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_assign\" is not using @override but is overriding a method in class \"mypyc.ir.ops.OpVisitor\"", - "offset": 11, + "offset": 10, "src": "def visit_assign(self, op: Assign) -> None:", "target": "mypyc.codegen.emitfunc.FunctionEmitterVisitor.visit_assign" }, @@ -37667,7 +38281,7 @@ }, { "code": "possibly-undefined", - "column": 41, + "column": 39, "message": "Name \"dest\" may be undefined", "offset": 33, "src": "self.emitter.emit_line(f\"{dest} = 1;\")", @@ -37701,7 +38315,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_call\" is not using @override but is overriding a method in class \"mypyc.ir.ops.OpVisitor\"", - "offset": 12, + "offset": 13, "src": "def visit_call(self, op: Call) -> None:", "target": "mypyc.codegen.emitfunc.FunctionEmitterVisitor.visit_call" }, @@ -37888,6 +38502,14 @@ "offset": 12, "src": "def visit_keep_alive(self, op: KeepAlive) -> None:", "target": "mypyc.codegen.emitfunc.FunctionEmitterVisitor.visit_keep_alive" + }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"visit_unborrow\" is not using @override but is overriding a method in class \"mypyc.ir.ops.OpVisitor\"", + "offset": 4, + "src": "def visit_unborrow(self, op: Unborrow) -> None:", + "target": "mypyc.codegen.emitfunc.FunctionEmitterVisitor.visit_unborrow" } ], "mypyc/codegen/emitmodule.py": [ @@ -38091,7 +38713,7 @@ "mypyc/crash.py": [ { "code": "helpful-string", - "column": 56, + "column": 10, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", "offset": 30, "src": "print(f\"{module_path}:{line}: {type(err).__name__}: {err}\")", @@ -39035,7 +39657,7 @@ }, { "code": "helpful-string", - "column": 50, + "column": 29, "message": "The type \"mypyc.ir.ops.ControlOp\" doesn't define a __format__, __str__ or __repr__ method", "offset": 13, "src": "raise AssertionError(f\"Invalid set_target({self}, {i})\")", @@ -39345,6 +39967,14 @@ "src": "def sources(self) -> list[Value]:", "target": "mypyc.ir.ops.TupleSet.sources" }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"stolen\" is not using @override but is overriding a method in class \"mypyc.ir.ops.Op\"", + "offset": 3, + "src": "def stolen(self) -> list[Value]:", + "target": "mypyc.ir.ops.TupleSet.stolen" + }, { "code": "explicit-override", "column": 4, @@ -39357,7 +39987,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"sources\" is not using @override but is overriding a method in class \"mypyc.ir.ops.Op\"", - "offset": 17, + "offset": 18, "src": "def sources(self) -> list[Value]:", "target": "mypyc.ir.ops.TupleGet.sources" }, @@ -39693,17 +40323,49 @@ "code": "explicit-override", "column": 4, "message": "Method \"sources\" is not using @override but is overriding a method in class \"mypyc.ir.ops.Op\"", - "offset": 28, + "offset": 36, "src": "def sources(self) -> list[Value]:", "target": "mypyc.ir.ops.KeepAlive.sources" }, { "code": "explicit-override", "column": 4, - "message": "Method \"accept\" is not using @override but is overriding a method in class \"mypyc.ir.ops.Op\"", + "message": "Method \"stolen\" is not using @override but is overriding a method in class \"mypyc.ir.ops.Op\"", "offset": 3, + "src": "def stolen(self) -> list[Value]:", + "target": "mypyc.ir.ops.KeepAlive.stolen" + }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"accept\" is not using @override but is overriding a method in class \"mypyc.ir.ops.Op\"", + "offset": 5, "src": "def accept(self, visitor: OpVisitor[T]) -> T:", "target": "mypyc.ir.ops.KeepAlive.accept" + }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"sources\" is not using @override but is overriding a method in class \"mypyc.ir.ops.Op\"", + "offset": 36, + "src": "def sources(self) -> list[Value]:", + "target": "mypyc.ir.ops.Unborrow.sources" + }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"stolen\" is not using @override but is overriding a method in class \"mypyc.ir.ops.Op\"", + "offset": 3, + "src": "def stolen(self) -> list[Value]:", + "target": "mypyc.ir.ops.Unborrow.stolen" + }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"accept\" is not using @override but is overriding a method in class \"mypyc.ir.ops.Op\"", + "offset": 3, + "src": "def accept(self, visitor: OpVisitor[T]) -> T:", + "target": "mypyc.ir.ops.Unborrow.accept" } ], "mypyc/ir/pprint.py": [ @@ -39711,7 +40373,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_goto\" is not using @override but is overriding a method in class \"mypyc.ir.ops.OpVisitor\"", - "offset": 72, + "offset": 73, "src": "def visit_goto(self, op: Goto) -> str:", "target": "mypyc.ir.pprint.IRPrettyPrintVisitor.visit_goto" }, @@ -40003,6 +40665,14 @@ "src": "def visit_keep_alive(self, op: KeepAlive) -> str:", "target": "mypyc.ir.pprint.IRPrettyPrintVisitor.visit_keep_alive" }, + { + "code": "explicit-override", + "column": 4, + "message": "Method \"visit_unborrow\" is not using @override but is overriding a method in class \"mypyc.ir.ops.OpVisitor\"", + "offset": 9, + "src": "def visit_unborrow(self, op: Unborrow) -> str:", + "target": "mypyc.ir.pprint.IRPrettyPrintVisitor.visit_unborrow" + }, { "code": "no-any-explicit", "column": 4, @@ -40571,15 +41241,15 @@ "code": "no-any-expr", "column": 13, "message": "Expression has type \"Any\"", - "offset": 244, + "offset": 248, "src": "with self.catch_errors(node.line):", "target": "mypyc.irbuild.builder.IRBuilder.accept" }, { "code": "helpful-string", - "column": 46, + "column": 22, "message": "The string for \"None\" isn't helpful in a user-facing or semantic string", - "offset": 292, + "offset": 297, "src": "error_msg=f'value for final name \"{error_name}\" was not set',", "target": "mypyc.irbuild.builder.IRBuilder.load_final_static" }, @@ -40635,7 +41305,7 @@ "code": "no-any-explicit", "column": 4, "message": "Explicit \"Any\" is not allowed", - "offset": 301, + "offset": 309, "src": "def catch_errors(self, line: int) -> Any:", "target": "mypyc.irbuild.builder.IRBuilder.catch_errors" } @@ -40749,7 +41419,7 @@ "mypyc/irbuild/env_class.py": [ { "code": "helpful-string", - "column": 46, + "column": 44, "message": "The type \"mypyc.ir.ops.Value\" doesn't define a __format__, __str__ or __repr__ method", "offset": 129, "src": "assert isinstance(env.type, RInstance), f\"{env} must be of type RInstance\"", @@ -41045,7 +41715,7 @@ "code": "possibly-undefined", "column": 33, "message": "Name \"func_ir\" may be undefined", - "offset": 339, + "offset": 348, "src": "builder.functions.append(func_ir)", "target": "mypyc.irbuild.function" }, @@ -41063,7 +41733,7 @@ "code": "redundant-expr", "column": 13, "message": "Condition is always true", - "offset": 486, + "offset": 489, "src": "elif is_uint8_rprimitive(target_type):", "target": "mypyc.irbuild.ll_builder.LowLevelIRBuilder.coerce_int_to_fixed_width" }, @@ -41603,7 +42273,7 @@ "code": "possibly-undefined", "column": 7, "message": "Name \"next_block\" may be undefined", - "offset": 481, + "offset": 509, "src": "if next_block:", "target": "mypyc.irbuild.statement" } @@ -41751,7 +42421,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_assignment_stmt\" is not using @override but is overriding a method in class \"mypy.visitor.StatementVisitor\"", - "offset": 3, + "offset": 4, "src": "def visit_assignment_stmt(self, stmt: AssignmentStmt) -> None:", "target": "mypyc.irbuild.visitor.IRBuilderVisitor.visit_assignment_stmt" }, @@ -41799,7 +42469,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_continue_stmt\" is not using @override but is overriding a method in class \"mypy.visitor.StatementVisitor\"", - "offset": 3, + "offset": 4, "src": "def visit_continue_stmt(self, stmt: ContinueStmt) -> None:", "target": "mypyc.irbuild.visitor.IRBuilderVisitor.visit_continue_stmt" }, @@ -41807,7 +42477,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_raise_stmt\" is not using @override but is overriding a method in class \"mypy.visitor.StatementVisitor\"", - "offset": 3, + "offset": 4, "src": "def visit_raise_stmt(self, stmt: RaiseStmt) -> None:", "target": "mypyc.irbuild.visitor.IRBuilderVisitor.visit_raise_stmt" }, @@ -41815,7 +42485,7 @@ "code": "explicit-override", "column": 4, "message": "Method \"visit_try_stmt\" is not using @override but is overriding a method in class \"mypy.visitor.StatementVisitor\"", - "offset": 3, + "offset": 4, "src": "def visit_try_stmt(self, stmt: TryStmt) -> None:", "target": "mypyc.irbuild.visitor.IRBuilderVisitor.visit_try_stmt" }, @@ -42527,7 +43197,7 @@ "code": "no-any-expr", "column": 5, "message": "Expression type contains \"Any\" (has type \"[_FT: (...) -> Any] (_FT) -> _FT\")", - "offset": 16, + "offset": 17, "src": "@unittest.skipIf(sys.platform.startswith(\"win\"), \"rt tests don't work on windows\")", "target": "mypyc.test.test_external" } @@ -42959,7 +43629,7 @@ }, { "code": "no-any-expr", - "column": 51, + "column": 32, "message": "Expression type contains \"Any\" (has type \"tuple[Any, ...]\")", "offset": 0, "src": "assert type(x) is type(y), (f\"Type mismatch at {trail}\", type(x), type(y))", @@ -43023,7 +43693,7 @@ }, { "code": "no-any-expr", - "column": 60, + "column": 41, "message": "Expression type contains \"Any\" (has type \"tuple[Any, ...]\")", "offset": 0, "src": "assert x.fullname == y.fullname, f\"Name mismatch at {trail}\"", @@ -43047,7 +43717,7 @@ }, { "code": "no-any-expr", - "column": 66, + "column": 47, "message": "Expression type contains \"Any\" (has type \"tuple[Any, ...]\")", "offset": 0, "src": "assert len(x.keys()) == len(y.keys()), f\"Keys mismatch at {trail}\"", @@ -43143,7 +43813,7 @@ }, { "code": "no-any-expr", - "column": 56, + "column": 37, "message": "Expression type contains \"Any\" (has type \"tuple[Any, ...]\")", "offset": 0, "src": "assert x.keys() == y.keys(), f\"Keys mismatch at {trail}\"", @@ -43240,7 +43910,7 @@ { "code": "no-any-expr", "column": 20, - "message": "Expression type contains \"Any\" (has type \"Any | str | set[Any]\")", + "message": "Expression has type \"Any\"", "offset": 1, "src": "elif isinstance(x, RType):", "target": "mypyc.test.test_serialization.assert_blobs_same" @@ -43255,7 +43925,7 @@ }, { "code": "no-any-expr", - "column": 55, + "column": 35, "message": "Expression type contains \"Any\" (has type \"tuple[Any, ...]\")", "offset": 0, "src": "assert is_same_type(x, y), f\"RType mismatch at {trail}\"", @@ -43264,7 +43934,7 @@ { "code": "no-any-expr", "column": 20, - "message": "Expression type contains \"Any\" (has type \"Any | str | set[Any]\")", + "message": "Expression has type \"Any\"", "offset": 1, "src": "elif isinstance(x, FuncSignature):", "target": "mypyc.test.test_serialization.assert_blobs_same" @@ -43279,25 +43949,17 @@ }, { "code": "no-any-expr", - "column": 64, + "column": 40, "message": "Expression type contains \"Any\" (has type \"tuple[Any, ...]\")", "offset": 0, "src": "assert is_same_signature(x, y), f\"Signature mismatch at {trail}\"", "target": "mypyc.test.test_serialization.assert_blobs_same" }, - { - "code": "no-any-expr", - "column": 15, - "message": "Expression type contains \"Any\" (has type \"Any | str | set[Any]\")", - "offset": 2, - "src": "assert x == y, f\"Value mismatch at {trail}\"", - "target": "mypyc.test.test_serialization.assert_blobs_same" - }, { "code": "no-any-expr", "column": 15, "message": "Expression has type \"Any\"", - "offset": 0, + "offset": 2, "src": "assert x == y, f\"Value mismatch at {trail}\"", "target": "mypyc.test.test_serialization.assert_blobs_same" }, @@ -43311,7 +43973,7 @@ }, { "code": "no-any-expr", - "column": 43, + "column": 23, "message": "Expression type contains \"Any\" (has type \"tuple[Any, ...]\")", "offset": 0, "src": "assert x == y, f\"Value mismatch at {trail}\"", diff --git a/mypy/binder.py b/mypy/binder.py index ef435fe90..1048f8c2a 100644 --- a/mypy/binder.py +++ b/mypy/binder.py @@ -2,7 +2,7 @@ from collections import defaultdict from contextlib import contextmanager -from typing import DefaultDict, Iterator, List, Optional, Tuple, Union, cast +from typing import DefaultDict, Iterator, List, Optional, Tuple, Union, cast, Iterable, Container from typing_extensions import TypeAlias as _TypeAlias from mypy.erasetype import remove_instance_last_known_values @@ -121,6 +121,18 @@ def __init__(self) -> None: self.try_frames: set[int] = set() self.break_frames: list[int] = [] self.continue_frames: list[int] = [] + self.artificial_values: set[Key] + self._collect_artificial_keys = False + + @contextmanager + def collect_artificial_keys(self): + collect_artificial_keys = self._collect_artificial_keys + self._collect_artificial_keys = True + self.artificial_values = set() + try: + yield + finally: + self._collect_artificial_keys = collect_artificial_keys def _get_id(self) -> int: self.next_id += 1 @@ -142,6 +154,8 @@ def push_frame(self, conditional_frame: bool = False) -> Frame: return f def _put(self, key: Key, type: Type, index: int = -1) -> None: + if self._collect_artificial_keys: + self.artificial_values.add(key) self.frames[index].types[key] = type def _get(self, key: Key, index: int = -1) -> Type | None: @@ -203,7 +217,8 @@ def update_from_options(self, frames: list[Frame]) -> bool: options are the same. """ - frames = [f for f in frames if f.unreachable == 0] + artificial = any([f.unreachable == 2 for f in frames]) + frames = [f for f in frames if not f.unreachable] changed = False keys = {key for f in frames for key in f.types} @@ -246,7 +261,10 @@ def update_from_options(self, frames: list[Frame]) -> bool: if simplified == self.declarations[key]: type = simplified if current_value is None or not is_same_type(type, current_value): - self._put(key, type) + if not (artificial and key in self.artificial_values): + # if any frames were artificially unreachable, + # we don't want to narrow any types + self._put(key, type) changed = True self.frames[-1].unreachable = not frames @@ -396,7 +414,7 @@ def allow_jump(self, index: int) -> None: for f in self.frames[index + 1 :]: frame.types.update(f.types) if f.unreachable: - frame.unreachable = True + frame.unreachable = f.unreachable self.options_on_return[index].append(frame) def handle_break(self) -> None: diff --git a/mypy/checker.py b/mypy/checker.py index 6b25f3483..ffbe84e00 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -7414,8 +7414,9 @@ def push_type_map(self, type_map: TypeMap) -> None: if type_map is None: self.binder.unreachable() else: - for expr, type in type_map.items(): - self.binder.put(expr, type) + with self.binder.collect_artificial_keys(): + for expr, type in type_map.items(): + self.binder.put(expr, type) def infer_issubclass_maps(self, node: CallExpr, expr: Expression) -> tuple[TypeMap, TypeMap]: """Infer type restrictions for an expression in issubclass call.""" diff --git a/mypy/constraints.py b/mypy/constraints.py index 8968962eb..46106c451 100644 --- a/mypy/constraints.py +++ b/mypy/constraints.py @@ -349,9 +349,15 @@ def _infer_constraints( # T :> U2", but they are not equivalent to the constraint solver, # which never introduces new Union types (it uses join() instead). if isinstance(template, TypeVarType): - return _infer_constraints(template.upper_bound, actual, direction, skip_neg_op) + [ - Constraint(template, direction, actual) - ] + if not isinstance(get_proper_type(template.upper_bound), CallableType): + generic_bound = _infer_constraints( + template.upper_bound, actual, direction, skip_neg_op + ) + else: + # HACK: Disregard CallableType because `(*Any, **Any) -> object` + # will produce unwanted constraints + generic_bound = [] + return generic_bound + [Constraint(template, direction, actual)] if ( isinstance(actual, TypeVarType) @@ -360,7 +366,7 @@ def _infer_constraints( ): # Unless template is also a type variable (or a union that contains one), using the upper # bound for inference will usually give better result for actual that is a type variable. - if not isinstance(template, UnionType) or not any( + if not isinstance(template, (UnionType, IntersectionType)) or not any( isinstance(t, TypeVarType) for t in template.items ): actual = get_proper_type(actual.upper_bound) diff --git a/mypy/dmypy_server.py b/mypy/dmypy_server.py index 73bb33161..347d610a0 100644 --- a/mypy/dmypy_server.py +++ b/mypy/dmypy_server.py @@ -225,6 +225,7 @@ def serve(self) -> None: data = receive(server) sys.stdout = WriteToConn(server, "stdout") # type: ignore[assignment] sys.stderr = WriteToConn(server, "stderr") # type: ignore[assignment] + self.options.color_output = False # needed so that initialize_unix_colors doesn't try to get the `fileno` of the WriteToConn resp: dict[str, Any] = {} if "command" not in data: resp = {"error": "No command found in request"} diff --git a/mypy/errors.py b/mypy/errors.py index 7a6f97bdc..c023aadee 100644 --- a/mypy/errors.py +++ b/mypy/errors.py @@ -242,20 +242,20 @@ def filtered_errors(self) -> list[ErrorInfo]: class StoredBaselineError(TypedDict): """Structure of an error while stored in a baseline file""" - code: Optional[str] + code: str | None column: int message: str offset: int - target: Optional[str] + target: str | None src: str class BaselineError(TypedDict): - code: Optional[str] + code: str | None column: int line: int message: str - target: Optional[str] + target: str | None src: str diff --git a/mypy/messages.py b/mypy/messages.py index cd67e3772..0871792ae 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -1371,7 +1371,7 @@ def return_type_incompatible_with_supertype( ): self.note(f'Consider declaring "{name}" in {target} without "async"', context) self.note( - "See https://mypy.readthedocs.io/en/stable/more_types.html#asynchronous-iterators", + "See https://kotlinisland.github.io/basedmypy/more_types.html#asynchronous-iterators", context, ) @@ -2470,7 +2470,9 @@ def quote_type_string(type_string: str) -> str: """Quotes a type representation for use in messages.""" no_quote_regex = r"^<(tuple|union): \d+ items>$" if ( - type_string in ["Module", "overloaded function", "Never", ""] + # erm, "Never" should "Never" be unquoted! + type_string in ["Module", "overloaded function", ""] + # type_string in ["Module", "overloaded function", "Never", ""] or type_string.startswith("Module ") or re.match(no_quote_regex, type_string) is not None or type_string.endswith("?") diff --git a/mypy/stubdoc.py b/mypy/stubdoc.py index c277573f0..02a2fd30b 100644 --- a/mypy/stubdoc.py +++ b/mypy/stubdoc.py @@ -127,7 +127,7 @@ def format_sig( args.append(arg_def) retfield = "" - ret_type = self.ret_type if self.ret_type else any_val + ret_type = self.ret_type or any_val if ret_type is not None: retfield = " -> " + ret_type diff --git a/mypy/stubgen.py b/mypy/stubgen.py index c8c1b2501..6eb837778 100755 --- a/mypy/stubgen.py +++ b/mypy/stubgen.py @@ -422,7 +422,7 @@ def __init__( include_docstrings: bool = False, legacy: bool = False, ) -> None: - super().__init__(_all_, include_private, export_less, include_docstrings) + super().__init__(_all_, include_private, export_less, include_docstrings, legacy=legacy) self._decorators: list[str] = [] # Stack of defined variables (per scope). self._vars: list[list[str]] = [[]] @@ -431,8 +431,6 @@ def __init__( self._current_class: ClassDef | None = None # Was the tree semantically analysed before? self.analyzed = analyzed - # Don't use based features? - self.legacy = legacy # Short names of methods defined in the body of the current class self.method_names: set[str] = set() self.processing_dataclass = False @@ -539,10 +537,10 @@ def _get_func_return(self, o: FuncDef, ctx: FunctionContext) -> str | None: if o.abstract_status == IS_ABSTRACT or o.name in METHODS_WITH_RETURN_VALUE: # Always assume abstract methods return Any unless explicitly annotated. Also # some dunder methods should not have a None return type. - return None # implicit Any + return None if self.legacy else self.add_name("_typeshed.Incomplete") # implicit Any retname = infer_method_ret_type(o.name) if not self.legacy and retname == "None": - retname = "" + return None if retname is not None: return retname if has_yield_expression(o) or has_yield_from_expression(o): @@ -561,9 +559,12 @@ def _get_func_return(self, o: FuncDef, ctx: FunctionContext) -> str | None: if has_return_statement(o): return_name = self.add_name("_typeshed.Incomplete") return f"{generator_name}[{yield_name}, {send_name}, {return_name}]" + if o.is_property: + return None + if not has_return_statement(o) and o.abstract_status == NOT_ABSTRACT: - return "None" - return None + return "None" if self.legacy else None + return None if self.legacy else self.add_name("_typeshed.Incomplete") def _get_func_docstring(self, node: FuncDef) -> str | None: if not node.body.body: diff --git a/mypy/stubgenc.py b/mypy/stubgenc.py index 0ad79a426..801c0a80a 100755 --- a/mypy/stubgenc.py +++ b/mypy/stubgenc.py @@ -226,6 +226,7 @@ def __init__( export_less: bool = False, include_docstrings: bool = False, module: ModuleType | None = None, + legacy=False, ) -> None: self.doc_dir = doc_dir if module is None: @@ -235,7 +236,7 @@ def __init__( self.is_c_module = is_c_module(self.module) self.known_modules = known_modules self.resort_members = self.is_c_module - super().__init__(_all_, include_private, export_less, include_docstrings) + super().__init__(_all_, include_private, export_less, include_docstrings, legacy=legacy) self.module_name = module_name def get_default_function_sig(self, func: object, ctx: FunctionContext) -> FunctionSig: @@ -686,7 +687,8 @@ def generate_property_stub( def get_type_fullname(self, typ: type) -> str: """Given a type, return a string representation""" - if typ is Any: + # typ is a TypeForm, not a type + if typ is Any: # type: ignore[comparison-overlap, unused-ignore] return "Any" typename = getattr(typ, "__qualname__", typ.__name__) module_name = self.get_obj_module(typ) diff --git a/mypy/stubutil.py b/mypy/stubutil.py index cc3b63098..4174a48b2 100644 --- a/mypy/stubutil.py +++ b/mypy/stubutil.py @@ -558,7 +558,10 @@ def __init__( include_private: bool = False, export_less: bool = False, include_docstrings: bool = False, + legacy=False, ): + self.legacy = legacy + # Best known value of __all__. self._all_ = _all_ self._include_private = include_private @@ -594,6 +597,9 @@ def add_name(self, fullname: str, require: bool = True) -> str: The import will be internal to the stub (i.e don't reexport). """ + + if fullname == "_typeshed.Incomplete" and not self.legacy: + fullname = "basedtyping.Untyped" module, name = fullname.rsplit(".", 1) alias = "_" + name if name in self.defined_names else None self.import_tracker.add_import_from(module, [(name, alias)], require=require) diff --git a/mypy/subtypes.py b/mypy/subtypes.py index 52e80ea58..53169bc28 100644 --- a/mypy/subtypes.py +++ b/mypy/subtypes.py @@ -1635,7 +1635,12 @@ def are_parameters_compatible( # (*Any) a supertype of all callables with positional arguments. This is needed in # particular because we often refuse to try type inference if actual type is not # a subtype of erased template type. - if all(k.is_positional() for k in left.arg_kinds) and ignore_pos_arg_names: + # HACK: working around upstream issues: + # https://github.com/python/mypy/issues/16567 + # https://github.com/python/mypy/issues/16568 + # https://github.com/python/mypy/issues/16569 + # if all(k.is_positional() for k in left.arg_kinds) and ignore_pos_arg_names: + if all(k.is_positional() for k in left.arg_kinds): return True # Match up corresponding arguments and check them for compatibility. In diff --git a/mypy/test/teststubgen.py b/mypy/test/teststubgen.py index 20f3be980..08d3bd0f9 100644 --- a/mypy/test/teststubgen.py +++ b/mypy/test/teststubgen.py @@ -825,7 +825,9 @@ def test_infer_cast_sig(self) -> None: def test_generate_class_stub_no_crash_for_object(self) -> None: output: list[str] = [] mod = ModuleType("module", "") # any module is fine - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_class_stub("alias", object, output) assert_equal(gen.get_imports().splitlines(), []) @@ -838,7 +840,9 @@ class TestClassVariableCls: output: list[str] = [] mod = ModuleType("module", "") # any module is fine - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_class_stub("C", TestClassVariableCls, output) assert_equal(gen.get_imports().splitlines(), ["from typing import ClassVar"]) assert_equal(output, ["class C:", " x: ClassVar[int] = ..."]) @@ -849,7 +853,9 @@ class TestClass(KeyError): output: list[str] = [] mod = ModuleType("module, ") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_class_stub("C", TestClass, output) assert_equal(output, ["class C(KeyError): ..."]) assert_equal(gen.get_imports().splitlines(), []) @@ -857,7 +863,9 @@ class TestClass(KeyError): def test_generate_c_type_inheritance_same_module(self) -> None: output: list[str] = [] mod = ModuleType(TestBaseClass.__module__, "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_class_stub("C", TestClass, output) assert_equal(output, ["class C(TestBaseClass): ..."]) assert_equal(gen.get_imports().splitlines(), []) @@ -870,7 +878,9 @@ class TestClass(argparse.Action): output: list[str] = [] mod = ModuleType("module", "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_class_stub("C", TestClass, output) assert_equal(output, ["class C(argparse.Action): ..."]) assert_equal(gen.get_imports().splitlines(), ["import argparse"]) @@ -881,7 +891,9 @@ class TestClass(type): output: list[str] = [] mod = ModuleType("module", "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_class_stub("C", TestClass, output) assert_equal(output, ["class C(type): ..."]) assert_equal(gen.get_imports().splitlines(), []) @@ -895,7 +907,9 @@ def test(self, arg0: str) -> None: output: list[str] = [] mod = ModuleType(TestClass.__module__, "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub( "test", TestClass.test, @@ -914,7 +928,9 @@ def test(self, arg0: str) -> None: output: list[str] = [] mod = ModuleType(TestClass.__module__, "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub( "test", TestClass.test, @@ -932,7 +948,9 @@ def test(cls, arg0: str) -> None: output: list[str] = [] mod = ModuleType(TestClass.__module__, "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub( "test", TestClass.test, @@ -954,7 +972,9 @@ def test(self, arg0: str) -> None: output: list[str] = [] mod = ModuleType(TestClass.__module__, "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub( "test", TestClass.test, @@ -983,7 +1003,9 @@ def test(self, arg0: str = "") -> None: output: list[str] = [] mod = ModuleType(TestClass.__module__, "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub( "test", TestClass.test, @@ -1005,7 +1027,9 @@ def test(arg0: str) -> None: output: list[str] = [] mod = ModuleType(self.__module__, "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub("test", test, output=output) assert_equal(output, ["def test(arg0: argparse.Action) -> Any: ..."]) assert_equal(gen.get_imports().splitlines(), ["import argparse"]) @@ -1024,7 +1048,9 @@ def test(arg0: str) -> None: output: list[str] = [] mod = ModuleType("argparse", "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub("test", test, output=output) assert_equal(output, ["def test(arg0: Action) -> Action: ..."]) assert_equal(gen.get_imports().splitlines(), []) @@ -1039,7 +1065,9 @@ def test(arg0: str) -> None: output: list[str] = [] mod = ModuleType(self.__module__, "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub("test", test, output=output) assert_equal(output, ["def test(arg0: argparse.Action) -> argparse.Action: ..."]) assert_equal(gen.get_imports().splitlines(), ["import argparse"]) @@ -1058,7 +1086,9 @@ def test(arg0: str) -> None: output: list[str] = [] mod = ModuleType("argparse", "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub("test", test, output=output) assert_equal(output, ["def test(arg0: list[Action]) -> list[Action]: ..."]) assert_equal(gen.get_imports().splitlines(), []) @@ -1077,7 +1107,9 @@ def test(arg0: str) -> None: output: list[str] = [] mod = ModuleType("argparse", "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub("test", test, output=output) assert_equal(output, ["def test(arg0: Union[Action, None]) -> Tuple[Action, None]: ..."]) assert_equal(gen.get_imports().splitlines(), []) @@ -1094,7 +1126,7 @@ def test(arg0: str) -> None: output: list[str] = [] mod = ModuleType(self.__module__, "") gen = InspectionStubGenerator( - mod.__name__, known_modules=["foo", "foo.spangle", "bar"], module=mod + mod.__name__, known_modules=["foo", "foo.spangle", "bar"], module=mod, legacy=True ) gen.generate_function_stub("test", test, output=output) assert_equal(output, ["def test(arg0: foo.bar.Action) -> other.Thing: ..."]) @@ -1108,7 +1140,9 @@ def test(arg0: str) -> None: output: list[str] = [] mod = ModuleType(self.__module__, "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub("test", test, output=output) assert_equal(output, ["def test(*args, **kwargs): ..."]) assert_equal(gen.get_imports().splitlines(), []) @@ -1127,7 +1161,9 @@ def get_attribute(self) -> None: readwrite_properties: list[str] = [] readonly_properties: list[str] = [] mod = ModuleType("module", "") # any module is fine - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_property_stub( "attribute", TestClass.__dict__["attribute"], @@ -1155,7 +1191,9 @@ def attribute(self, value: int) -> None: readwrite_properties: list[str] = [] readonly_properties: list[str] = [] mod = ModuleType("module", "") # any module is fine - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_property_stub( "attribute", TestClass.__dict__["attribute"], @@ -1176,7 +1214,9 @@ def test(self, arg0: str) -> None: output: list[str] = [] mod = ModuleType(TestClass.__module__, "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub( "test", TestClass.test, @@ -1195,7 +1235,9 @@ def test(self, arg0: str) -> None: output: list[str] = [] mod = ModuleType(TestClass.__module__, "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub( "test", TestClass.test, @@ -1214,7 +1256,9 @@ def test(self, arg0: str) -> None: output: list[str] = [] mod = ModuleType(TestClass.__module__, "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub( "test", TestClass.test, @@ -1233,7 +1277,9 @@ def test(self, arg0: str) -> None: output: list[str] = [] mod = ModuleType(TestClass.__module__, "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub( "test", TestClass.test, @@ -1252,7 +1298,9 @@ def test(self, arg0: str) -> None: output: list[str] = [] mod = ModuleType(TestClass.__module__, "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub( "test", TestClass.test, @@ -1276,7 +1324,9 @@ def __init__(self, arg0: str) -> None: output: list[str] = [] mod = ModuleType(TestClass.__module__, "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub( "__init__", TestClass.__init__, @@ -1308,7 +1358,9 @@ def __init__(self, arg0: str) -> None: output: list[str] = [] mod = ModuleType(TestClass.__module__, "") - gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) + gen = InspectionStubGenerator( + mod.__name__, known_modules=[mod.__name__], module=mod, legacy=True + ) gen.generate_function_stub( "__init__", TestClass.__init__, diff --git a/mypy_self_check.ini b/mypy_self_check.ini index 2c27d0242..98b9853f6 100644 --- a/mypy_self_check.ini +++ b/mypy_self_check.ini @@ -18,7 +18,7 @@ allow_any_decorated = True no_warn_unreachable = True implicit_reexport = True disallow_redefinition = True -disable_error_code = truthy-bool, no-untyped-usage, possibly-undefined, explicit-override, redundant-expr +disable_error_code = truthy-bool, truthy-iterable, no-untyped-usage, possibly-undefined, explicit-override, redundant-expr work_not_properly_function_names = True [mypy-_pytest.*,pytest.*] diff --git a/mypy_self_check_strict.ini b/mypy_self_check_strict.ini index 42c12a2ee..b709545e9 100644 --- a/mypy_self_check_strict.ini +++ b/mypy_self_check_strict.ini @@ -16,7 +16,7 @@ warn_unused_configs = True show_traceback = True pretty = True always_false = MYPYC -plugins = misc/proper_plugin.py +plugins = mypy.plugins.proper_plugin python_version = 3.8 exclude = mypy/typeshed/|mypyc/test-data/|mypyc/lib-rt/ disallow_redefinition = True diff --git a/test-data/unit/check-async-await.test b/test-data/unit/check-async-await.test index f0fa20664..95231d75d 100644 --- a/test-data/unit/check-async-await.test +++ b/test-data/unit/check-async-await.test @@ -1059,7 +1059,7 @@ class P(Protocol): class Launcher(P): def launch(self) -> AsyncIterator[int]: # E: Return type "AsyncIterator[int]" of "launch" incompatible with return type "Coroutine[Any, Any, AsyncIterator[int]]" in supertype "P" \ # N: Consider declaring "launch" in supertype "P" without "async" \ - # N: See https://mypy.readthedocs.io/en/stable/more_types.html#asynchronous-iterators + # N: See https://kotlinisland.github.io/basedmypy/more_types.html#asynchronous-iterators raise BaseException [builtins fixtures/async_await.pyi] diff --git a/test-data/unit/check-based-misc.test b/test-data/unit/check-based-misc.test index c2dffc466..74e94d615 100644 --- a/test-data/unit/check-based-misc.test +++ b/test-data/unit/check-based-misc.test @@ -163,14 +163,14 @@ def deco(t: T) -> T: ... @deco def f1(): ... -a = f1() # E: "f1" does not return a value [func-returns-value] +a = f1() # E: "f1" does not return a value (it only ever returns None) [func-returns-value] def becomes_none(f: object) -> Callable[[], None]: ... @becomes_none def f2() -> object: ... -a = f2() # E: "f2" does not return a value [func-returns-value] +a = f2() # E: "f2" does not return a value (it only ever returns None) [func-returns-value] def becomes_object(f: object) -> Callable[[], object]: ... @becomes_object @@ -179,14 +179,27 @@ def f3(): ... a = f3() -[case testDoubleTYPE_CHECKING] +[case testDoubleAlwaysTrue] # testing that it doesn't become "True" after a condition -from typing import TYPE_CHECKING +# mypy: always-true=a +a = False -if TYPE_CHECKING: - a = 1 -if TYPE_CHECKING: - a = 1 +if a: + b = 1 +if a: + b = 1 + + +[case testAlwaysTrueDoesntNarrow] +# testing that it doesn't become "True" after a condition +# but that narrowings in the body do +# mypy: always-true=a +a = False + +b: object +if a: + b = 1 +reveal_type(b) # N: Revealed type is "int" (narrowed from "object") [case testRedundantExprOnWhileTrue] diff --git a/test-data/unit/check-bound.test b/test-data/unit/check-bound.test index 2a7acd8d4..47b2f7765 100644 --- a/test-data/unit/check-bound.test +++ b/test-data/unit/check-bound.test @@ -55,7 +55,7 @@ class C(Generic[T]): return self.t c1: C[None] c1.get() -d = c1.get() # E: "get" of "C" does not return a value +d = c1.get() # E: "get" of "C" does not return a value (it only ever returns None) reveal_type(d) # N: Revealed type is "None" @@ -83,7 +83,7 @@ def f(g: Callable[[], T]) -> T: return g() def h() -> None: pass f(h) -a = f(h) # E: "f" does not return a value +a = f(h) # E: "f" does not return a value (it only ever returns None) reveal_type(a) # N: Revealed type is "None" diff --git a/test-data/unit/check-dataclasses.test b/test-data/unit/check-dataclasses.test index d37ae569c..98520d165 100644 --- a/test-data/unit/check-dataclasses.test +++ b/test-data/unit/check-dataclasses.test @@ -2149,8 +2149,8 @@ class B: a_or_b: Union[A[int], B] _ = replace(a_or_b, x=42, y=True, init_var=42) _ = replace(a_or_b, x=42, y=True) # E: Missing named argument "init_var" for "replace" of "Union[A[int], B]" -_ = replace(a_or_b, x=42, y=True, z='42', init_var=42) # E: Argument "z" to "replace" of "Union[A[int], B]" has incompatible type "str"; expected Never -_ = replace(a_or_b, x=42, y=True, w={}, init_var=42) # E: Argument "w" to "replace" of "Union[A[int], B]" has incompatible type "Dict[Never, Never]"; expected Never +_ = replace(a_or_b, x=42, y=True, z='42', init_var=42) # E: Argument "z" to "replace" of "Union[A[int], B]" has incompatible type "str"; expected "Never" +_ = replace(a_or_b, x=42, y=True, w={}, init_var=42) # E: Argument "w" to "replace" of "Union[A[int], B]" has incompatible type "Dict[Never, Never]"; expected "Never" _ = replace(a_or_b, y=42, init_var=42) # E: Argument "y" to "replace" of "Union[A[int], B]" has incompatible type "int"; expected "bool" [builtins fixtures/tuple.pyi] diff --git a/test-data/unit/check-expressions.test b/test-data/unit/check-expressions.test index 1fc55ba7b..1f35e4eff 100644 --- a/test-data/unit/check-expressions.test +++ b/test-data/unit/check-expressions.test @@ -1518,7 +1518,7 @@ x = [] y = "" x.append(y) if bool() else x.append(y) z = x.append(y) if bool() else x.append(y) # E: "append" of "list" does not return a value (it only ever returns None) \ - # E: "append" of "list" does not return a value + # E: "append" of "list" does not return a value (it only ever returns None) [builtins fixtures/list.pyi] -- Special cases diff --git a/test-data/unit/check-functions.test b/test-data/unit/check-functions.test index 483342aad..36e395f38 100644 --- a/test-data/unit/check-functions.test +++ b/test-data/unit/check-functions.test @@ -2576,9 +2576,9 @@ from typing import TypeVar, Optional T = TypeVar('T') def X(val: T) -> T: ... x_in = None -def Y(x: Optional[str] = X(x_in)): ... # E: "X" does not return a value +def Y(x: Optional[str] = X(x_in)): ... # E: "X" does not return a value (it only ever returns None) -xx: Optional[int] = X(x_in) # E: "X" does not return a value +xx: Optional[int] = X(x_in) # E: "X" does not return a value (it only ever returns None) [out] [case testNoComplainInferredNoneStrict] @@ -2586,9 +2586,9 @@ from typing import TypeVar, Optional T = TypeVar('T') def X(val: T) -> T: ... x_in = None -def Y(x: Optional[str] = X(x_in)): ... # E: "X" does not return a value +def Y(x: Optional[str] = X(x_in)): ... # E: "X" does not return a value (it only ever returns None) -xx: Optional[int] = X(x_in) # E: "X" does not return a value +xx: Optional[int] = X(x_in) # E: "X" does not return a value (it only ever returns None) [out] [case testNoComplainNoneReturnFromUntyped] diff --git a/test-data/unit/check-inference-context.test b/test-data/unit/check-inference-context.test index af6186da0..e7b999a2f 100644 --- a/test-data/unit/check-inference-context.test +++ b/test-data/unit/check-inference-context.test @@ -963,7 +963,7 @@ class M(Generic[_KT, _VT]): def get(self, k: _KT, default: _T) -> _T: ... def f(d: M[_KT, _VT], k: _KT) -> _VT: - return d.get(k, None) # E: "get" of "M" does not return a value \ + return d.get(k, None) # E: "get" of "M" does not return a value (it only ever returns None) \ # E: Incompatible return value type (got "None", expected "_VT") [case testGenericMethodCalledInGenericContext2] diff --git a/test-data/unit/check-namedtuple.test b/test-data/unit/check-namedtuple.test index 14e075339..350d16e22 100644 --- a/test-data/unit/check-namedtuple.test +++ b/test-data/unit/check-namedtuple.test @@ -740,7 +740,8 @@ from typing import List, NamedTuple, Union def test() -> None: Exp = Union['A', 'B'] # E: Cannot resolve name "Exp" (possible cyclic definition) \ # N: Recursive types are not allowed at function scope \ - # E: Cannot resolve name "A" (possible cyclic definition) + # E: Cannot resolve name "A" (possible cyclic definition) \ + # N: Recursive types are not allowed at function scope class A(NamedTuple('A', [('attr', List[Exp])])): pass class B(NamedTuple('B', [('val', object)])): pass diff --git a/test-data/unit/check-newsemanal.test b/test-data/unit/check-newsemanal.test index edd27a760..2d1fc2c3d 100644 --- a/test-data/unit/check-newsemanal.test +++ b/test-data/unit/check-newsemanal.test @@ -1513,6 +1513,7 @@ main:5: note: Recursive types are not allowed at function scope main:6: error: Cannot resolve name "B" (possible cyclic definition) main:6: note: Recursive types are not allowed at function scope main:6: error: Cannot resolve name "C" (possible cyclic definition) +main:6: note: Recursive types are not allowed at function scope main:9: note: Revealed type is "Any" main:10: note: Revealed type is "Any" @@ -2138,6 +2139,7 @@ main:6: note: Revealed type is "Any" main:8: error: Cannot resolve name "D" (possible cyclic definition) main:8: note: Recursive types are not allowed at function scope main:8: error: Cannot resolve name "C" (possible cyclic definition) +main:8: note: Recursive types are not allowed at function scope main:9: error: Argument 2 to NewType(...) must be a valid type main:9: error: Cannot resolve name "B" (possible cyclic definition) main:9: note: Recursive types are not allowed at function scope diff --git a/test-data/unit/check-optional.test b/test-data/unit/check-optional.test index 103d3d9f3..8cf6d2334 100644 --- a/test-data/unit/check-optional.test +++ b/test-data/unit/check-optional.test @@ -119,7 +119,7 @@ reveal_type(z2) # N: Revealed type is "Union[builtins.int, builtins.str, None]" [case testLambdaReturningNone] f = lambda: None -x = f() # E: Function does not return a value +x = f() # E: Function does not return a value (it only ever returns None) reveal_type(x) # N: Revealed type is "None" [case testNoneArgumentType] diff --git a/test-data/unit/check-overloading.test b/test-data/unit/check-overloading.test index 241276207..4b61f168b 100644 --- a/test-data/unit/check-overloading.test +++ b/test-data/unit/check-overloading.test @@ -1298,7 +1298,7 @@ def g(x: U, y: V) -> None: # N: Possible overload variants: \ # N: def [T <: str] f(x: T) -> T \ # N: def [T <: str] f(x: List[T]) -> None - a = f([x]) # E: "f" does not return a value + a = f([x]) # E: "f" does not return a value (it only ever returns None) reveal_type(a) # N: Revealed type is "None" f([y]) # E: Value of type variable "T" of "f" cannot be "V" f([x, y]) # E: Value of type variable "T" of "f" cannot be "object" diff --git a/test-data/unit/check-plugin-attrs.test b/test-data/unit/check-plugin-attrs.test index fb5f1f947..3f751cb71 100644 --- a/test-data/unit/check-plugin-attrs.test +++ b/test-data/unit/check-plugin-attrs.test @@ -2144,8 +2144,8 @@ class B: a_or_b: A[int] | B a2 = attrs.evolve(a_or_b, x=42, y=True) -a2 = attrs.evolve(a_or_b, x=42, y=True, z='42') # E: Argument "z" to "evolve" of "Union[A[int], B]" has incompatible type "str"; expected Never -a2 = attrs.evolve(a_or_b, x=42, y=True, w={}) # E: Argument "w" to "evolve" of "Union[A[int], B]" has incompatible type "Dict[Never, Never]"; expected Never +a2 = attrs.evolve(a_or_b, x=42, y=True, z='42') # E: Argument "z" to "evolve" of "Union[A[int], B]" has incompatible type "str"; expected "Never" +a2 = attrs.evolve(a_or_b, x=42, y=True, w={}) # E: Argument "w" to "evolve" of "Union[A[int], B]" has incompatible type "Dict[Never, Never]"; expected "Never" [builtins fixtures/plugin_attrs.pyi] diff --git a/test-data/unit/check-protocols.test b/test-data/unit/check-protocols.test index 991d334a9..8f209e11a 100644 --- a/test-data/unit/check-protocols.test +++ b/test-data/unit/check-protocols.test @@ -1454,7 +1454,7 @@ class P2(Protocol): T = TypeVar('T') def f(x: Callable[[T, T], None]) -> T: pass def g(x: P, y: P2) -> None: pass -x = f(g) # E: "f" does not return a value +x = f(g) # E: "f" does not return a value (it only ever returns None) reveal_type(x) # N: Revealed type is "None" [case testMeetProtocolWithNormal] diff --git a/test-data/unit/check-python312.test b/test-data/unit/check-python312.test index cb89eb348..68c68dd3f 100644 --- a/test-data/unit/check-python312.test +++ b/test-data/unit/check-python312.test @@ -8,7 +8,9 @@ type MyList[T] = list[T] # E: PEP 695 type aliases are not yet supported \ # E: Name "T" is not defined def g(x: MyList[int]) -> MyList[int]: # E: Variable "__main__.MyList" is not valid as a type \ - # N: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases + # N: See https://kotlinisland.github.io/basedmypy/common_issues.html#variables-vs-type-aliases \ + # E: Variable "__main__.MyList" is not valid as a type \ + # N: See https://kotlinisland.github.io/basedmypy/common_issues.html#variables-vs-type-aliases return reveal_type(x) # N: Revealed type is "MyList?[builtins.int]" [case test695Class] @@ -21,12 +23,14 @@ def f(x: MyGen[int]): # E: "MyGen" expects no type arguments, but 1 given [case test695Function] def f[T](x: T) -> T: # E: PEP 695 generics are not yet supported \ + # E: Name "T" is not defined \ # E: Name "T" is not defined return reveal_type(x) # N: Revealed type is "Any" reveal_type(f(1)) # N: Revealed type is "Any" async def g[T](x: T) -> T: # E: PEP 695 generics are not yet supported \ + # E: Name "T" is not defined \ # E: Name "T" is not defined return reveal_type(x) # N: Revealed type is "Any" @@ -50,8 +54,12 @@ class Cls3[*Ts]: ... # E: PEP 695 generics are not yet supported def func1[T: int](x: T) -> T: ... # E: PEP 695 generics are not yet supported def func2[**P](x: Callable[P, int]) -> Callable[P, str]: ... # E: PEP 695 generics are not yet supported \ # E: The first argument to Callable must be a list of types, parameter specification, or "..." \ - # N: See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas \ + # N: See https://kotlinisland.github.io/basedmypy/kinds_of_types.html#callable-types-and-lambdas \ + # E: Name "P" is not defined \ + # E: The first argument to Callable must be a list of types, parameter specification, or "..." \ + # N: See https://kotlinisland.github.io/basedmypy/kinds_of_types.html#callable-types-and-lambdas \ # E: Name "P" is not defined def func3[*Ts](x: tuple[*Ts]) -> tuple[int, *Ts]: ... # E: PEP 695 generics are not yet supported \ + # E: Name "Ts" is not defined \ # E: Name "Ts" is not defined [builtins fixtures/tuple.pyi] diff --git a/test-data/unit/check-type-aliases.test b/test-data/unit/check-type-aliases.test index 34222d78d..d14f6d543 100644 --- a/test-data/unit/check-type-aliases.test +++ b/test-data/unit/check-type-aliases.test @@ -201,10 +201,16 @@ from typing import Type, Callable, Union def test() -> None: A = Union[A, int] # E: Cannot resolve name "A" (possible cyclic definition) \ + # N: Recursive types are not allowed at function scope \ + # E: Cannot resolve name "A" (possible cyclic definition) \ # N: Recursive types are not allowed at function scope B = Callable[[B], int] # E: Cannot resolve name "B" (possible cyclic definition) \ + # N: Recursive types are not allowed at function scope \ + # E: Cannot resolve name "B" (possible cyclic definition) \ # N: Recursive types are not allowed at function scope C = Type[C] # E: Cannot resolve name "C" (possible cyclic definition) \ + # N: Recursive types are not allowed at function scope \ + # E: Cannot resolve name "C" (possible cyclic definition) \ # N: Recursive types are not allowed at function scope [case testRecursiveAliasesErrors2] @@ -221,9 +227,11 @@ def test() -> None: main:5: error: Cannot resolve name "A" (possible cyclic definition) main:5: note: Recursive types are not allowed at function scope main:5: error: Cannot resolve name "B" (possible cyclic definition) +main:5: note: Recursive types are not allowed at function scope main:6: error: Cannot resolve name "B" (possible cyclic definition) main:6: note: Recursive types are not allowed at function scope main:6: error: Cannot resolve name "C" (possible cyclic definition) +main:6: note: Recursive types are not allowed at function scope main:7: error: Cannot resolve name "C" (possible cyclic definition) main:7: note: Recursive types are not allowed at function scope main:9: note: Revealed type is "Union[Any, builtins.int]" @@ -256,6 +264,10 @@ def test() -> None: x: JSON # E: Cannot resolve name "JSON" (possible cyclic definition) \ # N: Recursive types are not allowed at function scope JSON = Union[int, str, List[JSON], Dict[str, JSON]] # E: Cannot resolve name "JSON" (possible cyclic definition) \ + # N: Recursive types are not allowed at function scope \ + # E: Cannot resolve name "JSON" (possible cyclic definition) \ + # N: Recursive types are not allowed at function scope \ + # E: Cannot resolve name "JSON" (possible cyclic definition) \ # N: Recursive types are not allowed at function scope reveal_type(x) # N: Revealed type is "Any" if isinstance(x, list): diff --git a/test-data/unit/check-typeguard.test b/test-data/unit/check-typeguard.test index 067047163..467a11240 100644 --- a/test-data/unit/check-typeguard.test +++ b/test-data/unit/check-typeguard.test @@ -164,7 +164,7 @@ def is_user(a: Dict[str, object]) -> TypeGuard[User]: return isinstance(a.get("name"), str) and isinstance(a.get("id"), int) def main(a: Dict[str, object]) -> None: if is_user(a): - reveal_type(a) # N: Revealed type is "" + reveal_type(a) # N: Revealed type is "Never" [builtins fixtures/dict.pyi] [typing fixtures/typing-typeddict.pyi] diff --git a/test-data/unit/check-unions.test b/test-data/unit/check-unions.test index 8275ad0d8..4669166a8 100644 --- a/test-data/unit/check-unions.test +++ b/test-data/unit/check-unions.test @@ -1007,6 +1007,8 @@ from typing import List, Union def test() -> None: MYTYPE = List[Union[str, "MYTYPE"]] # E: Cannot resolve name "MYTYPE" (possible cyclic definition) \ + # N: Recursive types are not allowed at function scope \ + # E: Cannot resolve name "MYTYPE" (possible cyclic definition) \ # N: Recursive types are not allowed at function scope [builtins fixtures/list.pyi] diff --git a/test-data/unit/stubgen-based.test b/test-data/unit/stubgen-based.test index 15db99442..6df6738bf 100644 --- a/test-data/unit/stubgen-based.test +++ b/test-data/unit/stubgen-based.test @@ -258,6 +258,7 @@ __all__ = [] __author__ = '' __version__ = '' [out] +__version__: str [case testBaseClass] class A: ... @@ -1626,10 +1627,8 @@ class A: pass [out] -from basedtyping import Untyped - def f(x): ... -def g(x, y: str) -> Untyped: ... +def g(x, y: str): ... class A: def f(self, x): ... @@ -1645,10 +1644,9 @@ def h(x: Any) -> str: pass [out] -from basedtyping import Untyped from typing import Any -def f(x: Any) -> Untyped: ... +def f(x: Any): ... def g(x, y: Any) -> str: ... def h(x: Any) -> str: ... @@ -2259,8 +2257,11 @@ __uri__ = '' __version__ = '' [out] +from m import __version__ as __version__ + class A: ... + [case testHideDunderModuleAttributesWithAll_import] from m import ( __about__, @@ -2288,6 +2289,7 @@ __uri__ = '' __version__ = '' [out] +from m import __version__ as __version__ [case testAttrsClass_semanal] import attr @@ -2345,9 +2347,9 @@ y: b.Y z: p.a.X [out] +import p.a import p.a as a import p.b as b -import p.a x: a.X y: b.Y @@ -2360,7 +2362,7 @@ from p import a x: a.X [out] -from p import a as a +from p import a x: a.X @@ -2382,7 +2384,7 @@ from p import a x: a.X [out] -from p import a as a +from p import a x: a.X @@ -2468,7 +2470,6 @@ class A: @overload def f(self, x: Tuple[int, int]) -> int: ... - @overload def f(x: int, y: int) -> int: ... @overload @@ -2530,7 +2531,6 @@ class A: @classmethod def g(cls, x: typing.Tuple[int, int]) -> int: ... - @typing.overload def f(x: int, y: int) -> int: ... @typing.overload @@ -2539,6 +2539,7 @@ def f(x: typing.Tuple[int, int]) -> int: ... [case testOverload_importTypingAs] import typing as t +import typing_extensions as te class A: @t.overload @@ -2578,8 +2579,21 @@ def f(*args: t.Union[int, t.Tuple[int, int]]) -> int: pass + +@te.overload +def g(x: int, y: int) -> int: + ... + +@te.overload +def g(x: t.Tuple[int, int]) -> int: + ... + +def g(*args: t.Union[int, t.Tuple[int, int]]) -> int: + pass + [out] import typing as t +import typing_extensions as te class A: @t.overload @@ -2593,11 +2607,15 @@ class A: @classmethod def g(cls, x: t.Tuple[int, int]) -> int: ... - @t.overload def f(x: int, y: int) -> int: ... @t.overload def f(x: t.Tuple[int, int]) -> int: ... +@te.overload +def g(x: int, y: int) -> int: ... +@te.overload +def g(x: t.Tuple[int, int]) -> int: ... + [case testProtocol_semanal] from typing import Protocol, TypeVar @@ -2626,9 +2644,7 @@ class PT(Protocol[T, T2]): [case testNonDefaultKeywordOnlyArgAfterAsterisk] def func(*, non_default_kwarg: bool, default_kwarg: bool = True): ... [out] -from basedtyping import Untyped - -def func(*, non_default_kwarg: bool, default_kwarg: bool = ...) -> Untyped: ... +def func(*, non_default_kwarg: bool, default_kwarg: bool = ...): ... [case testNestedGenerator] def f():