Skip to content

Conversation

@abhijeetbodas2001
Copy link
Contributor

Summary

Add more tests and TODOs for NamedTuple support, based on the typing spec: https://typing.python.org/en/latest/spec/namedtuples.html

Test Plan

This PR adds new tests.

@abhijeetbodas2001
Copy link
Contributor Author

@sharkdp I was going through the #17738 and found that we do not yet enforce these checks.
Since this might be less of a priority right now, I added test TODOs instead of opening an issue.
Could you review?

@github-actions
Copy link
Contributor

github-actions bot commented May 9, 2025

mypy_primer results

No ecosystem changes detected ✅

@MichaReiser

This comment was marked as outdated.

@MichaReiser MichaReiser added the ty Multi-file analysis & type inference label May 9, 2025
Copy link
Contributor

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Thank you!

Comment on lines 8 to 17
### Definition

```py
from typing import NamedTuple

class Location(NamedTuple):
altitude: float = 0.0
latitude: float # TODO: this should be an error. Fields without default values cannot come after fields with.
longitude: float
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move this test somewhere below? I'd like to have the "Basics" test on top.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, done!

@abhijeetbodas2001
Copy link
Contributor Author

abhijeetbodas2001 commented May 9, 2025

Thanks David. I've addressed both your comments.

@sharkdp sharkdp added the testing Related to testing Ruff itself label May 10, 2025
@sharkdp sharkdp merged commit 235b74a into astral-sh:main May 10, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Related to testing Ruff itself ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants