Skip to content

Commit

Permalink
@cached_property is only since 3.8, we still support 3.7
Browse files Browse the repository at this point in the history
flake8 issued B019 warning about using lru_cache on methods, so moved
to a helper function
  • Loading branch information
yarikoptic committed Apr 25, 2024
1 parent 6f342ff commit 470882a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/datalad_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from email import policy
from email.headerregistry import ContentTypeHeader
from enum import Enum
from functools import cached_property, total_ordering
from functools import lru_cache, total_ordering
from getopt import GetoptError, getopt
from html.parser import HTMLParser
from http.client import HTTPMessage
Expand Down Expand Up @@ -1585,10 +1585,6 @@ class HomebrewInstaller(Installer):
),
}

@cached_property
def bin_dir(self) -> Path:
return Path(readcmd("brew", "--prefix").rstrip(os.linesep)) / "bin"

def install_package(
self,
package: str,
Expand Down Expand Up @@ -1616,8 +1612,9 @@ def install_package(
runcmd("brew", "doctor")
raise
### TODO: Handle variations in this path (Is it "$(brew --prefix)/bin"?)
log.debug("Installed program directory: %s", self.bin_dir)
return self.bin_dir
bin_dir = get_brew_bin_dir()
log.debug("Installed program directory: %s", bin_dir)
return bin_dir

def assert_supported_system(self, **_kwargs: Any) -> None:
if shutil.which("brew") is None:
Expand Down Expand Up @@ -2965,6 +2962,11 @@ def check_exists(path: Path) -> bool:
return os.path.exists(path)


@lru_cache()
def get_brew_bin_dir() -> Path:
return Path(readcmd("brew", "--prefix").rstrip(os.linesep)) / "bin"


def parse_links(html: str, base_url: Optional[str] = None) -> list[Link]:
"""
Parse the source of an HTML page and return a list of all hyperlinks found
Expand Down

0 comments on commit 470882a

Please sign in to comment.