Skip to content

Conversation

@Jelleas
Copy link
Contributor

@Jelleas Jelleas commented Sep 3, 2025

Per @cmlsharp's comment in #368, Python 3.7 brought with it dataclasses that can directly replace attrs. This pr replaces the only uses of attrs in check50 with dataclasses and removes attrs as a dependency.

Opted to use python 3.10 as the 4.0.0-dev branch is already using features from Python 3.10. Such as match, and importlib.resources.files that was added in Python 3.9.

Used python 3.10 syntax for type hints (notably the use of |, and list instead of typing.List).
Set slots=True which is only supported from 3.10 onwards.

@rongxin-liu rongxin-liu self-assigned this Nov 5, 2025
@rongxin-liu rongxin-liu added the 4.x Issues relating to check50 4.x label Nov 5, 2025
@rongxin-liu rongxin-liu requested a review from Copilot January 4, 2026 17:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the codebase by replacing the attrs library with Python's built-in dataclasses module, which has been available since Python 3.7 and provides equivalent functionality.

  • Removes attrs as a dependency
  • Updates minimum Python version from 3.8 to 3.10 to leverage modern type hint syntax
  • Converts the CheckResult class from attrs to dataclasses with proper type annotations

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
setup.py Removes attrs>=18 from dependencies and updates minimum Python requirement to 3.10
check50/runner.py Converts CheckResult from attrs to dataclass with Python 3.10 type hints, updates attr.fields() to dataclasses.fields()
check50/main.py Replaces attr.asdict() with dataclasses.asdict() for serialization

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rongxin-liu
Copy link
Contributor

rongxin-liu commented Jan 4, 2026

Thank you! @Jelleas

@rongxin-liu rongxin-liu merged commit 3414d62 into cs50:4.0.0-dev Jan 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.x Issues relating to check50 4.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants