Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

More precise type checking of NotImplemented and operator overloading #363

Open
Labels
@JukkaL

Description

@JukkaL

NotImplemented should be implicitly a valid return value of operator methods such as__lt__,__add__, but it should be flagged as an error to return it elsewhere (unless, maybe, the return type includes a suitable type such as typing.NotImplementedType).

Currently NotImplemented has type Any which allows it to be used in any context, which is wrong.

This should be fine:

def __lt__(self, x: int) -> bool:    if isinstance(x, int):        return ...    return NotImplemented

This should not be fine:

def f() -> bool:    return NotImplemented

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp