Skip to content

Commit

Permalink
Fix showing default value in documentation.
Browse files Browse the repository at this point in the history
Affects `Get Fron Dictionary` and `Pop From Dictionery`. Fixes #5032.
  • Loading branch information
pekkaklarck committed Jan 31, 2024
1 parent e641a90 commit 67a902d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
7 changes: 5 additions & 2 deletions atest/robot/libdoc/LibDocLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ def get_repr_from_arg_model(self, model):
return str(ArgInfo(kind=model['kind'],
name=model['name'],
type=self._get_type_info(model['type']),
default=model['default'] or NOT_SET))
default=self._get_default(model['default'])))

def get_repr_from_json_arg_model(self, model):
return str(ArgInfo(kind=model['kind'],
name=model['name'],
type=self._get_type_info(model['type']),
default=model['defaultValue'] or NOT_SET))
default=self._get_default(model['defaultValue'])))

def _get_type_info(self, data):
if not data:
Expand All @@ -82,3 +82,6 @@ def _get_type_info(self, data):
return TypeInfo.from_string(data)
nested = [self._get_type_info(n) for n in data.get('nested', ())]
return TypeInfo(data['name'], None, nested=nested or None)

def _get_default(self, data):
return data if data is not None else NOT_SET
5 changes: 5 additions & 0 deletions atest/robot/libdoc/python_library.robot
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,8 @@ Deprecation
...
... RF and Libdoc don't consider this being deprecated.
Keyword Should Not Be Deprecated 3

NOT_SET as default value
Run Libdoc And Parse Output Collections
Keyword Name Should Be 17 Get From Dictionary
Keyword Arguments Should Be 17 dictionary key default=
7 changes: 5 additions & 2 deletions src/robot/libraries/Collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
from itertools import chain

from robot.api import logger
from robot.utils import (get_error_message, is_dict_like, is_list_like, Matcher,
NOT_SET, plural_or_not as s, seq2str, seq2str2, type_name)
from robot.utils import (is_dict_like, is_list_like, Matcher, NotSet,
plural_or_not as s, seq2str, seq2str2, type_name)
from robot.utils.asserts import assert_equal
from robot.version import get_version


NOT_SET = NotSet()


class _List:

def convert_to_list(self, item):
Expand Down
2 changes: 1 addition & 1 deletion src/robot/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
from .misc import (classproperty, isatty, parse_re_flags, plural_or_not,
printable_name, seq2str, seq2str2, test_or_task)
from .normalizing import normalize, normalize_whitespace, NormalizedDict
from .notset import NOT_SET
from .notset import NOT_SET, NotSet
from .platform import PY_VERSION, PYPY, UNIXY, WINDOWS, RERAISED_EXCEPTIONS
from .recommendations import RecommendationFinder
from .robotenv import get_env_var, set_env_var, del_env_var, get_env_vars
Expand Down
5 changes: 2 additions & 3 deletions src/robot/utils/notset.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class NotSet:
Can be used instead of the standard ``None`` in cases where ``None``
itself is a valid value.
Use the constant ``robot.utils.NOT_SET`` instead of creating new instances
of the class.
``robot.utils.NOT_SET`` is an instance of this class, but it in same cases
it is better to create a separate instance.
New in Robot Framework 7.0.
"""
Expand All @@ -30,4 +30,3 @@ def __repr__(self):


NOT_SET = NotSet()

0 comments on commit 67a902d

Please sign in to comment.