Azure / Azure/azure-sdk-tools

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

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

Description

**Bad code snippet:**
```python
file_mode: Optional[str] = ...
```

**Description:**
The APIView parser is incorrectly rendering type annotations for parameters that should use `Literal` values. String literal values are not quoted, making it unclear that they are string literals for type checking purposes.

**Expected behavior:**
Literal values should be quoted to clearly indicate string literals in type annotations.

**Good code snippet:**
```python
file_mode: Optional[Literal['New', 'Restore']] = ...
```

Contributor guide

Open the contributing guide

Research direction

Start with the APIView parser and its handling of Python type annotations, using the bad and good snippets as the reproduction. Trace how Literal values are rendered and add or update coverage for quoted string values. Done means the output matches the expected Literal['New', 'Restore'] form.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.