Skip to content

Type hints for Element.walk are incorrect #259

Description

@castedo

def walk(self, action: Callable[[Element, Element], Any], doc: Element | None=None, stop_if=None) -> Element | None:

The action function:

  • parameter takes [Element, Doc] as arguments not [Element, Element]
  • returns an Element, typing Any isn't very useful

The doc parameter take a Doc not an Element.

The documentation/helpstring for this function says an empty list can be returned. This type hint says it can not. What is correct. Can an empty list be returned or not?

Also the Element.doc method type hint returns Any | Element. But it should be Doc shouldn't it?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions