Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable self type annotation #448

Merged
merged 1 commit into from
Aug 3, 2022
Merged

Conversation

tylerflex
Copy link
Collaborator

Before, when type annotating a class method, could not reference the class name. Instead, we put it in quotes:

class MyClass:
    def copy(self) -> 'MyClass':
        pass

In python 3.7 +, we can use the class name in the annotations by importing

from __future__ import annotations

class MyClass:
    def copy(self) -> MyClass:
        pass

note, breaks python 3.6. Are we even supporting it though?

@momchil-flex
Copy link
Collaborator

Sounds good, python >=3.7 is already in our requirements.

@tylerflex tylerflex merged commit a40ec5e into develop Aug 3, 2022
@tylerflex tylerflex deleted the tyler/self_reference_type branch August 3, 2022 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants