Azure / Azure/azure-sdk-tools

[Python APIView] Constructor parameter type is incorrectly rendered as Mapping instead of Literal

Open
#14,329 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)
144

Description

**Bad code snippet:**
```python
def __init__(self, mapping: Mapping[str, Any]) -> None
```

**Description:**
The APIView parser incorrectly renders the constructor parameter as `mapping: Mapping[str, Any]`. According to the architect's feedback, this should be rendered as a literal type for consistency, specifically:

**Good code snippet:**
```python
def __init__(self, *, type: Literal[ToolChoiceParamType.APPLY_PATCH]) -> None
```

Please update the parser to correctly render literal types in constructor parameters.

Contributor guide

Open the contributing guide

Research direction

Start with the APIView parser and reproduce the issue using the bad and good Python constructor snippets in the report. Trace how constructor parameter annotations are rendered; done means the parameter is emitted as the specified Literal type rather than Mapping[str, Any].

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.