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

Typing spec update: type[] distributes over unions #35

Closed
5 tasks done
InSyncWithFoo opened this issue Aug 22, 2024 · 2 comments
Closed
5 tasks done

Typing spec update: type[] distributes over unions #35

InSyncWithFoo opened this issue Aug 22, 2024 · 2 comments
Labels

Comments

@InSyncWithFoo
Copy link

InSyncWithFoo commented Aug 22, 2024

As noted in the Python Forum discussion, all major type checkers already consider this to be the case; backward compatibility problems will thus be minimal if not non-existent. This proposal is only to formalize the concept.

Relevant concerns raised during the discussion were about wording, which have since been addressed in the PR.

TC Sign-off

  • Carl
  • Eric
  • Jelle
  • Rebecca
  • Shantanu
@mikeshardmind
Copy link

I don't think all relevent concerns were addressed.

The open question, as you mentioned, is whether we keep type[] defined as-is (though without constructibility, which is not specified but is implemented, unsoundly, by all type checkers) and add a new syntax sugar for that constructible-type intersection, or we redefine type[] to mean that constructible-type intersection. I agree that the latter probably agrees better with much current usage of type[]. Both are breaking changes in practice for some current code. The former is more expressive, in that it still gives you a way to spell the always-covariant-but-not-constructible “C and all subclasses of C” type[].

https://discuss.python.org/t/specs-clarification-type-a-b-is-equivalent-the-same-as-type-a-type-b/60912/26

One of the options here is not compatible with this, and has not reached resolution.

@carljm
Copy link
Member

carljm commented Aug 22, 2024

I agree that the option of redefining type as described there is not compatible with this spec clarification, but since it's also not compatible with other clear wording already in the spec about what type means, I don't see it as a barrier to this clarification. Whether we make this clarification or not, redefining type will require changing the spec, as well as the behavior of type checkers, which will be a much bigger challenge than changing the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants