1

I have the following problem.

I have something like this

class X(models.Model):
    def add_meber(self, user : User <-Error here):
        # code

class User(AbstractUser):
    # Code

Pycharm is no the class User when I use the type hint in the class X, there is a way to make this work ?

1 Answer 1

2

Wrap User with quotes in annotation or use postponed evaluation of annotations in case of Python 3.7.

Sign up to request clarification or add additional context in comments.

2 Comments

This worked for me, however, the auto-annotate feature in Pycharm (2018.2.5) does not include the quotation marks. Bug? Pycharm bug? Python bug? Is this documented anywhere?
@jpcgt It's a PyCharm bug, it's better to file an issue youtrack.jetbrains.com/issues/PY

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.