Skip to content

Using typing hints or keyword-only-arguments prevents using function as keyword #2627

Closed

Description

@kbfu

Let's say I have a simple library named typing.py:

def typing_hint(hint: str):
    print(hint)


def no_typing_hint(hint):
    print(hint)

Then I will import this library in typing.robot like below:

*** Settings ***
Library     typing

*** Test Cases ***
Typing Check
    No typing hint  hint
    Typing hint  hint

Finally, exception throws with no keyword named 'Typing hint' found.
image

Seems like in argumentsparser.py, a deprecated method called getargspec is the root cause. My guess is this method is unable to analyze the new syntax.

class PythonArgumentParser(_ArgumentParser):

    def _get_arg_spec(self, handler):
        args, varargs, kwargs, defaults = inspect.getargspec(handler) # here, replace this with the new method getfullargspec().
        if inspect.ismethod(handler) or handler.__name__ == '__init__':
            args = args[1:]  # drop 'self'
        defaults = list(defaults) if defaults else []
        return args, defaults, varargs, kwargs

I have submit a pull request #2625 to fix this issue.

Activity

  1. self-assigned this
    on Jun 28, 2017
  2. added this to the milestone on Jun 28, 2017
  3. changed the title [-]No keyword error is raised when call the function with typing hint[/-] [+]Using typing hints prevents using function as keyword[/+] on Jun 28, 2017
  4. pekkaklarck commented on Jun 28, 2017

    @pekkaklarck
    Member

    This is somewhat related to keyword-only-arguments support covered by issue #2555.

  5. Kompakti commented on Jan 19, 2018

    @Kompakti
    Contributor

    I'll start to work on this.

  6. added 2 commits that reference this issue on Jan 19, 2018
    d5819dd
    a46630e
  7. changed the title [-]Using typing hints prevents using function as keyword[/-] [+]Using typing hints or keyword-only-arguments prevents using function as keyword[/+] on Feb 23, 2018
  8. pekkaklarck commented on Feb 23, 2018

    @pekkaklarck
    Member

    This has been fixed by PR #2751.

  9. added theissue type on Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions