Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect type hint when generating LRO from typespec #2701

Open
catalinaperalta opened this issue Jul 16, 2024 · 2 comments
Open

Incorrect type hint when generating LRO from typespec #2701

catalinaperalta opened this issue Jul 16, 2024 · 2 comments
Assignees

Comments

@catalinaperalta
Copy link
Member

catalinaperalta commented Jul 16, 2024

typespec-python: 0.25.0

The health insights service defined an LRO in the following way in tsp: https://github.com/Azure/azure-rest-api-specs/blob/5046b2ea8ec0a7701990de74feee1d357114ca7a/specification/ai/HealthInsights/HealthInsights.RadiologyInsights/route.radiologyinsights.tsp#L25

This definition is an acceptable representation of service behavior in tsp (confirmed with @johanste ). However, our internal LRO code is a bit smarter and tries to return the content of the result property of the response envelope. This behavior is ok for client libraries, however we need to make sure we're returning the correct type hint in the method signature when we do this, so we don't run into typing checking bugs.

Current method signature:

def begin_infer_radiology_insights(
        self,
        id: str,
        resource: _models.RadiologyInsightsJob,
        *,
        expand: Optional[List[str]] = None,
        content_type: str = "application/json",
        **kwargs: Any
    ) -> LROPoller[_models.RadiologyInsightsJob]:

Expected method signature:

def begin_infer_radiology_insights(
        self,
        id: str,
        resource: _models.RadiologyInsightsJob,
        *,
        expand: Optional[List[str]] = None,
        content_type: str = "application/json",
        **kwargs: Any
    ) -> LROPoller[_models.RadiologyInsightsInferenceResult]:

A related issue is allowing service partners to specify if they want the parent envelope type returned instead of the type of the result property (Azure/typespec-azure#1167)

@msyyc msyyc self-assigned this Jul 16, 2024
@msyyc
Copy link
Member

msyyc commented Jul 16, 2024

It is bug of getLroMetadata in TCGC:
image

the logicalResult shall be RadiologyInsightsInferenceResult instead of RadiologyInsightsJob

@msyyc
Copy link
Member

msyyc commented Jul 16, 2024

It is known issue Azure/typespec-azure#787 and before typespec-azure-core support/fix, we will have to customize it manually @catalinaperalta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants