Skip to content

[Bug]: [typing] "_models" in typing annotation confuses sphinx #6152

Open
@xiangyan99

Description

@xiangyan99

Describe the bug

This is transferred from Azure/autorest.python#2964

we add "_models." in our generated code.

e.g.

def init(
self,
*,
vectorizer_name: str,
ai_services_vision_parameters: Optional["_models.AIServicesVisionParameters"] = None,
**kwargs: Any
) -> None:

The reason is to avoid name conflicts. we've had issues in the past, for example, if an enum is named the same thing as a model, by tying it to _models (we also make it private so we're not exposing anything), we avoid naming conflicts.

Unfortunately, Sphinx cannot parse the model "_models.AIServicesVisionParameters" correctly.

In Sphinx generated code, it shows
_models.SearchIndexerDataIdentity
and loses xref.

We need to find some other ways to solve the name conflicts.

Reproduction

As above

Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingemitter:client:pythonIssue for the Python client emitter: @typespec/http-client-python

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions