Skip to content

Commit

Permalink
Use cached_property for the simple property (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Mar 5, 2025
1 parent 04b4656 commit f86d41e
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions awesomeversion/awesomeversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class AwesomeVersion(str):
_modifier: str | None = None
_modifier_type: str | None = None
_sections: int | None = None
_simple: bool | None = None
_ensure_strategy: EnsureStrategyIterableType = []

def __init__(
Expand Down Expand Up @@ -455,14 +454,10 @@ def strategy(self) -> AwesomeVersionStrategy:
return description.strategy
return AwesomeVersionStrategy.UNKNOWN

@property
@cached_property
def simple(self) -> bool:
"""Return True if the version string is simple."""
if self._simple is None:
self._simple = (
generate_full_string_regex(RE_SIMPLE).match(self.string) is not None
)
return self._simple
return generate_full_string_regex(RE_SIMPLE).match(self.string) is not None


class AwesomeVersionDiff:
Expand Down

0 comments on commit f86d41e

Please sign in to comment.