Skip to content

ty reports urllib.parse.urlunparse as returning Literal[b""] #733

@charliermarsh

Description

@charliermarsh

Given:

import urllib.parse


def func(url: str) -> str:
    parsed = urllib.parse.urlparse(url)
    return urllib.parse.urlunparse(parsed)

Returns:

error[invalid-return-type]: Return type does not match returned value
 --> main.py:4:23
  |
4 | def func(url: str) -> str:
  |                       --- Expected `str` because of return type
5 |     parsed = urllib.parse.urlparse(url)
6 |     return urllib.parse.urlunparse(parsed)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `str`, found `Literal[b""]`
  |
info: rule `invalid-return-type` is enabled by default

Found 1 diagnostic

Metadata

Metadata

Assignees

Labels

ProtocolsgenericsBugs or features relating to ty's generics implementation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions