
from __future__ import annotations

try:
    from typing import ClassVar
except ImportError:  # Py<=3.5
    ClassVar = {int: int}


class PyAnnotatedClass:
    """
    >>> PyAnnotatedClass.__annotations__["CLASS_VAR"]
    'ClassVar[int]'
    >>> PyAnnotatedClass.__annotations__["obj"]
    'str'
    >>> PyAnnotatedClass.__annotations__["literal"]
    "'int'"
    >>> PyAnnotatedClass.__annotations__["recurse"]
    "'PyAnnotatedClass'"
    >>> PyAnnotatedClass.__annotations__["default"]
    'bool'
    >>> PyAnnotatedClass.CLASS_VAR
    1
    >>> PyAnnotatedClass.default
    False
    >>> PyAnnotatedClass.obj
    Traceback (most recent call last):
      ...
    AttributeError: type object 'PyAnnotatedClass' has no attribute 'obj'
    """
    CLASS_VAR: ClassVar[int] = 1
    obj: str
    literal: "int"
    recurse: "PyAnnotatedClass"
    default: bool = False


class PyVanillaClass:
    """
    >>> PyVanillaClass.__annotations__
    Traceback (most recent call last):
      ...
    AttributeError: type object 'PyVanillaClass' has no attribute '__annotations__'
    """


from __future__ import annotations

import sys

try:
    from typing import ClassVar
except ImportError:  # Py<=3.5
    ClassVar = {int: int}


class PyAnnotatedClass:
    """
    >>> PyAnnotatedClass.__annotations__["CLASS_VAR"]
    'ClassVar[int]'
    >>> PyAnnotatedClass.__annotations__["obj"]
    'str'
    >>> PyAnnotatedClass.__annotations__["literal"]
    "'int'"
    >>> PyAnnotatedClass.__annotations__["recurse"]
    "'PyAnnotatedClass'"
    >>> PyAnnotatedClass.__annotations__["default"]
    'bool'
    >>> PyAnnotatedClass.CLASS_VAR
    1
    >>> PyAnnotatedClass.default
    False
    >>> PyAnnotatedClass.obj
    Traceback (most recent call last):
      ...
    AttributeError: type object 'PyAnnotatedClass' has no attribute 'obj'
    """
    CLASS_VAR: ClassVar[int] = 1
    obj: str
    literal: "int"
    recurse: "PyAnnotatedClass"
    default: bool = False


class PyVanillaClass:
    """
    Before Py3.10, unannotated classes did not have '__annotations__'.

    >>> try:
    ...     a = PyVanillaClass.__annotations__
    ... except AttributeError:
    ...     assert sys.version_info < (3, 10)
    ... else:
    ...     assert sys.version_info >= (3, 10)
    ...     assert a == {}
    """

Repair a Python compatibility test in Py3.10.
Repair a Python compatibility test in Py3.10.

  
  from __future__ import annotations
+ 
+ import sys
  
  try:
      from typing import ClassVar
  except ImportError:  # Py<=3.5
      ClassVar = {int: int}
  
  
  class PyAnnotatedClass:
      """
      >>> PyAnnotatedClass.__annotations__["CLASS_VAR"]
      'ClassVar[int]'
      >>> PyAnnotatedClass.__annotations__["obj"]
      'str'
      >>> PyAnnotatedClass.__annotations__["literal"]
      "'int'"
      >>> PyAnnotatedClass.__annotations__["recurse"]
      "'PyAnnotatedClass'"
      >>> PyAnnotatedClass.__annotations__["default"]
      'bool'
      >>> PyAnnotatedClass.CLASS_VAR
      1
      >>> PyAnnotatedClass.default
      False
      >>> PyAnnotatedClass.obj
      Traceback (most recent call last):
        ...
      AttributeError: type object 'PyAnnotatedClass' has no attribute 'obj'
      """
      CLASS_VAR: ClassVar[int] = 1
      obj: str
      literal: "int"
      recurse: "PyAnnotatedClass"
      default: bool = False
  
  
  class PyVanillaClass:
      """
+     Before Py3.10, unannotated classes did not have '__annotations__'.
+ 
+     >>> try:
-     >>> PyVanillaClass.__annotations__
+     ...     a = PyVanillaClass.__annotations__
-     Traceback (most recent call last):
-       ...
-     AttributeError: type object 'PyVanillaClass' has no attribute '__annotations__'
+     ... except AttributeError:
+     ...     assert sys.version_info < (3, 10)
+     ... else:
+     ...     assert sys.version_info >= (3, 10)
+     ...     assert a == {}
      """
  
Repair a Python compatibility test in Py3.10.
## Code Before:

from __future__ import annotations

try:
    from typing import ClassVar
except ImportError:  # Py<=3.5
    ClassVar = {int: int}


class PyAnnotatedClass:
    """
    >>> PyAnnotatedClass.__annotations__["CLASS_VAR"]
    'ClassVar[int]'
    >>> PyAnnotatedClass.__annotations__["obj"]
    'str'
    >>> PyAnnotatedClass.__annotations__["literal"]
    "'int'"
    >>> PyAnnotatedClass.__annotations__["recurse"]
    "'PyAnnotatedClass'"
    >>> PyAnnotatedClass.__annotations__["default"]
    'bool'
    >>> PyAnnotatedClass.CLASS_VAR
    1
    >>> PyAnnotatedClass.default
    False
    >>> PyAnnotatedClass.obj
    Traceback (most recent call last):
      ...
    AttributeError: type object 'PyAnnotatedClass' has no attribute 'obj'
    """
    CLASS_VAR: ClassVar[int] = 1
    obj: str
    literal: "int"
    recurse: "PyAnnotatedClass"
    default: bool = False


class PyVanillaClass:
    """
    >>> PyVanillaClass.__annotations__
    Traceback (most recent call last):
      ...
    AttributeError: type object 'PyVanillaClass' has no attribute '__annotations__'
    """

## Instruction:
Repair a Python compatibility test in Py3.10.
## Code After:

from __future__ import annotations

import sys

try:
    from typing import ClassVar
except ImportError:  # Py<=3.5
    ClassVar = {int: int}


class PyAnnotatedClass:
    """
    >>> PyAnnotatedClass.__annotations__["CLASS_VAR"]
    'ClassVar[int]'
    >>> PyAnnotatedClass.__annotations__["obj"]
    'str'
    >>> PyAnnotatedClass.__annotations__["literal"]
    "'int'"
    >>> PyAnnotatedClass.__annotations__["recurse"]
    "'PyAnnotatedClass'"
    >>> PyAnnotatedClass.__annotations__["default"]
    'bool'
    >>> PyAnnotatedClass.CLASS_VAR
    1
    >>> PyAnnotatedClass.default
    False
    >>> PyAnnotatedClass.obj
    Traceback (most recent call last):
      ...
    AttributeError: type object 'PyAnnotatedClass' has no attribute 'obj'
    """
    CLASS_VAR: ClassVar[int] = 1
    obj: str
    literal: "int"
    recurse: "PyAnnotatedClass"
    default: bool = False


class PyVanillaClass:
    """
    Before Py3.10, unannotated classes did not have '__annotations__'.

    >>> try:
    ...     a = PyVanillaClass.__annotations__
    ... except AttributeError:
    ...     assert sys.version_info < (3, 10)
    ... else:
    ...     assert sys.version_info >= (3, 10)
    ...     assert a == {}
    """
