Skip to content

Commit 89cacc1

Browse files
Enforce ruff rule RUF019
RUF019 Unnecessary key check before dictionary access
1 parent 042f9ca commit 89cacc1

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

fsspec/implementations/gist.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,16 @@ def _get_kwargs_from_urls(path):
141141
"""
142142
so = infer_storage_options(path)
143143
out = {}
144-
if "username" in so and so["username"]:
144+
if so.get("username"):
145145
out["username"] = so["username"]
146-
if "password" in so and so["password"]:
146+
if so.get("password"):
147147
out["token"] = so["password"]
148-
if "host" in so and so["host"]:
148+
if so.get("host"):
149149
# We interpret 'host' as the gist ID
150150
out["gist_id"] = so["host"]
151151

152152
# Extract SHA and filename from path
153-
if "path" in so and so["path"]:
153+
if so.get("path"):
154154
path_parts = so["path"].rsplit("/", 2)[-2:]
155155
if len(path_parts) == 2:
156156
if path_parts[0]: # SHA present

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ select = [
179179
"RUF006",
180180
"RUF012",
181181
"RUF015",
182+
"RUF019",
182183
"RUF024",
183184
"SIM",
184185
"SLOT",

0 commit comments

Comments
 (0)