Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

param:Optional[x] = None type hint behaves differently than Robot Framework #64

Closed
@mkorpela

Description

Please add the following "hacky" Optional removal to

return hints
 def _remove_optional_none_type_hints(self, type_hints, defaults):
 # If argument has None as a default, typing.get_type_hints adds
 # optional None to the information it returns. We don't want that.
 for arg in defaults:
 if defaults[arg] is None and arg in type_hints:
 type_ = type_hints[arg]
 if self._is_union(type_):
 try:
 types = type_.__args__
 except AttributeError:
 # Python 3.5.2's typing uses __union_params__ instead
 # of __args__. This block can likely be safely removed
 # when Python 3.5 support is dropped
 types = type_.__union_params__
 if len(types) == 2 and types[1] is type(None):
 type_hints[arg] = types[0]

https://github.com/robotframework/robotframework/blob/5dc9affd4aee31703a58ad105ed49579b1ca7067/src/robot/running/arguments/argumentparser.py#L101

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    AltStyle によって変換されたページ (->オリジナル) /