Skip to content

Conversation

@dylwil3
Copy link
Collaborator

@dylwil3 dylwil3 commented Aug 25, 2025

This PR attempts to add support for inferring string.templatelib.Template for t-string literals.

First PR of this kind so apologies in advance if I've made a mess of things! Also this is low priority so feel free to ignore.

Diff is relatively small but feel free to review commit-by-commit if it's more convenient.

Also tested LSP:
demo

@dylwil3 dylwil3 added the ty Multi-file analysis & type inference label Aug 25, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Aug 25, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

Comment on lines 5193 to +5117
fn known_class_roundtrip_from_str() {
let db = setup_db();
let mut db = setup_db();
Program::get(&db)
.set_python_version_with_source(&mut db)
.to(PythonVersionWithSource {
version: PythonVersion::latest_preview(),
source: PythonVersionSource::default(),
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you'd like me to handle this differently, and/or add an assertion to remind us to modify this once the latest supported version is Python 3.14

@github-actions
Copy link
Contributor

github-actions bot commented Aug 25, 2025

mypy_primer results

No ecosystem changes detected ✅
No memory usage changes detected ✅

@dylwil3 dylwil3 changed the title [ty] Add support for PEP 750 t-strings [ty] Add support for PEP 750 t-strings Aug 25, 2025
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@dylwil3 dylwil3 enabled auto-merge (squash) August 25, 2025 18:39
@dylwil3 dylwil3 disabled auto-merge August 25, 2025 18:39
@dylwil3 dylwil3 enabled auto-merge (squash) August 25, 2025 18:46
@dylwil3 dylwil3 merged commit ef4897f into astral-sh:main Aug 25, 2025
37 checks passed
@dylwil3 dylwil3 deleted the ty-t-strings branch August 25, 2025 18:51
second-ed pushed a commit to second-ed/ruff that referenced this pull request Sep 9, 2025
This PR attempts to adds support for inferring`string.templatelib.Template` for t-string literals.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants