Skip to content

Commit

Permalink
Bump ruff from 0.4.7 to 0.5.5 in the pip group across 1 directory (#24)
Browse files Browse the repository at this point in the history
* Bump ruff from 0.4.7 to 0.5.5 in the pip group across 1 directory

Bumps the pip group with 1 update in the / directory: [ruff](https://github.com/astral-sh/ruff).


Updates `ruff` from 0.4.7 to 0.5.5
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@v0.4.7...0.5.5)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: pip
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix ruff errors

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
  • Loading branch information
dependabot[bot] and fcollonval authored Jul 30, 2024
1 parent c981ab1 commit 464a12d
Show file tree
Hide file tree
Showing 14 changed files with 481 additions and 148 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ repos:
["traitlets>=5.13"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.4
rev: v0.5.5
hooks:
# - id: ruff
# types_or: [python, jupyter]
# args: ["--fix", "--show-fixes"]
- id: ruff
types_or: [python, jupyter]
args: ["--fix", "--show-fixes"]
- id: ruff-format
types_or: [python, jupyter]

Expand Down
2 changes: 1 addition & 1 deletion jupyter_builder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
# the package from a stable release or in editable mode: https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs
import warnings

warnings.warn("Importing 'jupyter_builder' outside a proper installation.")
warnings.warn("Importing 'jupyter_builder' outside a proper installation.", stacklevel=1)
__version__ = "dev"
4 changes: 1 addition & 3 deletions jupyter_builder/base_extension_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Distributed under the terms of the Modified BSD License.

from __future__ import annotations

import os
from copy import copy

Expand All @@ -15,9 +16,6 @@

HERE = os.path.dirname(os.path.abspath(__file__))


# from .federated_labextensions import build_labextension, develop_labextension_py, watch_labextension

flags = dict(base_flags)

develop_flags = copy(flags)
Expand Down
3 changes: 2 additions & 1 deletion jupyter_builder/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def _compare_ranges(spec1, spec2, drop_prerelease1=False, drop_prerelease2=False
# Set return_value to a sentinel value
return_value = False

# r1.set may be a list of ranges if the range involved an ||, so we need to test for overlaps between each pair.
# r1.set may be a list of ranges if the range involved an ||,
# so we need to test for overlaps between each pair.
for r1set, r2set in itertools.product(r1.set, r2.set):
x1 = r1set[0].semver
x2 = r1set[-1].semver
Expand Down
14 changes: 7 additions & 7 deletions jupyter_builder/debug_log_file_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ def debug_logging(self):
for line in msg:
self.log.debug(line)
if isinstance(ex, SystemExit):
warnings.warn(f"An error occurred. See the log file for details: {log_path}")
warnings.warn(
f"An error occurred. See the log file for details: {log_path}", stacklevel=1
)
raise
warnings.warn("An error occurred.")
warnings.warn(msg[-1].strip())
warnings.warn(f"See the log file for details: {log_path}")
warnings.warn("An error occurred.", stacklevel=1)
warnings.warn(msg[-1].strip(), stacklevel=1)
warnings.warn(f"See the log file for details: {log_path}", stacklevel=1)
self.exit(1)
else:
log.removeHandler(_debug_handler)
_debug_handler.flush()
_debug_handler.close()
try:
with contextlib.suppress(FileNotFoundError):
os.remove(log_path)
except FileNotFoundError:
pass
log.removeHandler(_debug_handler)
8 changes: 4 additions & 4 deletions jupyter_builder/extension_commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

from traitlets import Bool, Unicode

from ..base_extension_app import BaseExtensionApp
from ..core_path import default_core_path
from ..federated_extensions import build_labextension
from jupyter_builder.base_extension_app import BaseExtensionApp
from jupyter_builder.core_path import default_core_path
from jupyter_builder.federated_extensions import build_labextension

HERE = os.path.dirname(os.path.abspath(__file__))

Expand All @@ -27,7 +27,7 @@ class BuildLabExtensionApp(BaseExtensionApp):
help="Directory containing core application package.json file",
)

aliases = {
aliases = { # noqa: RUF012
"static-url": "BuildLabExtensionApp.static_url",
"development": "BuildLabExtensionApp.development",
"source-map": "BuildLabExtensionApp.source_map",
Expand Down
4 changes: 2 additions & 2 deletions jupyter_builder/extension_commands/develop.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from jupyter_core.application import base_flags
from traitlets import Bool, Unicode

from ..base_extension_app import BaseExtensionApp
from ..federated_extensions import develop_labextension_py
from jupyter_builder.base_extension_app import BaseExtensionApp
from jupyter_builder.federated_extensions import develop_labextension_py

flags = dict(base_flags)
develop_flags = copy(flags)
Expand Down
8 changes: 4 additions & 4 deletions jupyter_builder/extension_commands/watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

from traitlets import Bool, Unicode

from ..base_extension_app import BaseExtensionApp
from ..federated_extensions import watch_labextension
from ..core_path import default_core_path
from jupyter_builder.base_extension_app import BaseExtensionApp
from jupyter_builder.core_path import default_core_path
from jupyter_builder.federated_extensions import watch_labextension

HERE = os.path.dirname(os.path.abspath(__file__))

Expand All @@ -25,7 +25,7 @@ class WatchLabExtensionApp(BaseExtensionApp):
help="Directory containing core application package.json file",
)

aliases = {
aliases = { # noqa: RUF012
"core-path": "WatchLabExtensionApp.core_path",
"development": "WatchLabExtensionApp.development",
"source-map": "WatchLabExtensionApp.source_map",
Expand Down
47 changes: 22 additions & 25 deletions jupyter_builder/federated_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
from jupyter_core.utils import ensure_dir_exists
from jupyter_server.extension.serverextension import ArgumentConflict

# from jupyterlab_server.config import get_federated_extensions
from .federated_extensions_requirements import get_federated_extensions

try:
from tomllib import load # Python 3.11+
except ImportError:
from tomli import load

from .core_path import default_core_path

# from .commands import _test_overlap TO BE DONE -----------------------------

DEPRECATED_ARGUMENT = object()
Expand Down Expand Up @@ -95,7 +96,7 @@ def develop_labextension( # noqa
ensure_dir_exists(labext)

if isinstance(path, (list, tuple)):
msg = "path must be a string pointing to a single extension to install; call this function multiple times to install multiple extensions"
msg = "path must be a string pointing to a single extension to install; call this function multiple times to install multiple extensions" # noqa: E501
raise TypeError(msg)

if not destination:
Expand All @@ -104,7 +105,7 @@ def develop_labextension( # noqa
full_dest = normpath(pjoin(labext, destination))
if overwrite and os.path.lexists(full_dest):
if logger:
logger.info("Removing: %s" % full_dest)
logger.info("Removing: %s", full_dest)
if os.path.isdir(full_dest) and not os.path.islink(full_dest):
shutil.rmtree(full_dest)
else:
Expand All @@ -124,22 +125,23 @@ def develop_labextension( # noqa
if platform.platform().startswith("Windows"):
msg = (
"Symlinks can be activated on Windows 10 for Python version 3.8 or higher"
" by activating the 'Developer Mode'. That may not be allowed by your administrators.\n"
" by activating the 'Developer Mode'. That may not be allowed by your administrators.\n" # noqa: E501
"See https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development"
)
raise OSError(msg) from e
raise

elif not os.path.islink(full_dest):
raise ValueError("%s exists and is not a symlink" % full_dest)
msg = f"{full_dest} exists and is not a symlink"
raise ValueError(msg)

elif os.path.isdir(path):
path = pjoin(os.path.abspath(path), "") # end in path separator
for parent, _, files in os.walk(path):
dest_dir = pjoin(full_dest, parent[len(path) :])
if not os.path.exists(dest_dir):
if logger:
logger.info("Making directory: %s" % dest_dir)
logger.info("Making directory: %s", dest_dir)
os.makedirs(dest_dir)
for file_name in files:
src = pjoin(parent, file_name)
Expand All @@ -152,7 +154,7 @@ def develop_labextension( # noqa
return full_dest


def develop_labextension_py(
def develop_labextension_py( # noqa: PLR0913
module,
user=False,
sys_prefix=False,
Expand Down Expand Up @@ -195,10 +197,7 @@ def develop_labextension_py(
return full_dests


from .core_path import default_core_path


def build_labextension(
def build_labextension( # noqa: PLR0913
path, logger=None, development=False, static_url=None, source_map=False, core_path=None
):
"""Build a labextension in the given path"""
Expand All @@ -208,7 +207,7 @@ def build_labextension(
ext_path = str(Path(path).resolve())

if logger:
logger.info("Building extension in %s" % path)
logger.info("Building extension in %s", path)

builder = _ensure_builder(ext_path, core_path)

Expand All @@ -223,15 +222,15 @@ def build_labextension(
subprocess.check_call(arguments, cwd=ext_path) # noqa S603


def watch_labextension(
def watch_labextension( # noqa: PLR0913
path, labextensions_path, logger=None, development=False, source_map=False, core_path=None
):
"""Watch a labextension in a given path"""
core_path = default_core_path() if core_path is None else str(Path(core_path).resolve())
ext_path = str(Path(path).resolve())

if logger:
logger.info("Building extension in %s" % path)
logger.info("Building extension in %s", path)

# Check to see if we need to create a symlink
federated_extensions = get_federated_extensions(labextensions_path)
Expand Down Expand Up @@ -274,9 +273,8 @@ def _ensure_builder(ext_path, core_path):
dep_version2 = ext_data.get("devDependencies", {}).get("@jupyterlab/builder")
dep_version2 = dep_version2 or ext_data.get("dependencies", {}).get("@jupyterlab/builder")
if dep_version2 is None:
raise ValueError(
"Extensions require a devDependency on @jupyterlab/builder@%s" % dep_version1
)
msg = f"Extensions require a devDependency on @jupyterlab/builder@{dep_version1}"
raise ValueError(msg)

# if we have installed from disk (version is a path), assume we know what
# we are doing and do not check versions.
Expand Down Expand Up @@ -310,7 +308,7 @@ def _ensure_builder(ext_path, core_path):
# )

# if not overlap:
# msg = f"Extensions require a devDependency on @jupyterlab/builder@{dep_version1}, you have a dependency on {dep_version2}"
# msg = f"Extensions require a devDependency on @jupyterlab/builder@{dep_version1}, you have a dependency on {dep_version2}" # noqa: E501
# raise ValueError(msg)

return osp.join(
Expand Down Expand Up @@ -339,10 +337,10 @@ def _should_copy(src, dest, logger=None):
# we add a fudge factor to work around a bug in python 2.x
# that was fixed in python 3.x: https://bugs.python.org/issue12904
if logger:
logger.warning("Out of date: %s" % dest)
logger.warning("Out of date: %s", dest)
return True
if logger:
logger.info("Up to date: %s" % dest)
logger.info("Up to date: %s", dest)
return False


Expand Down Expand Up @@ -388,9 +386,8 @@ def _get_labextension_dir(user=False, sys_prefix=False, prefix=None, labextensio
]
conflicting_set = [f"{n}={v!r}" for n, v in conflicting if v]
if len(conflicting_set) > 1:
msg = "cannot specify more than one of user, sys_prefix, prefix, or labextensions_dir, but got: {}".format(
", ".join(conflicting_set)
)
conflict = ", ".join(conflicting_set)
msg = f"cannot specify more than one of user, sys_prefix, prefix, or labextensions_dir, but got: {conflict}" # noqa: E501
raise ArgumentConflict(msg)
if user:
labext = pjoin(jupyter_data_dir(), "labextensions")
Expand Down Expand Up @@ -449,8 +446,8 @@ def _get_labextension_metadata(module): # noqa
if not package:
try:
package = (
subprocess.check_output(
[sys.executable, "setup.py", "--name"], # noqa S603
subprocess.check_output( # noqa: S603
[sys.executable, "setup.py", "--name"],
cwd=mod_path,
)
.decode("utf8")
Expand Down
24 changes: 12 additions & 12 deletions jupyter_builder/federated_extensions_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ def get_federated_extensions(labextensions_path: list[str]) -> dict[str, Any]:
with open(ext_path, encoding="utf-8") as fid:
pkgdata = json.load(fid)
if pkgdata["name"] not in federated_extensions:
data = dict(
name=pkgdata["name"],
version=pkgdata["version"],
description=pkgdata.get("description", ""),
url=get_package_url(pkgdata),
ext_dir=ext_dir,
ext_path=osp.dirname(ext_path),
is_local=False,
dependencies=pkgdata.get("dependencies", dict()),
jupyterlab=pkgdata.get("jupyterlab", dict()),
)
data = {
"name": pkgdata["name"],
"version": pkgdata["version"],
"description": pkgdata.get("description", ""),
"url": get_package_url(pkgdata),
"ext_dir": ext_dir,
"ext_path": osp.dirname(ext_path),
"is_local": False,
"dependencies": pkgdata.get("dependencies", {}),
"jupyterlab": pkgdata.get("jupyterlab", {}),
}

# Add repository info if available
if "repository" in pkgdata and "url" in pkgdata.get("repository", {}):
data["repository"] = dict(url=pkgdata.get("repository").get("url"))
data["repository"] = {"url": pkgdata.get("repository").get("url")}

install_path = osp.join(osp.dirname(ext_path), "install.json")
if osp.exists(install_path):
Expand Down
Loading

0 comments on commit 464a12d

Please sign in to comment.