Skip to content

Commit

Permalink
[cdd/docstring/utils/parse_utils.py] Guard word length ; [cdd/shared/…
Browse files Browse the repository at this point in the history
…ast_utils.py] Guard no default ; [cdd/tests/test_utils_for_tests.py] `tensorboard_doc_str_no_args_str` -> `tensorboard_doc_str_no_args_str.rstrip(" ")`
  • Loading branch information
SamuelMarks committed Nov 26, 2023
1 parent 85b24a2 commit 5bda68b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cdd/docstring/utils/parse_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def parse_adhoc_doc_for_typ(doc, name):

if candidate_type is not None:
return candidate_type
elif "/" in words[2]:
elif len(words) > 2 and "/" in words[2]:
return "Union[{}]".format(",".join(sorted(words[2].split("/"))))

return None
Expand Down
2 changes: 1 addition & 1 deletion cdd/shared/ast_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def param2ast(param):
# )
elif needs_quoting(_param["typ"]):
val = (
_param["default"]
_param.get("default")
if _param.get("default") in (None, NoneStr)
else quote(_param["default"])
)
Expand Down
2 changes: 1 addition & 1 deletion cdd/tests/test_shared/test_ast_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ def test_merge_modules(self) -> None:
)
)

def test_optimise_imports(self):
def test_optimise_imports(self) -> None:
"""Tests that `optimise_imports` deduplicates"""
run_ast_test(
self,
Expand Down
2 changes: 1 addition & 1 deletion cdd/tests/test_sqlalchemy/test_emit_sqlalchemy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_ensure_has_primary_key_from_id(self) -> None:
ir["params"]["id"]["doc"] = "[PK] {}".format(ir["params"]["id"]["doc"])
self.assertDictEqual(res, ir)

def test_generate_create_from_attr_staticmethod(self):
def test_generate_create_from_attr_staticmethod(self) -> None:
"""Tests that `generate_create_from_attr` staticmethod is correctly constructed"""
run_ast_test(
self,
Expand Down
2 changes: 1 addition & 1 deletion cdd/tests/test_utils_for_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_remove_args_from_docstring(self) -> None:
"""
self.assertEqual(
remove_args_from_docstring(tensorboard_doc_str),
tensorboard_doc_str_no_args_str,
tensorboard_doc_str_no_args_str.rstrip(" "),
)


Expand Down

0 comments on commit 5bda68b

Please sign in to comment.