Skip to content

error: "Type[None]" has no attribute "__bool__" #11539

Open

Description

@KotlinIsland
type(None).__bool__

Activity

  1. sobolevn commented on Nov 13, 2021

    @sobolevn
    Member

    We need to add something like

    mypy/mypy/checkmember.py

    Lines 323 to 329 in 8f281fb

    if is_python_3 and name == '__bool__':
    literal_false = LiteralType(False, fallback=mx.named_type('builtins.bool'))
    return CallableType(arg_types=[],
    arg_kinds=[],
    arg_names=[],
    ret_type=literal_false,
    fallback=mx.named_type('builtins.function'))

    but for Type[None], PR is on its way! 👍

  2. KotlinIsland commented on Nov 14, 2021

    @KotlinIsland
    ContributorAuthor

    Would it make sense to use typesheds _typeshed.NoneType for analysis instead of hardcoding it into the typechecker?

  3. sobolevn commented on Nov 14, 2021

    @sobolevn
    Member

    _typeshed.NoneType is not standartized. We cannot use it yet 😞

  4. erictraut commented on Nov 14, 2021

    @erictraut

    FWIW, pyright uses _typeshed.NoneType.

  5. sobolevn commented on Nov 14, 2021

    @sobolevn
    Member

    @erictraut do you use any other _typeshed types? 🤔

  6. erictraut commented on Nov 14, 2021

    @erictraut

    That's the only symbol from _typeshed. We also use _TypedDict from typing, which predates _typeshed but should maybe be moved there.

  7. emmatyping commented on Jun 8, 2022

    @emmatyping
    Member

    I think we should probably use _typeshed.NoneType or types.NoneType in 3.10+ (which _typeshed.NoneType already handles).

    If someone wants to make a PR changing mypy to leverage the _typeshed code, I'd be happy to review it.

  8. KotlinIsland commented on Jun 9, 2022

    @KotlinIsland
    ContributorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-runtime-semanticsmypy doesn't model runtime semantics correctly

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions