Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow all super calls to methods with trivial bodies #16756

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Disallow all super calls to methods with trivial bodies
Relates to:
https://discuss.python.org/t/calling-abstract-methods/42576

Mainly interested in seeing primer diff
  • Loading branch information
hauntsaninja committed Jan 7, 2024
commit d463a42a7cbd724db2d6f8152b789eda67b4821b
8 changes: 1 addition & 7 deletions mypy/checkmember.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,7 @@ def validate_super_call(node: FuncBase, mx: MemberContext) -> None:
impl = node.impl if isinstance(node.impl, FuncDef) else node.impl.func
unsafe_super = impl.is_trivial_body
if unsafe_super:
ret_type = (
impl.type.ret_type
if isinstance(impl.type, CallableType)
else AnyType(TypeOfAny.unannotated)
)
if not subtypes.is_subtype(NoneType(), ret_type):
mx.msg.unsafe_super(node.name, node.info.name, mx.context)
mx.msg.unsafe_super(node.name, node.info.name, mx.context)


def analyze_type_callable_member_access(name: str, typ: FunctionLike, mx: MemberContext) -> Type:
Expand Down
Loading