Azure / Azure/azure-sdk-tools

[Python APIView] Literal values in type annotations are not quoted as strings

Open
#14,330 0 comments 0 reactions 0 assignees View on GitHub
APIView customer-reported Python question
Dominant language
C#
Stars
135
Forks
260
Avg merge
3d 2h
Merged PRs (30d)
130

Description

**Bad code snippet:**
```python
type: Optional[Union[Literal[builtin], Literal[custom], Literal[all], str]] = ...
```

**Description:**
The APIView parser is incorrectly rendering Literal values in type annotations without quotes. According to Python typing guidelines, Literal values representing strings must be quoted to ensure correctness and proper type checking.

**Good code snippet:**
```python
type: Optional[Union[Literal['builtin'], Literal['custom'], Literal['all'], str]] = ...
```

Please update the parser to render string Literal values with quotes.

Contributor guide

Open the contributing guide

Research direction

Start in the APIView parser and reproduce the issue with the bad Python annotation shown in the report. Compare its rendered output with the good snippet; done means string values inside Literal annotations are rendered with quotes, while the surrounding annotation remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.