Skip to content

ForwardRef's and recursive type aliases are still broken #8609

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

Closed
ulidtko opened this issue Mar 31, 2020 · 1 comment
Closed

ForwardRef's and recursive type aliases are still broken #8609

ulidtko opened this issue Mar 31, 2020 · 1 comment

Comments

@ulidtko
Copy link

ulidtko commented Mar 31, 2020

The minimal Hutton razor doesn't typecheck.

# hutton.py

from typing import Union, Tuple

HuttonRazor = Union[
    int,
    Tuple['HuttonRazor', 'HuttonRazor'],
]

I've tested on these git tags with Python 3.8.2:

  • v0.761
  • v0.760
  • v0.750
  • v0.740
  • v0.730
  • v0.720
  • v0.710
  • v0.701
  • v0.700

None of them work; all emit an error of possible cyclic definition:

hutton.py:5: error: Cannot resolve name "HuttonRazor" (possible cyclic definition)
hutton.py:7: error: Cannot resolve name "HuttonRazor" (possible cyclic definition)

Which is bitterly upsetting, after having read:

The error message of v0.710 was much better:

hutton.py:5: error: Recursive types not fully supported yet, nested types replaced with "Any"

To be explicit: my expectation is no error. I'm following the typing module doc (and ergo, PEP 484).

I'd also searched among GitHub issues off course. #7069 is closed as "known limitation". #731 is the canonical f̶i̶v̶e̶-̶y̶e̶a̶r̶-̶o̶l̶d̶ issue where actual discussion & development of recursive types support happen. I can remember looking at it ~2 years ago, still open today.

The special prize goes to #6740 — "Stop saying mypy is beta software?". Haha, yes. Nice joke. Save it for tomorrow.

@emmatyping
Copy link
Member

Haha, yes. Nice joke.

There is no need to be rude. Consider this a warning to not be rude further.

Just because mypy doesn't support what you want doesn't mean it isn't ready to be used in production. Regardless this is a duplicate so I am closing.

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