Skip to content

Possible issue with PyYAML's load() #2886

Closed

Description

@nkantar

I'm running into a confusing error when using mypy to check a project using PyYAML.

Relevant code:

raw = yaml.load(some_str, Loader=yaml.FullLoader)

Error message (from mypy --strict):

error: Call to untyped function "load" in typed context

Yet the typeshed has:

def load(stream: Union[str, IO[str]], Loader=...) -> Any: ...

Versions:
• OS: macOS 10.14.3
• Python: 3.7.2 (installed via Homebrew)
• Pipenv: 2018.11.26
• mypy: 0.670
• PyYAML: 5.1

(If this belongs in the mypy repo, I'm happy to move it.)

Activity

  1. JelleZijlstra commented on Mar 26, 2019

    @JelleZijlstra
    Member

    This might be because Loader is untyped in typeshed.

  2. adamtheturtle commented on Jul 1, 2019

    @adamtheturtle
    Contributor

    This was fixed in #3035.

  3. AMWJ commented on Sep 30, 2022

    @AMWJ

    This doesn't appear resolved? #3035 adds no types to the load() method's Loader argument, so Loader's type remains Unknown.

    It appears #1657 attempted to resolve this incorrectly, and #1695 reverted. I think this should be re-opened until load() and load_all() are typed.

  4. Akuli commented on Oct 2, 2022

    @Akuli
    Collaborator

    Feel free to submit a PR :)

  5. reopened this on Oct 2, 2022
  6. adamtheturtle commented on Oct 2, 2022

    @adamtheturtle
    Contributor

    Apologies for my mistake.

  7. Avasam commented on Feb 20, 2023

    @Avasam
    SponsorCollaborator

    Is this fixed by #9752 ?

  8. AlexWaygood commented on Feb 21, 2023

    @AlexWaygood
    Member

    Is this fixed by #9752 ?

    Looks like it!

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

    stubs: incompleteAnnotations or sub-modules missing from an existing package or module

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions