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

Add time, tzinfo, and timezone as immutable function calls #13109

Merged

Conversation

N-Wouda
Copy link
Contributor

@N-Wouda N-Wouda commented Aug 26, 2024

Summary

Currently, datetime.datetime, datetime.date, and datetime.timedelta are correctly flagged as immutable calls, and RUF009 does not complain about their use in dataclasses. But the datetime module features three more classes that are also immutable: time, tzinfo, and timezone. See here for details. These are missing, and that causes a false positive for e.g. the following example:

from dataclasses import dataclass
from datetime import time


@dataclass
class Test:
    test: time = time()

Test Plan

Not sure, I'm not all that familiar with Rust or the Ruff internals. How do I add tests for this? 😄

@N-Wouda N-Wouda force-pushed the add-missing-immutable-datetime-types branch from b51d809 to b1171e1 Compare August 26, 2024 13:15
@N-Wouda N-Wouda force-pushed the add-missing-immutable-datetime-types branch from b1171e1 to feae164 Compare August 26, 2024 13:21
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

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.

Thanks!

@AlexWaygood AlexWaygood added bug Something isn't working linter Related to the linter labels Aug 27, 2024
@AlexWaygood AlexWaygood merged commit e6d0c4a into astral-sh:main Aug 27, 2024
20 checks passed
@N-Wouda N-Wouda deleted the add-missing-immutable-datetime-types branch August 27, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linter Related to the linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants