Skip to content

Commit

Permalink
Add test for circular types in enum instance attributes.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 407173206
  • Loading branch information
Solumin authored and rchen152 committed Nov 2, 2021
1 parent 6e33205 commit 03df5c3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pytype/tests/test_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,23 @@ def take_m(m: M):
return m.x
""", pythonpath=[d.path])

def test_instance_attrs_self_referential(self):
self.Check("""
from dataclasses import dataclass
from enum import Enum
from typing import Optional
@dataclass
class O:
thing: Optional["Thing"] = None
class Thing(Enum):
A = O()
def __init__(self, o: O):
self.b = o.thing
""")

def test_enum_bases(self):
self.CheckWithErrors("""
import enum
Expand Down

0 comments on commit 03df5c3

Please sign in to comment.