Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 8, 2025

This PR migrates the project from using the external cached_property package to Python's built-in functools.cached_property where possible, while preserving the library's cached_property_with_ttl implementation for TTL functionality.

Changes Made

Import Updates

  • msazure.py: from cached_property import cached_propertyfrom functools import cached_property
  • scvmm.py: from cached_property import cached_propertyfrom functools import cached_property
  • virtualcenter.py: from cached_property import threaded_cached_propertyfrom functools import cached_property
  • podman.py: Fixed incorrect from proto.utils import cached_propertyfrom functools import cached_property

Dependencies

  • Retained cached_property in pyproject.toml dependencies specifically for TTL functionality

TTL Functionality Preserved

  • vm.py: Continues using from cached_property import cached_property_with_ttl to maintain the proven library implementation for VM state caching with 1-second TTL

Technical Details

The migration strategically handles different cached property variants:

  1. Standard cached_property: Migrated to functools.cached_property (available since Python 3.8)
  2. threaded_cached_property: Replaced with functools.cached_property (which is already thread-safe)
  3. cached_property_with_ttl: Preserved from the library to avoid potential issues with custom TTL implementations

This approach reduces dependency usage while maintaining the reliability of the existing TTL caching mechanism used for VM state queries.

Fixes #514.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copy link
Contributor Author

Copilot AI commented Aug 8, 2025

@ogajduse 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Co-authored-by: ogajduse <20440883+ogajduse@users.noreply.github.com>
Copilot AI changed the title [WIP] Use cached_property from functools Use cached_property from functools instead of external package Aug 8, 2025
Copilot AI requested a review from ogajduse August 8, 2025 17:11
Copilot AI changed the title Use cached_property from functools instead of external package Migrate to functools.cached_property while preserving cached_property_with_ttl Aug 8, 2025
Copilot AI requested a review from ogajduse August 8, 2025 17:29
@ogajduse ogajduse marked this pull request as ready for review August 8, 2025 18:40
Co-authored-by: ogajduse <20440883+ogajduse@users.noreply.github.com>
@ogajduse ogajduse requested a review from JacobCallahan August 8, 2025 18:53
@ogajduse ogajduse merged commit 6b52050 into master Oct 16, 2025
4 checks passed
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.

Use cached_property from functools

4 participants