Skip to content

Commit cd8010e

Browse files
[pre-commit.ci] pre-commit autoupdate (#1255)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Steven Silvester <[email protected]>
1 parent 3d4e162 commit cd8010e

File tree

16 files changed

+34
-28
lines changed

16 files changed

+34
-28
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repos:
2020
- id: trailing-whitespace
2121

2222
- repo: https://github.com/python-jsonschema/check-jsonschema
23-
rev: 0.21.0
23+
rev: 0.22.0
2424
hooks:
2525
- id: check-github-workflows
2626

@@ -30,12 +30,12 @@ repos:
3030
- id: mdformat
3131

3232
- repo: https://github.com/psf/black
33-
rev: 23.1.0
33+
rev: 23.3.0
3434
hooks:
3535
- id: black
3636

3737
- repo: https://github.com/charliermarsh/ruff-pre-commit
38-
rev: v0.0.254
38+
rev: v0.0.260
3939
hooks:
4040
- id: ruff
4141
args: ["--fix"]

jupyter_server/auth/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def set_password(args):
1919
password1 = getpass("" if args.quiet else "Provide password: ")
2020
password_repeat = getpass("" if args.quiet else "Repeat password: ")
2121
if password1 != password_repeat:
22-
warnings.warn("Passwords do not match, try again")
22+
warnings.warn("Passwords do not match, try again", stacklevel=2)
2323
elif len(password1) < 4: # noqa
24-
warnings.warn("Please provide at least 4 characters")
24+
warnings.warn("Please provide at least 4 characters", stacklevel=2)
2525
else:
2626
password = password1
2727

jupyter_server/auth/identity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ def is_token_authenticated(self, handler: JupyterHandler) -> bool:
499499
- skip origin-checks for scripts
500500
"""
501501
# ensure get_user has been called, so we know if we're token-authenticated
502-
handler.current_user
502+
handler.current_user # noqa
503503
return getattr(handler, "_token_authenticated", False)
504504

505505
def validate_security(

jupyter_server/auth/login.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def is_token_authenticated(cls, handler):
165165
"""DEPRECATED in 2.0, use IdentityProvider API"""
166166
if getattr(handler, "_user_id", None) is None:
167167
# ensure get_user has been called, so we know if we're token-authenticated
168-
handler.current_user
168+
handler.current_user # noqa
169169
return getattr(handler, "_token_authenticated", False)
170170

171171
@classmethod

jupyter_server/auth/security.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def passwd(passphrase=None, algorithm="argon2"):
5252
passphrase = p0
5353
break
5454
else:
55-
warnings.warn("Passwords do not match.")
55+
warnings.warn("Passwords do not match.", stacklevel=2)
5656
else:
5757
msg = "No matching passwords found. Giving up."
5858
raise ValueError(msg)
@@ -161,7 +161,9 @@ def persist_config(config_file=None, mode=0o600):
161161
os.chmod(config_file, mode)
162162
except Exception:
163163
tb = traceback.format_exc()
164-
warnings.warn(f"Failed to set permissions on {config_file}:\n{tb}", RuntimeWarning)
164+
warnings.warn(
165+
f"Failed to set permissions on {config_file}:\n{tb}", RuntimeWarning, stacklevel=2
166+
)
165167

166168

167169
def set_password(password=None, config_file=None):

jupyter_server/auth/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,4 @@ def get_anonymous_username() -> str:
166166
Get a random user-name based on the moons of Jupyter.
167167
This function returns names like "Anonymous Io" or "Anonymous Metis".
168168
"""
169-
return moons_of_jupyter[random.randint(0, len(moons_of_jupyter) - 1)]
169+
return moons_of_jupyter[random.randint(0, len(moons_of_jupyter) - 1)] # noqa

jupyter_server/base/handlers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ def authorizer(self):
224224
"https://github.com/jupyter-server/jupyter_server/blob/"
225225
"653740cbad7ce0c8a8752ce83e4d3c2c754b13cb/jupyter_server/serverapp.py"
226226
"#L234-L256",
227+
stacklevel=2,
227228
)
228229
from jupyter_server.auth import AllowAllAuthorizer
229230

@@ -245,6 +246,7 @@ def identity_provider(self):
245246
"add an identity provider to the tornado settings: "
246247
"https://github.com/jupyter-server/jupyter_server/blob/v2.0.0/"
247248
"jupyter_server/serverapp.py#L242",
249+
stacklevel=2,
248250
)
249251
from jupyter_server.auth import IdentityProvider
250252

@@ -594,10 +596,10 @@ async def prepare(self):
594596
# check for overridden get_current_user + default IdentityProvider
595597
# deprecated way to override auth (e.g. JupyterHub < 3.0)
596598
# allow deprecated, overridden get_current_user
597-
warnings.warn(
599+
warnings.warn( # noqa
598600
"Overriding JupyterHandler.get_current_user is deprecated in jupyter-server 2.0."
599601
" Use an IdentityProvider class.",
600-
DeprecationWarning,
602+
DeprecationWarning
601603
# stacklevel not useful here
602604
)
603605
user = self.get_current_user()
@@ -984,7 +986,7 @@ def get_absolute_path(cls, roots, path):
984986

985987
def validate_absolute_path(self, root, absolute_path):
986988
"""check if the file should be served (raises 404, 403, etc.)"""
987-
if absolute_path == "":
989+
if not absolute_path:
988990
raise web.HTTPError(404)
989991

990992
for root in self.root:

jupyter_server/extension/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def get_loader(obj, logger=None):
5353
"name will be deprecated in future releases "
5454
"of Jupyter Server.".format(name=obj),
5555
DeprecationWarning,
56+
stacklevel=2,
5657
)
5758
return func
5859

jupyter_server/gateway/handlers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from .managers import GatewayClient
2323

2424
# Keepalive ping interval (default: 30 seconds)
25-
GATEWAY_WS_PING_INTERVAL_SECS = int(os.getenv("GATEWAY_WS_PING_INTERVAL_SECS", 30))
25+
GATEWAY_WS_PING_INTERVAL_SECS = int(os.getenv("GATEWAY_WS_PING_INTERVAL_SECS", "30"))
2626

2727

2828
class WebSocketChannelsHandler(WebSocketHandler, JupyterHandler):
@@ -229,7 +229,7 @@ async def _read_messages(self, callback):
229229

230230
# NOTE(esevan): if websocket is not disconnected by client, try to reconnect.
231231
if not self.disconnected and self.retry < GatewayClient.instance().gateway_retry_max:
232-
jitter = random.randint(10, 100) * 0.01
232+
jitter = random.randint(10, 100) * 0.01 # noqa
233233
retry_interval = (
234234
min(
235235
GatewayClient.instance().gateway_retry_interval * (2**self.retry),

jupyter_server/serverapp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def random_ports(port, n):
197197
for i in range(min(5, n)):
198198
yield port + i
199199
for _ in range(n - 5):
200-
yield max(1, port + random.randint(-2 * n, 2 * n))
200+
yield max(1, port + random.randint(-2 * n, 2 * n)) # noqa
201201

202202

203203
def load_handlers(name):
@@ -1239,7 +1239,7 @@ def _default_allow_remote(self):
12391239

12401240
# if blank, self.ip was configured to "*" meaning bind to all interfaces,
12411241
# see _valdate_ip
1242-
if self.ip == "":
1242+
if self.ip == "": # noqa
12431243
return True
12441244

12451245
try:
@@ -1879,7 +1879,7 @@ def init_configurables(self):
18791879
)
18801880
# Trigger a default/validation here explicitly while we still support the
18811881
# deprecated trait on ServerApp (FIXME remove when deprecation finalized)
1882-
self.contents_manager.preferred_dir
1882+
self.contents_manager.preferred_dir # noqa
18831883
self.session_manager = self.session_manager_class(
18841884
parent=self,
18851885
log=self.log,

0 commit comments

Comments
 (0)