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

Forward references #480

Closed
matthew-parrott opened this issue Sep 12, 2023 · 2 comments
Closed

Forward references #480

matthew-parrott opened this issue Sep 12, 2023 · 2 comments

Comments

@matthew-parrott
Copy link

Hi there -- does Codon support forward references as defined in PEP 484:

https://peps.python.org/pep-0484/#forward-references

I have some code which looks like this:

class A:
    child: 'A' = None

But, I get the error:
error: expected type expression

@matthew-parrott
Copy link
Author

It looks like this works:

class A:
    child: A = None

Which, I'm happy there's a way to do this. But, that means the code won't work in Python and I was hoping (maybe unrealistically so) that I could run the same code (within reason; it has 0 dependencies outside the standard library) in both environments.

@inumanag
Copy link
Contributor

This is duplicate of #482 ; Self should be the canonical way to cover both grounds.

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

No branches or pull requests

2 participants