Skip to content

Add a setter to patch#674

Merged
jph00 merged 4 commits into
AnswerDotAI:mainfrom
galopyz:patch-setter
Apr 1, 2025
Merged

Add a setter to patch#674
jph00 merged 4 commits into
AnswerDotAI:mainfrom
galopyz:patch-setter

Conversation

@galopyz
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread fastcore/basics.py Outdated
Co-authored-by: Jeremy Howard <j@howard.fm>
@galopyz galopyz requested a review from jph00 March 24, 2025 10:47
@jph00
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

galopyz commented Mar 27, 2025

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

@jph00
Copy link
Copy Markdown
Contributor

jph00 commented Apr 1, 2025

Thank you :)

@jph00 jph00 merged commit c8aaa6f into AnswerDotAI:main Apr 1, 2025
@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