Skip to content

Commit 5633b95

Browse files
committed
minor refactor
1 parent d020b88 commit 5633b95

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

sphinxcontrib/needs/api/need.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,12 @@ def run():
207207

208208
# Handle status
209209
# Check if status is in needs_statuses. If not raise an error.
210-
if config.needs_statuses:
211-
if status not in [stat["name"] for stat in config.needs_statuses]:
212-
raise NeedsStatusNotAllowed(
213-
"Status {0} of need id {1} is not allowed "
214-
"by config value 'needs_statuses'.".format(status, need_id)
215-
)
210+
allowed_status_names = (s["name"] for s in config.needs_statuses)
211+
if config.needs_statuses and status not in allowed_status_names:
212+
raise NeedsStatusNotAllowed(
213+
"Status {0} of need id {1} is not allowed "
214+
"by config value 'needs_statuses'.".format(status, need_id)
215+
)
216216

217217
allowed_tags: Optional[List[str]] = None
218218
if config.needs_tags:
@@ -307,11 +307,13 @@ def run():
307307
link_type["option"] not in list(kwargs.keys())
308308
or len(str(kwargs[link_type["option"]])) == 0
309309
):
310-
# If it is in global option, value got already set during prior handling of them
310+
# If it is in global option, value got already set during prior handling of
311+
# them
311312
links_string = needs_info[link_type["option"]]
312313
links = utils.read_in_links(links_string)
313314
else:
314-
# if it is set in kwargs, take this value and maybe override set value from global_options
315+
# if it is set in kwargs, take this value and maybe override set value from
316+
# global_options
315317
links_string = kwargs[link_type["option"]]
316318
links = utils.read_in_links(links_string)
317319

sphinxcontrib/needs/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,4 +299,4 @@ def fix_list_dyn_func(list: Iterable[str]) -> List[str]:
299299
# Looks like it isn't a cut dyn_func, just add.
300300
else:
301301
new_list.append(element)
302-
return new_list
302+
return new_list

0 commit comments

Comments
 (0)