Skip to content

Commit

Permalink
Use cached_property for the prefix property (#397)
Browse files Browse the repository at this point in the history
* Cache the value of the prefix property

* cache major,minor,patch as well

* cache class

* Use cached property instead

* revert for major,minor,patch
  • Loading branch information
ludeeus authored Mar 5, 2025
1 parent e24827c commit 75a248a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion awesomeversion/awesomeversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

from functools import cached_property
from typing import TYPE_CHECKING, Any, Dict
from warnings import warn

Expand Down Expand Up @@ -255,7 +256,7 @@ def string(self) -> str:
return self._version
return self._version[len(prefix) :]

@property
@cached_property
def prefix(self) -> str | None:
"""Return the version prefix if any"""
version = self._version
Expand Down

0 comments on commit 75a248a

Please sign in to comment.