Skip to content

fix: 🐛 Fix ValueError when using Flag #2759

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Paillat-dev
Copy link
Contributor

@Paillat-dev Paillat-dev commented Apr 1, 2025

Summary

See also my comment on #2443 .

The issue was that a dataclasses.field object could not be reused and caused unhelpful TypeErrors.

This, or something fixing this issue should ideally be merged before #2443 is merged, and then master merged into #2443 .

Information

  • This PR fixes an issue.
    fixes: TypeError when using Flag with python 3.11+ #2758
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

@github-project-automation github-project-automation bot moved this to In Progress in Pycord Releases Apr 1, 2025
@Lulalaby Lulalaby added this to the v2.7 milestone Apr 1, 2025
Comment on lines -122 to +125
MissingField = field(default_factory=lambda: MISSING)


def missing_field_factory() -> field:
return field(default_factory=lambda: MISSING)
Copy link
Member

Choose a reason for hiding this comment

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

maybe I'm stupid but how is this different

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the other one was referencing the same object every time, whereas here it creates a new object. I have no knowledge of the python interpreter internals that make this work, but yeah

@Paillat-dev Paillat-dev requested a review from plun1331 May 9, 2025 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

TypeError when using Flag with python 3.11+
4 participants