Skip to content

Detect missing typeshed packages #1279

@tobiashenkel

Description

@tobiashenkel

Original bug report - Pyrefly type inference doesn't work on the raw PyYAML library

Describe the Bug

When running a type check with pyrefy check test.py, I expect to see no error, but I get this:

Test script:

import yaml

def test_function() -> str:
    return yaml.safe_dump({'key': 'value'})

Pyrefly output:

ERROR Returned type `bytes | str | None` is not assignable to declared return type `str` [bad-return]
 --> test.py:5:12
  |
5 |     return yaml.safe_dump({'key': 'value'})
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
 INFO 1 error

Versions used:

  • pyrefly: 0.36.2
  • pyyaml: 6.0.3

Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIEAtsbgE4AuABKalVADrpdeYxhMG8BgH0wAV3QBjBhFzoAFAEomAWgB8TOAzqIuTA0zowG4uuhZsohNGBgjM4mguAByANYxSrxE1cA3VChxGFcAXyUuEAAaEHFZKDgSckQQAGImAFUEiAZSJglpWXk4Hix%2BAvoqVFF0J2wYOgV8Xwh0BhUNLR09C0NjU3MCjhAAOXrG32B8MJGo2LJjMChSQgZcdgoMgAVSJZWtDBwCJil5SABzMxq5dEIuDIBlGBgmAAsGBmI4RAB6X8W-BWhHoF1%2BMHQv0wuCkcF%2BZ3Ql2uxUhlToTFQgWgqGwsFO5wgVzoN3kTFwxBRSS4ZAYb3kqn8jTgtyYAF4mCMAMyEACMACY5ugQGFYqgZBBGQAxaAwChoLB4IhkYVAA

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions