Repository navigation
Conversation
4151e84 to
d7fbb9e
Compare
d7fbb9e to
62d90dc
Compare
|
I have updated the text to better clarify the exact comparisons for each of the supported attributes, |
62d90dc to
ff338e3
Compare
|
Dear TC, If so kindly let me know how to proceed. |
JelleZijlstra
left a comment
There was a problem hiding this comment.
I'm generally supportive but I think this change needs some more editing, and I'd like support in at least some type checkers (at least an open PR) before we start mandating this pattern.
c575c15 to
c951b00
Compare
|
Dear typing council, However now it appears that this PR is in a Catch-22 situation; Lacking response I plan close this in a few weeks |
This is not the case at all. It is very typical for type checkers to implement features even if they are not in the spec. It is very helpful to have feedback from type checker authors to be able to understand potential problems with spec changes. I think this has worked quite well in the past.and if a feature is useful enough there is usually a type checker that will implement it. |
carljm
left a comment
There was a problem hiding this comment.
Thanks for your patience, @Josverl. I'm not sure we've fully reached consensus yet on what should be supported here, but I also generally support making this clearly specified. I also think this still needs some editing to give a clear and unambiguous presentation of the requirements.
|
Thanks all for the renewed attention and comments.
|
…atform checks. Signed-off-by: Jos Verlinde <Jos.Verlinde@Microsoft.com>
Formatting improvements. Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
…sion comparisons. Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
b3b76c1 to
98e3697
Compare
|
Again thanks for the feedback and suggestions to improve the spec. I processed the comments and suggestion - and commented or marked them as resolved to keep track. Open topics. 1. 2-Tuple or 3-Tuple version comparisons.
2. Should 3. Scope I think the commits should be squashed when merging - I've kept them separate for now. |
|
We could eliminate open-question (2) and at least partially address (3) by just considering containment checks as out of scope to specify for now. Considering they don't add any new capability, just allow writing more concise code, they aren't really necessary. We could leave this out of the spec / conformance suite for now and up to individual type checkers. Similarly maybe for |
Is there any type checker that support this currently? |
ty |
|
At least for ty, Regarding containment checks, for ty tuples are trivial (also already supported!) but mutable types are not. ty handles this quite differently from other type checkers: we use full type inference, not special-cased AST-matching. This makes some thing a lot easier, and some things harder. For mutable container types, we would normally not infer e.g. I suspect that for type checkers that do AST matching, containment checks for tuple/list/set should all be equally straightforward. |
Would |
Not much. It would require that we implement astral-sh/ty#2280, which probably mostly requires the same machinery. (The problem here is that To be clear, I don't want you to weight this ty implementation issue too much -- I'd rather first hear from other typing council members what they think a good scope is here. |
|
Gentle reminder for additional feedback. |
|
Here's a summary of what type checkers already support (courtesy of Codex):
So nobody supports any |
This is proposed for the spec in python/typing#2173. It is trivial to support in mypy and seems useful, so let's add it.
Also : - wrapped lines to ~85 characters - tables to 110 characters - Improved .rst formatting and markup The Intent is for these commits allow tracability of review comments, but to be squashed to a single commit during merge. Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Inline list and set membership tests now preserve the values of their
individual elements, allowing ty to determine when a condition is always
true or false. With the target platform set to Linux, both `sys.platform
in ["linux", "windows"]` and `sys.platform in {"linux", "windows"}`
select only the matching branch, so an assignment there is inferred as
`Literal[1]`.
Reuse the precise element extraction used for iteration and membership
narrowing without changing the inferred container type. Lists and sets
use the existing tuple membership equality evaluator, including its
identity-or-equality behavior. For sets, assume equality is an
equivalence relation and equal objects have equal hashes. Checking
reflexive equality across union alternatives also improves existing
tuple membership inference.
Context is that in python/typing#2173 people are
wanting to specify that `sys.platform in ["linux", "windows"]` should
work. This makes it work in ty so that we can be fine with any outcome
of that specification change.
## Test plan
Mdtests cover platform-dependent branch reachability; positive and
negative membership in inline lists and sets; inferred literal values
and unions; fixed-length unpacking; stored mutable containers; custom
equality and identity; comparison chains; and preservation of enum-set
narrowing.
## Ecosystem report
The comparison for head `90111f10da9359722abb903351b89aaae0f9bcba` adds
four `redundant-condition-strict` warnings. The paasta and SciPy
warnings correctly identify disjoint membership checks. The dd-trace-py
warning exposes existing limitations in modeling dynamic `setattr`; the
Scrapy warning exposes existing attribute narrowing across method calls
and `await`. Equivalent equality checks already exhibit both limitations
on the base revision. These existing limitations are accepted for this
change. See the [full ecosystem
report](#28676 (comment))
for minimized examples and exact comparison details.
|
Just to avoid unneeded waiting: |
|
@carljm, CI also seems to have forgotten that I did sign the CLA with all my identities, re-signing is not possible either. |
carljm
left a comment
There was a problem hiding this comment.
I think the CLA signing failure is because your latest commit (unlike the previous ones) is authored by Jos_Verlinde@hotmail.com, which GitHub can't associate with your GitHub account. If you can amend that commit with a recognized email address and force push, I suspect the CLA signing check will pass.
Barring my two nits below, I think this PR is ready for conformance tests. @jorenham @davidhalter @JelleZijlstra @rchen152 any objections to the spec updates here, before @Josverl writes conformance tests?
|
I'll try to take a look this evening |
jorenham
left a comment
There was a problem hiding this comment.
Looks good overall, thanks. I left some comments for some minor issues / nits / suggestions.
| Required forms and optional extensions | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| Type checkers must support the forms specified above as required. Support for additional |
There was a problem hiding this comment.
consistency nit
| Type checkers must support the forms specified above as required. Support for additional | |
| Type checkers should support the forms specified above as required. Support for additional |
There was a problem hiding this comment.
I do not think that "should" can be combined with "required" in this sentence.
That would degrade the meaning of the "required" statements in the prior paragraphs, which I think is incorrect.
d027211 to
bc8965e
Compare
Minor changes to wording and formatting. Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bc8965e to
d2c4133
Compare
This PR expands and clarifies the specification for version, platform, and Python implementation checks:
sys.implementation.version.sys.platform.startswith().References :