-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
(RUF012) Fixed mutable class Defaults- Task 2 #10286
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I'm concerned this looks good.
However, I'm going to need to get a second opinion from staff
@ananyakaligal I looked at this with Drini and we realized we probably don't want all these values to be mutable. See https://docs.astral.sh/ruff/rules/mutable-class-default/ |
@RayBB sure, I will work on this. |
@ananyakaligal any update on this? |
Hey @RayBB, My schedule has been pretty packed, and I'm working on the preview button right now. The CSS part of that is a bit much and very specific, so it's taking some time. I'll definitely work on this by the end of this week. My apologies! |
No problem. Marking as draft until it's ready 👍 |
@RayBB I used MappingProxyType to ensure immutability, as I encountered dictionaries throughout and wanted to maintain consistency. Now, I will investigate the files where the class variable overriding issue popped up. |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
@RayBB Proposed Solutions: 1.Use Instance Variables
2.Use Immutable Types
3.Rename in Child Class
Considering these solutions, which approach do you recommend for managing multiple variables like facet_fields and field_name_map? Should we refactor the parent class to enforce a consistent approach across its attributes? |
@RayBB Could you please provide your feedback on the solutions I proposed earlier? |
I see how messy this one is really great work diving in on it. Lets move openlibrary/plugins/worksearch/schemes/editions.py to be part of #10283
|
PS: I went ahead and removed the editions.py changes so Drini and I can review this one tomorrow. Hopefully merge it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome thank you @ananyakaligal ! One change request for you in the testing file ; the schema file looks good.
58099ca
to
db41f09
Compare
148a4db
to
44b1263
Compare
0160bbd
to
2151049
Compare
for more information, see https://pre-commit.ci
@cdrini I hope I have made all the changes as requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm, nice work @ananyakaligal !
Part of #10196
NOTE: These are NOT automated changes, they are done by hand
This pull request addresses Part of RUF012 Rule - Task 2, with a focus on enhancing code quality and resolving linting issues related to mutable class attributes.
Technical Details:
Testing:
Ran ruff check --select RUF012 to confirm that no further warnings related to mutable class attributes remain.
Screenshot:
N/A
Stakeholders:
@RayBB