FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

pytype silent when enum member given instead of built-in type · Issue #589 · google/pytype · GitHub

This repository was archived by the owner on Sep 3, 2026. It is now read-only.
/ pytype Public archive
This repository was archived by the owner on Sep 3, 2026. It is now read-only.

pytype silent when enum member given instead of built-in type #589

Description

Hello,

Consider the following:

from enum import Enum

class MyEnum(Enum):
    x = "x"
    y: 'MyEnum' = "y"
    z = "z" # type: 'MyEnum'

def accept_str(s: str): pass

accept_str("hello") # OK, as expected
accept_str(MyEnum.x.value) # OK, as expected
accept_str(MyEnum.x) # Not OK, but pytype is silent
accept_str(MyEnum.y) # Not OK, but pytype is silent
accept_str(MyEnum.z) # Not OK, but pytype is silent

Pytype finds nothing to complain about when MyEnum.x is of <enum MyEnum> type, and not str (which is the case for MyEnum.x.value).

Also for IntEnums:

from enum import IntEnum

class MyIntEnum(IntEnum):
    a = 1
    b: 'MyIntEnum' = 2
    c = 3 # type: 'MyIntEnum'

def accept_int(i: int): pass

accept_int(42) # OK, as expected
accept_int(MyIntEnum.a.value) # OK, as expected
accept_int(MyIntEnum.a) # Not OK, but pytype is silent
accept_int(MyIntEnum.b) # Not OK, but pytype is silent
accept_int(MyIntEnum.c) # Not OK, but pytype is silent

pytype version: 2020.05.13

Activity

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL