Skip to content

Add a setter to patch #674

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

Merged
merged 4 commits into from
Apr 1, 2025
Merged

Add a setter to patch #674

merged 4 commits into from
Apr 1, 2025

Conversation

galopyz
Copy link
Contributor

@galopyz galopyz commented Mar 22, 2025

This PR adds a setter to patch_to and patch with set_prop=True.

Here are the changes:

  • Creating a setter is limited to classes that already have a property with the same name.
  • It raises an AttributeError if there is no property with the name.

Copy link
Contributor

@jph00 jph00 left a comment

Choose a reason for hiding this comment

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

Looks great! I suspect you can collapse your implementation down to one line if you follow my suggestion - I don't think we need all that extra ceremony, since python will already raise a suitable exception afaik.

Co-authored-by: Jeremy Howard <j@howard.fm>
@galopyz galopyz requested a review from jph00 March 24, 2025 10:47
@jph00
Copy link
Contributor

jph00 commented Mar 27, 2025

It looks like you might have forgotten to update the notebook with my suggestion? AFAICT it's only in the .py file, which means it'll be overwritten next time someone exports.

@galopyz
Copy link
Contributor Author

galopyz commented Mar 27, 2025

I am very sorry about that. I forgot to update the notebook. I thought I could make changes on github, but I was wrong. I will make corrections.

@galopyz
Copy link
Contributor Author

galopyz commented Mar 27, 2025

I make the corrections, and it is good to go. I appreciate your patience.

@jph00
Copy link
Contributor

jph00 commented Apr 1, 2025

Thank you :)

@jph00 jph00 merged commit c8aaa6f into AnswerDotAI:main Apr 1, 2025
14 checks passed
@jph00 jph00 added the enhancement New feature or request label Apr 1, 2025
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.

2 participants