Azure / autorest.python

Extension for AutoRest (https://github.com/Azure/autorest) that generates Python code
MIT License
79 stars 57 forks source link

[typespec-python] `accept` is not defined in generated build request method #2670

Closed swathipil closed 2 months ago

swathipil commented 3 months ago

I re-generated code from [this spec] with the most recent typespec-python version (0.24.3) and it's no longer outputting the accept = kwargs.get('Accept', ...) line when building these two requests:

https://github.com/Azure/azure-sdk-for-python/blob/44b7842a848b2413c4c8743760c7d4c5e48f355b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_operations/_operations.py#L90

https://github.com/Azure/azure-sdk-for-python/blob/44b7842a848b2413c4c8743760c7d4c5e48f355b/sdk/schemaregistry/azure-schemaregistry/azure/schemaregistry/_operations/_operations.py#L116

This results in the following error:

File "C:\Users\swathip\venvs\env311\Lib\site-packages\azure\schemaregistry\_operations\_operations.py", line 107, in build_schema_registry_get_schema_by_id_request
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")    
                                                      ^^^^^^
NameError: name 'accept' is not defined
msyyc commented 3 months ago

It is a bug and will be fixed soon.