[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
pull/1411/head
pre-commit-ci[bot] 2025-02-12 17:55:42 +00:00
rodzic c1ddf464d6
commit ac485fa06c
8 zmienionych plików z 57 dodań i 57 usunięć

Wyświetl plik

@ -236,7 +236,7 @@ class BuildPack:
) )
self.platform = "" self.platform = ""
@lru_cache() @lru_cache
def get_packages(self): def get_packages(self):
""" """
List of packages that are installed in this BuildPack. List of packages that are installed in this BuildPack.
@ -246,7 +246,7 @@ class BuildPack:
""" """
return set() return set()
@lru_cache() @lru_cache
def get_base_packages(self): def get_base_packages(self):
""" """
Base set of apt packages that are installed for all images. Base set of apt packages that are installed for all images.
@ -265,7 +265,7 @@ class BuildPack:
"gettext-base", "gettext-base",
} }
@lru_cache() @lru_cache
def get_build_env(self): def get_build_env(self):
""" """
Ordered list of environment variables to be set for this image. Ordered list of environment variables to be set for this image.
@ -281,7 +281,7 @@ class BuildPack:
""" """
return [] return []
@lru_cache() @lru_cache
def get_env(self): def get_env(self):
""" """
Ordered list of environment variables to be set for this image. Ordered list of environment variables to be set for this image.
@ -296,7 +296,7 @@ class BuildPack:
""" """
return [] return []
@lru_cache() @lru_cache
def get_path(self): def get_path(self):
""" """
Ordered list of file system paths to look for executables in. Ordered list of file system paths to look for executables in.
@ -306,14 +306,14 @@ class BuildPack:
""" """
return [] return []
@lru_cache() @lru_cache
def get_labels(self): def get_labels(self):
""" """
Docker labels to set on the built image. Docker labels to set on the built image.
""" """
return self.labels return self.labels
@lru_cache() @lru_cache
def get_build_script_files(self): def get_build_script_files(self):
""" """
Dict of files to be copied to the container image for use in building. Dict of files to be copied to the container image for use in building.
@ -338,7 +338,7 @@ class BuildPack:
f"Found a stencila manifest.xml at {root}. Stencila is no longer supported." f"Found a stencila manifest.xml at {root}. Stencila is no longer supported."
) )
@lru_cache() @lru_cache
def get_build_scripts(self): def get_build_scripts(self):
""" """
Ordered list of shell script snippets to build the base image. Ordered list of shell script snippets to build the base image.
@ -360,7 +360,7 @@ class BuildPack:
return [] return []
@lru_cache() @lru_cache
def get_preassemble_script_files(self): def get_preassemble_script_files(self):
""" """
Dict of files to be copied to the container image for use in preassembly. Dict of files to be copied to the container image for use in preassembly.
@ -374,7 +374,7 @@ class BuildPack:
""" """
return {} return {}
@lru_cache() @lru_cache
def get_preassemble_scripts(self): def get_preassemble_scripts(self):
""" """
Ordered list of shell snippets to build an image for this repository. Ordered list of shell snippets to build an image for this repository.
@ -391,7 +391,7 @@ class BuildPack:
""" """
return [] return []
@lru_cache() @lru_cache
def get_assemble_scripts(self): def get_assemble_scripts(self):
""" """
Ordered list of shell script snippets to build the repo into the image. Ordered list of shell script snippets to build the repo into the image.
@ -418,7 +418,7 @@ class BuildPack:
""" """
return [] return []
@lru_cache() @lru_cache
def get_post_build_scripts(self): def get_post_build_scripts(self):
""" """
An ordered list of executable scripts to execute after build. An ordered list of executable scripts to execute after build.
@ -431,7 +431,7 @@ class BuildPack:
""" """
return [] return []
@lru_cache() @lru_cache
def get_start_script(self): def get_start_script(self):
""" """
The path to a script to be executed at container start up. The path to a script to be executed at container start up.
@ -672,14 +672,14 @@ class BuildPack:
class BaseImage(BuildPack): class BaseImage(BuildPack):
@lru_cache() @lru_cache
def get_build_env(self): def get_build_env(self):
"""Return env directives required for build""" """Return env directives required for build"""
return [ return [
("APP_BASE", "/srv"), ("APP_BASE", "/srv"),
] ]
@lru_cache() @lru_cache
def get_env(self): def get_env(self):
"""Return env directives to be set after build""" """Return env directives to be set after build"""
return [] return []
@ -687,7 +687,7 @@ class BaseImage(BuildPack):
def detect(self): def detect(self):
return True return True
@lru_cache() @lru_cache
def get_preassemble_scripts(self): def get_preassemble_scripts(self):
scripts = [] scripts = []
try: try:
@ -727,19 +727,19 @@ class BaseImage(BuildPack):
return scripts return scripts
@lru_cache() @lru_cache
def get_assemble_scripts(self): def get_assemble_scripts(self):
"""Return directives to run after the entire repository has been added to the image""" """Return directives to run after the entire repository has been added to the image"""
return [] return []
@lru_cache() @lru_cache
def get_post_build_scripts(self): def get_post_build_scripts(self):
post_build = self.binder_path("postBuild") post_build = self.binder_path("postBuild")
if os.path.exists(post_build): if os.path.exists(post_build):
return [post_build] return [post_build]
return [] return []
@lru_cache() @lru_cache
def get_start_script(self): def get_start_script(self):
start = self.binder_path("start") start = self.binder_path("start")
if os.path.exists(start): if os.path.exists(start):

Wyświetl plik

@ -46,7 +46,7 @@ class CondaBuildPack(BaseImage):
return "linux-aarch64" return "linux-aarch64"
raise ValueError(f"Unknown platform {self.platform}") raise ValueError(f"Unknown platform {self.platform}")
@lru_cache() @lru_cache
def get_build_env(self): def get_build_env(self):
"""Return environment variables to be set. """Return environment variables to be set.
@ -90,13 +90,13 @@ class CondaBuildPack(BaseImage):
env.append(("KERNEL_PYTHON_PREFIX", "${NB_PYTHON_PREFIX}")) env.append(("KERNEL_PYTHON_PREFIX", "${NB_PYTHON_PREFIX}"))
return env return env
@lru_cache() @lru_cache
def get_env(self): def get_env(self):
"""Make kernel env the default for `conda install`""" """Make kernel env the default for `conda install`"""
env = super().get_env() + [("CONDA_DEFAULT_ENV", "${KERNEL_PYTHON_PREFIX}")] env = super().get_env() + [("CONDA_DEFAULT_ENV", "${KERNEL_PYTHON_PREFIX}")]
return env return env
@lru_cache() @lru_cache
def get_path(self): def get_path(self):
"""Return paths (including conda environment path) to be added to """Return paths (including conda environment path) to be added to
the PATH environment variable. the PATH environment variable.
@ -111,7 +111,7 @@ class CondaBuildPack(BaseImage):
path.append("${NPM_DIR}/bin") path.append("${NPM_DIR}/bin")
return path return path
@lru_cache() @lru_cache
def get_build_scripts(self): def get_build_scripts(self):
""" """
Return series of build-steps common to all Python 3 repositories. Return series of build-steps common to all Python 3 repositories.
@ -149,7 +149,7 @@ class CondaBuildPack(BaseImage):
major_pythons = {"2": "2.7", "3": "3.10"} major_pythons = {"2": "2.7", "3": "3.10"}
@lru_cache() @lru_cache
def get_build_script_files(self): def get_build_script_files(self):
""" """
Dict of files to be copied to the container image for use in building. Dict of files to be copied to the container image for use in building.
@ -374,7 +374,7 @@ class CondaBuildPack(BaseImage):
self.kernel_env_cutoff_version self.kernel_env_cutoff_version
) )
@lru_cache() @lru_cache
def get_preassemble_script_files(self): def get_preassemble_script_files(self):
"""preassembly only requires environment.yml """preassembly only requires environment.yml
@ -388,7 +388,7 @@ class CondaBuildPack(BaseImage):
assemble_files[environment_yml] = environment_yml assemble_files[environment_yml] = environment_yml
return assemble_files return assemble_files
@lru_cache() @lru_cache
def get_env_scripts(self): def get_env_scripts(self):
"""Return series of build-steps specific to this source repository.""" """Return series of build-steps specific to this source repository."""
scripts = [] scripts = []
@ -455,14 +455,14 @@ class CondaBuildPack(BaseImage):
] ]
return scripts return scripts
@lru_cache() @lru_cache
def get_preassemble_scripts(self): def get_preassemble_scripts(self):
scripts = super().get_preassemble_scripts() scripts = super().get_preassemble_scripts()
if self._should_preassemble_env: if self._should_preassemble_env:
scripts.extend(self.get_env_scripts()) scripts.extend(self.get_env_scripts())
return scripts return scripts
@lru_cache() @lru_cache
def get_assemble_scripts(self): def get_assemble_scripts(self):
scripts = super().get_assemble_scripts() scripts = super().get_assemble_scripts()
if not self._should_preassemble_env: if not self._should_preassemble_env:

Wyświetl plik

@ -69,7 +69,7 @@ class JuliaProjectTomlBuildPack(PythonBuildPack):
raise RuntimeError("Failed to find a matching Julia version: {compat}") raise RuntimeError("Failed to find a matching Julia version: {compat}")
return match return match
@lru_cache() @lru_cache
def get_build_env(self): def get_build_env(self):
"""Get additional environment settings for Julia and Jupyter """Get additional environment settings for Julia and Jupyter
@ -112,11 +112,11 @@ class JuliaProjectTomlBuildPack(PythonBuildPack):
else: else:
return "${REPO_DIR}" return "${REPO_DIR}"
@lru_cache() @lru_cache
def get_env(self): def get_env(self):
return super().get_env() + [("JULIA_PROJECT", self.project_dir)] return super().get_env() + [("JULIA_PROJECT", self.project_dir)]
@lru_cache() @lru_cache
def get_path(self): def get_path(self):
"""Adds path to Julia binaries to user's PATH. """Adds path to Julia binaries to user's PATH.
@ -127,7 +127,7 @@ class JuliaProjectTomlBuildPack(PythonBuildPack):
""" """
return super().get_path() + ["${JULIA_PATH}/bin"] return super().get_path() + ["${JULIA_PATH}/bin"]
@lru_cache() @lru_cache
def get_build_scripts(self): def get_build_scripts(self):
""" """
Return series of build-steps common to "ALL" Julia repositories Return series of build-steps common to "ALL" Julia repositories
@ -156,7 +156,7 @@ class JuliaProjectTomlBuildPack(PythonBuildPack):
), ),
] ]
@lru_cache() @lru_cache
def get_assemble_scripts(self): def get_assemble_scripts(self):
""" """
Return series of build-steps specific to "this" Julia repository Return series of build-steps specific to "this" Julia repository

Wyświetl plik

@ -9,12 +9,12 @@ from ..base import BaseImage
class NixBuildPack(BaseImage): class NixBuildPack(BaseImage):
"""A nix Package Manager BuildPack""" """A nix Package Manager BuildPack"""
@lru_cache() @lru_cache
def get_path(self): def get_path(self):
"""Return paths to be added to PATH environemnt variable""" """Return paths to be added to PATH environemnt variable"""
return super().get_path() + ["/home/${NB_USER}/.nix-profile/bin"] return super().get_path() + ["/home/${NB_USER}/.nix-profile/bin"]
@lru_cache() @lru_cache
def get_env(self): def get_env(self):
"""Ordered list of environment variables to be set for this image""" """Ordered list of environment variables to be set for this image"""
@ -24,7 +24,7 @@ class NixBuildPack(BaseImage):
("GIT_SSL_CAINFO", "/etc/ssl/certs/ca-certificates.crt"), ("GIT_SSL_CAINFO", "/etc/ssl/certs/ca-certificates.crt"),
] ]
@lru_cache() @lru_cache
def get_build_scripts(self): def get_build_scripts(self):
""" """
Return series of build-steps common to all nix repositories. Return series of build-steps common to all nix repositories.
@ -60,7 +60,7 @@ class NixBuildPack(BaseImage):
), ),
] ]
@lru_cache() @lru_cache
def get_build_script_files(self): def get_build_script_files(self):
"""Dict of files to be copied to the container image for use in building""" """Dict of files to be copied to the container image for use in building"""
return { return {
@ -68,7 +68,7 @@ class NixBuildPack(BaseImage):
"nix/nix-shell-wrapper": "/usr/local/bin/nix-shell-wrapper", "nix/nix-shell-wrapper": "/usr/local/bin/nix-shell-wrapper",
} }
@lru_cache() @lru_cache
def get_assemble_scripts(self): def get_assemble_scripts(self):
"""Return series of build-steps specific to this source repository.""" """Return series of build-steps specific to this source repository."""
return super().get_assemble_scripts() + [ return super().get_assemble_scripts() + [
@ -82,7 +82,7 @@ class NixBuildPack(BaseImage):
) )
] ]
@lru_cache() @lru_cache
def get_start_script(self): def get_start_script(self):
"""The path to a script to be executed as ENTRYPOINT""" """The path to a script to be executed as ENTRYPOINT"""
# the shell wrapper script duplicates the behaviour of other buildpacks # the shell wrapper script duplicates the behaviour of other buildpacks

Wyświetl plik

@ -80,7 +80,7 @@ class PipfileBuildPack(CondaBuildPack):
) )
return self._python_version return self._python_version
@lru_cache() @lru_cache
def get_preassemble_script_files(self): def get_preassemble_script_files(self):
"""Return files needed for preassembly""" """Return files needed for preassembly"""
files = super().get_preassemble_script_files() files = super().get_preassemble_script_files()
@ -90,7 +90,7 @@ class PipfileBuildPack(CondaBuildPack):
files[path] = path files[path] = path
return files return files
@lru_cache() @lru_cache
def get_preassemble_scripts(self): def get_preassemble_scripts(self):
"""scripts to run prior to staging the repo contents""" """scripts to run prior to staging the repo contents"""
scripts = super().get_preassemble_scripts() scripts = super().get_preassemble_scripts()
@ -108,7 +108,7 @@ class PipfileBuildPack(CondaBuildPack):
) )
return scripts return scripts
@lru_cache() @lru_cache
def get_assemble_scripts(self): def get_assemble_scripts(self):
"""Return series of build-steps specific to this repository.""" """Return series of build-steps specific to this repository."""
# If we have either Pipfile.lock, Pipfile, or runtime.txt declare the # If we have either Pipfile.lock, Pipfile, or runtime.txt declare the

Wyświetl plik

@ -98,7 +98,7 @@ class PythonBuildPack(CondaBuildPack):
# allow assembly from subset # allow assembly from subset
return True return True
@lru_cache() @lru_cache
def get_preassemble_script_files(self): def get_preassemble_script_files(self):
assemble_files = super().get_preassemble_script_files() assemble_files = super().get_preassemble_script_files()
for name in ("requirements.txt", "requirements3.txt"): for name in ("requirements.txt", "requirements3.txt"):
@ -107,7 +107,7 @@ class PythonBuildPack(CondaBuildPack):
assemble_files[requirements_txt] = requirements_txt assemble_files[requirements_txt] = requirements_txt
return assemble_files return assemble_files
@lru_cache() @lru_cache
def get_preassemble_scripts(self): def get_preassemble_scripts(self):
"""Return scripts to run before adding the full repository""" """Return scripts to run before adding the full repository"""
scripts = super().get_preassemble_scripts() scripts = super().get_preassemble_scripts()
@ -115,7 +115,7 @@ class PythonBuildPack(CondaBuildPack):
scripts.extend(self._get_pip_scripts()) scripts.extend(self._get_pip_scripts())
return scripts return scripts
@lru_cache() @lru_cache
def get_assemble_scripts(self): def get_assemble_scripts(self):
"""Return series of build steps that require the full repository""" """Return series of build steps that require the full repository"""
# If we have a runtime.txt & that's set to python-2.7, # If we have a runtime.txt & that's set to python-2.7,

Wyświetl plik

@ -146,7 +146,7 @@ class RBuildPack(PythonBuildPack):
self._runtime = f"r-{str(self._checkpoint_date)}" self._runtime = f"r-{str(self._checkpoint_date)}"
return True return True
@lru_cache() @lru_cache
def get_env(self): def get_env(self):
""" """
Set custom env vars needed for RStudio to load Set custom env vars needed for RStudio to load
@ -161,7 +161,7 @@ class RBuildPack(PythonBuildPack):
("LD_LIBRARY_PATH", "${R_HOME}/lib:${LD_LIBRARY_PATH}"), ("LD_LIBRARY_PATH", "${R_HOME}/lib:${LD_LIBRARY_PATH}"),
] ]
@lru_cache() @lru_cache
def get_path(self): def get_path(self):
""" """
Return paths to be added to the PATH environment variable. Return paths to be added to the PATH environment variable.
@ -171,7 +171,7 @@ class RBuildPack(PythonBuildPack):
""" """
return super().get_path() + ["/usr/lib/rstudio-server/bin/"] return super().get_path() + ["/usr/lib/rstudio-server/bin/"]
@lru_cache() @lru_cache
def get_build_env(self): def get_build_env(self):
""" """
Return environment variables to be set. Return environment variables to be set.
@ -185,7 +185,7 @@ class RBuildPack(PythonBuildPack):
("R_LIBS_USER", "${APP_BASE}/rlibs") ("R_LIBS_USER", "${APP_BASE}/rlibs")
] ]
@lru_cache() @lru_cache
def get_packages(self): def get_packages(self):
""" """
Return list of packages to be installed. Return list of packages to be installed.
@ -204,7 +204,7 @@ class RBuildPack(PythonBuildPack):
return super().get_packages().union(packages) return super().get_packages().union(packages)
@lru_cache() @lru_cache
def get_rspm_snapshot_url(self, snapshot_date, max_days_prior=7): def get_rspm_snapshot_url(self, snapshot_date, max_days_prior=7):
for i in range(max_days_prior): for i in range(max_days_prior):
snapshots = requests.post( snapshots = requests.post(
@ -232,7 +232,7 @@ class RBuildPack(PythonBuildPack):
) )
) )
@lru_cache() @lru_cache
def get_devtools_snapshot_url(self): def get_devtools_snapshot_url(self):
""" """
Return url of snapshot to use for getting devtools install Return url of snapshot to use for getting devtools install
@ -249,7 +249,7 @@ class RBuildPack(PythonBuildPack):
# appropriate binary packages without having to hard code version names here. # appropriate binary packages without having to hard code version names here.
return "https://packagemanager.posit.co/all/__linux__/${VERSION_CODENAME}/2022-06-03+Y3JhbiwyOjQ1MjYyMTU7RkM5ODcwN0M" return "https://packagemanager.posit.co/all/__linux__/${VERSION_CODENAME}/2022-06-03+Y3JhbiwyOjQ1MjYyMTU7RkM5ODcwN0M"
@lru_cache() @lru_cache
def get_build_scripts(self): def get_build_scripts(self):
""" """
Return series of build-steps common to all R repositories Return series of build-steps common to all R repositories
@ -361,7 +361,7 @@ class RBuildPack(PythonBuildPack):
return super().get_build_scripts() + scripts return super().get_build_scripts() + scripts
@lru_cache() @lru_cache
def get_preassemble_script_files(self): def get_preassemble_script_files(self):
files = super().get_preassemble_script_files() files = super().get_preassemble_script_files()
installR_path = self.binder_path("install.R") installR_path = self.binder_path("install.R")
@ -370,7 +370,7 @@ class RBuildPack(PythonBuildPack):
return files return files
@lru_cache() @lru_cache
def get_preassemble_scripts(self): def get_preassemble_scripts(self):
"""Install contents of install.R """Install contents of install.R
@ -396,7 +396,7 @@ class RBuildPack(PythonBuildPack):
return super().get_preassemble_scripts() + scripts return super().get_preassemble_scripts() + scripts
@lru_cache() @lru_cache
def get_assemble_scripts(self): def get_assemble_scripts(self):
"""Install the dependencies of or the repository itself""" """Install the dependencies of or the repository itself"""
assemble_scripts = super().get_assemble_scripts() assemble_scripts = super().get_assemble_scripts()

Wyświetl plik

@ -30,7 +30,7 @@ def str_to_version(vstr):
return tuple([int(n) for n in vstr.split(".")]) return tuple([int(n) for n in vstr.split(".")])
@lru_cache() @lru_cache
def parse_version(vstr): def parse_version(vstr):
"""Convert a simple 'x[.y[.z]]' version string to a comparable VersionInfo """Convert a simple 'x[.y[.z]]' version string to a comparable VersionInfo
@ -62,7 +62,7 @@ def patch(v):
return v[2] if len(v) >= 3 else 0 return v[2] if len(v) >= 3 else 0
@lru_cache() @lru_cache
def create_semver_matcher(constraint_str): def create_semver_matcher(constraint_str):
"""Create a matcher that can be used to match version tuples """Create a matcher that can be used to match version tuples