Skip to content

Conversation

Jelleas
Copy link
Contributor

@Jelleas Jelleas commented Sep 3, 2025

Per @cmlsharp's comment in cs50/check50#368, Python 3.7 brought with it dataclasses that can directly replace attrs. This pr replaces the only use of attrs in lib50 with dataclasses and removes attrs as a dependency. lib50 already requires python>=3.8, so no change needed there.

slots can be set through dataclasses too, but requires python>=3.10 (see https://docs.python.org/3/library/dataclasses.html#module-contents). Functionally this is not needed for lib50.

@rongxin-liu rongxin-liu added the enhancement New feature or request label Sep 3, 2025
@rongxin-liu rongxin-liu self-assigned this Sep 3, 2025
@Jelleas Jelleas changed the title Rm attr Rm attrs Sep 3, 2025
@cmlsharp
Copy link
Contributor

cmlsharp commented Sep 3, 2025

👍 on slots not being necessary. I think pre-3.10 you could still declare __slots__ on a dataclass, but IIRC some stuff like default values wouldn't work out of the box. The memory usage/performance of lib50 should in no way bottlenecked by the User struct so it's not a big deal not to have them if you want the min supported version to be < 3.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants