[ty] Add a SupportedPythonVersion enum#24412
Conversation
SupportedPythonVersion enum to enable JSON schemaSupportedPythonVersion enum
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 87.72%. The percentage of expected errors that received a diagnostic held steady at 82.85%. The number of fully passing files held steady at 74/132. |
Memory usage reportMemory usage unchanged ✅ |
e039630 to
7068819
Compare
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-await |
40 | 0 | 0 |
invalid-return-type |
1 | 0 | 0 |
| Total | 41 | 0 | 0 |
Changes in flaky projects detected. Raw diff output excludes flaky projects; see the HTML report for details.
|
7068819 to
5595025
Compare
MichaReiser
left a comment
There was a problem hiding this comment.
Thanks for looking into this.
I think I'd prefer this not be a serde deserialization error. Validating the schema with serde (or clap) is straightforward, but it comes at the cost of ty not understanding the entire configuration if there's the slightest mistake.
It also feels overly strict to me to reject newer Python versions. What if a project wants to use the next Python version but hasn't yet had a chance to upgrade ty? In that case, I think it would be fine to emit a warning diagnostic saying that the specified Python version isn't supported.
We could accomplish this by manually implementing the validation in to_program_settings. This also ensures better error messages, where we can point users to the problematic configuration (with a code snippet) rather than a generic deserialization error.
In #24402, I changed the TOML semantics to match the CLI, which was already rejecting Python versions outside of a fixed list: We could decide to change that, but my general intent was just to make it consistent with the CLI. I think a plausible behavior would be: |
|
Oh, I wasn't aware that the CLI already behaved that way. I only saw the change in #24402. What you're suggesting sounds good to me. |
|
It could have been unintentional... But yeah, my intent in that change was just to get thing into alignment. I'll follow-up with what I've suggested above. |
5595025 to
fd46015
Compare
1b98a90 to
edffbaa
Compare
a704295 to
31a9f69
Compare
2b95754 to
333e840
Compare
a08d136 to
482a4bc
Compare
333e840 to
409a821
Compare
482a4bc to
69773fc
Compare
409a821 to
1994c9b
Compare
69773fc to
d187804
Compare
1994c9b to
134a92b
Compare
d187804 to
306c0a0
Compare
134a92b to
d3ec898
Compare
306c0a0 to
6ff5134
Compare
d3ec898 to
8508179
Compare
aa3a8af to
788e7d7
Compare
8508179 to
c4526a8
Compare
788e7d7 to
9236531
Compare
c4526a8 to
c88837e
Compare
| serde = { workspace = true } | ||
| serde_json = { workspace = true } | ||
| shellexpand = { workspace = true } | ||
| strum = { workspace = true } |
There was a problem hiding this comment.
Huh, this is slightly annoying but I don't think it's worth bothering about
5fe2cb8 to
364811c
Compare
c88837e to
7e72378
Compare
* main: [ty] Fix bad diagnostic range for incorrect implicit `__init_subclass__` calls (#24541) [ty] Add a `SupportedPythonVersion` enum (#24412) [ty] Ignore unsupported editor-selected Python versions (#24498) [ty] Add snapshots for `__init_subclass__` diagnostics (#24539) [ty] Minor fix in tests (#24538) [ty] Allow `Final` variable assignments in `__post_init__` (#24529) [ty] Expand test suite for assignment errors (#24537) [ty] Use `map`, not `__map`, as the name of the mapping parameter in `TypedDict` `__init__` methods (#24535) [ty] Rework logic for synthesizing `TypedDict` methods (#24534) [flake8-bandit] Fix S103 false positives and negatives in mask analysis (#24424) [ty] mdtest.py: update dependencies (#24533) Rename patterns and arguments source order iterator method (#24532) [ty] Omit invalid keyword arguments from `TypedDict` signature (#24522) [ty] support super() in metaclass methods (#24483) [ty] Synthesize `__init__` for `TypedDict` (#24476)
Summary
This unifies the validation of supported Python versions between the CLI and TOML (e.g.,
environment.python-version) by introducing a single enum to share across them.