facebook / facebook/pyrefly

Does not parse type annotations with nested quotes: `x: "list[\"int\"]"`

Open
#3,006 2 comments 0 reactions 0 assignees View on GitHub
typechecking typing-spec
Dominant language
Rust
Stars
7k
Forks
519
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

I'm not sure if there's a standard, but apparently mypy, pyright and pydantic all accept type annotations with nested quotes like `x: "list[\"int\"]"`. Pyrefly raises an "Expected a type form, got instance of `Literal['int']`" error.

- https://pyright-play.net/?strict=true&code=IYLgBANglgzgLgbSgOzgXTAXjAtAoAI3GngQCIU4yNtc8BjY2RAckpZp3wBNwWTEFVNRZYueAKbgyAhAB0hcBWjJi6AM2mzKKtfiA
- https://mypy-play.net/?gist=30975017f4ade21f3750499e6578b486
- pydantic: `TypeAdapter("list[\"int\"]").validate_python([1, 2, 3])`

This occurred in a scenario, where we want to automatically stringify annotations in the source code.

### Sandbox Link

_No response_

### (Only applicable for extension issues) IDE Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.