Skip to content

Function returning NotImplementedType cannot return NotImplemented if strict=True #18914

Open
@schuelermine

Description

@schuelermine

Bug Report

A function returning NotImplementedType cannot return NotImplemented if strict=True.

(A clear and concise description of what the bug is.)

To Reproduce

from types import NotImplementedType

def foo() -> NotImplementedType:
    return NotImplemented

Expected Behavior

Type checks even with --strict

Actual Behavior

main.py:4: error: Returning Any from function declared to return "_NotImplementedType"  [no-any-return]
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 1.15.0
  • Mypy command-line flags: --strict
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-disallow-anyThe disallow-any-* family of flags

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions