Skip to content

Switch property to cached_property#82

Open
Prill wants to merge 2 commits intocoderedcorp:mainfrom
Prill:cached
Open

Switch property to cached_property#82
Prill wants to merge 2 commits intocoderedcorp:mainfrom
Prill:cached

Conversation

@Prill
Copy link

@Prill Prill commented Nov 27, 2025

Takes #73, adds a commit to fix the issue of caching a mutable object, and rebases the branch onto main.

vsalvino and others added 2 commits November 26, 2025 22:48
When using returning mutable objects from @cached_property, the same
dictionary object is shared between different calls, meaning that any
modifications to the returned dictionary will also show up in the
"cached" property. As an example, when if you call
`seo_struct_org_base_dict` on an object, then call
`seo_struct_org_dict`, and then call `seo_struct_org_base_dict`, it will
return the extended dictionary, because `seo_struct_org_dict` calls
`.update()` on the base dict.

I've changed the `@cached_property` to `@property` on the four methods
that return dictionaries. It's safe to leave it on the `_json` methods
since those return immutable strings.
@Prill
Copy link
Author

Prill commented Nov 27, 2025

Darn, it appears I didn't manage to stop it failing on 3.9. I don't know if that's an issue given that it's officially out of support since October 31st, but apologies for a PR that doesn't pass tests. I was really sure that was the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants