Skip to navigation

Python configuration

View as Markdown

Configure the Python SDK in the generation block of its target in sdk-config.yml:

sdk-config.yml
targets:
- language: python
generation:
naming:
clientName: YourClientName
followRedirectsByDefault: true
alwaysInitializeOptionals: true
useTypedDictRequests: true

The target’s generation block also accepts the shared generation options, such as naming, wireTests, and customCode. Shared options set in the top-level generation block apply to every target, and a target’s generation block overrides them. For generators.yml options, see the Legacy Python configuration.

Python options

pythonVersion
string

The Python version targeted by the generated project.

pydanticVersion
string

The Pydantic dependency version requirement.

pydantic
object

Pydantic model-generation behavior.

<ParamField path=“pydantic.versionCompatibility” type=""v1” | “v2” | “both” | “v1-on-v2"" required= toc=> The Pydantic major versions supported by generated models. </ParamField>

pydantic.frozen
boolean

Whether generated Pydantic models are immutable.

pydantic.requireOptionalFields
boolean

Whether Optional fields remain required unless they declare a default.

<ParamField path=“pydantic.unionNaming” type=""v0” | “v1"" required= toc=> The naming strategy for generated union types. </ParamField>

pydantic.useFieldAliases
boolean

Whether Pydantic field aliases preserve wire names.

client
object

Python client file naming.

client.fileName
string

The source file name for the Python client.

client.exportedFileName
string

The file name used when exporting the Python client.

followRedirectsByDefault
boolean

Whether generated HTTP clients follow redirects by default.

defaultBytesStreamChunkSize
number

The default byte-stream iterator chunk size.

recursionLimit
number

The Python recursion limit installed when the generated package is imported.

extras
object

Published Python extras and their dependency names.

alwaysInitializeOptionals
boolean

Whether optional model fields are initialized even when omitted.

useTypedDictRequests
boolean

Whether request bodies are generated as TypedDict types.

additionalInitExports
list of object

Additional names re-exported from the package initializer.