Skip to content

Does not work with annotation string #2

Description

@Horstage

Type annotations can be Strings and with Python 4.0 will always be handled as such (PEP 484).
As of Python 3.7 you can from __future__ import annotations to replicated Py4.0 behavior.
This package does not work with strings as annotation.

I already stumbled on this.
Referencing to parent or child objects of the same class is rather common (I believe)

from typing import Optional
class Foo:
    bar: int # works fine
    baz: "str"  # does not work, but you could simply remove quotation marks for now
    child: "Optional[MyClass]"  # does not work
    parent: "Optional[MyClass]"

The only solution I see right now is to use eval on the annotations. Please prove me wrong.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions