`--report-glean` names a method on a `Literal` or `LiteralString` receiver without its class (`title`, not `str.title`)
Summary
In the --report-glean output, a method call on a receiver typed as a Literal or LiteralString names the callee without its class: title instead of str.title. The same call on a plain str receiver is named str.title. The bare name appears in python.CalleeToCaller.4 and in the python.xrefs.XRefsByFile.1 target at the method token. This makes a consumer unable to tell str.title from any other function named title.
The behaviour is the same in 1.2.0 and 1.4.0. In 1.4.0 it reaches more code, because a StrEnum member's .value is now inferred as a literal. So self.value.title() changed from str.title in 1.2.0 to title in 1.4.0.
Reproduction
repro.py:
from enum import StrEnum
from typing import Literal, LiteralString
def plain(word: str) -> str:
return word.title()
def literal(word: Literal["red"]) -> str:
return word.title()
def literal_string(word: LiteralString) -> str:
return word.title()
def joined(parts: list[str]) -> str:
return ", ".join(parts)
class Colour(StrEnum):
RED = "red"
def label(self) -> str:
return self.value.title()
pyrefly check --report-glean out/ repro.py
Callee per caller, read from python.CalleeToCaller.4:
| Caller | 1.2.0 | 1.4.0 | Expected |
|---|---|---|---|
repro.plain |
str.title |
str.title |
str.title |
repro.literal |
title |
title |
str.title |
repro.literal_string |
title |
title |
str.title |
repro.joined |
join |
join |
str.join |
repro.Colour.label |
str.title |
title |
str.title |
Expected
A method resolved through a Literal[...] or LiteralString receiver is named by the class that defines it (str.title, str.join), the same as for a plain str receiver. The literal type promotes to its class for attribute lookup, so the qualified name is available.
Environment
pyrefly 1.2.0 and 1.4.0 (installed with uv tool), macOS, Python 3.13. Default config: no pyrefly.toml, no other flags.
Looks like we're missing literal handling here: https://github.com/meta/pyrefly/blob/9f8d4de232a00fff74a397763053ac8f454452a7/pyrefly/lib/report/glean/convert.rs#L1003
#claim
@Quaden2307 you've claimed this issue — it's now assigned to you. Thanks for picking it up! 🎉