Skip to content

Fix Python schema generation for fields named int or bool#64

Merged
negz merged 1 commit into
crossplane:mainfrom
negz:buuump
Jun 4, 2026
Merged

Fix Python schema generation for fields named int or bool#64
negz merged 1 commit into
crossplane:mainfrom
negz:buuump

Conversation

@negz
Copy link
Copy Markdown
Member

@negz negz commented Jun 3, 2026

Description of your changes

Fixes #63

crossplane project build generates broken Python models when an XRD has a property literally named int or bool (for example when modelling DRA's DeviceAttribute, whose wire fields are int/bool/string/version). The generated models reference undefined type aliases int_aliased and bool_aliased, which makes them unimportable:

PydanticUserError: `ObjectMeta` is not fully defined; you should define `int_aliased`, then call `ObjectMeta.model_rebuild()`.

The undefined aliases are emitted by the pinned code generator image docker.io/koxudaxi/datamodel-code-generator:0.31.2. The CLI worked around this with fixAliasedTypesInFile, which text-replaced the broken aliases, but it only ran in the OpenAPI generation path — not the XRD/CRD path that project build uses — so XRD-derived models and the shared meta/v1.py kept the broken references.

The underlying code generator bug is fixed upstream in koxudaxi/datamodel-code-generator#2968, first released in 0.54.0, which sanitizes builtin-conflicting field names by appending a trailing underscore and preserving the wire name via a Pydantic alias. A field named int now generates as int_: int | None = Field(None, alias='int').

This PR bumps the pinned image to 0.59.0, fixing the broken output at its source. With the fix in place fixAliasedTypesInFile no longer matches anything, so it is removed along with the postProcessFile wrapper, leaving both generation paths to call adjustImportsInFile directly.

I have:

  • Read and followed Crossplane's contribution process.
  • Run ./nix.sh flake check to ensure this PR is ready for review.
  • Added or updated unit tests. The Python generator's image-backed output is not currently covered by automated tests; see the draft note above.
  • Linked a PR or a docs tracking issue to document this change.
  • Added backport release-x.y labels to auto-backport this PR.

Need help with this checklist? See the cheat sheet.

crossplane project build generates broken Python models when an XRD has
a property literally named int or bool. The generated models reference
undefined type aliases int_aliased and bool_aliased, which makes the
models unimportable:

    PydanticUserError: `ObjectMeta` is not fully defined; you should
    define `int_aliased`, then call `ObjectMeta.model_rebuild()`.

The undefined aliases are emitted by the pinned code generator image
docker.io/koxudaxi/datamodel-code-generator:0.31.2. The CLI worked
around this with fixAliasedTypesInFile, which text-replaced the broken
aliases, but it only ran in the OpenAPI generation path - not the
XRD/CRD path that project build uses - so XRD-derived models and the
shared meta/v1.py kept the broken references.

The underlying code generator bug is fixed upstream in 0.54.0, which
sanitizes builtin-conflicting field names by appending a trailing
underscore and preserving the wire name via a Pydantic alias. Fields
named int now generate as `int_: int | None = Field(None, alias='int')`.

This commit bumps the pinned image to 0.59.0, which fixes the broken
output at its source. With the fix in place fixAliasedTypesInFile no
longer matches anything, so this commit removes it along with the
postProcessFile wrapper, leaving both generation paths to call
adjustImportsInFile directly.

Fixes crossplane#63.

Signed-off-by: Nic Cope <nicc@rk0n.org>
@negz
Copy link
Copy Markdown
Member Author

negz commented Jun 3, 2026

Here are the full diffs (vs the pre-regeneration commit), for a provider CRD schema (provider-gcp-compute's Subnetwork) and meta/v1. The Subnetwork has no int/bool fields, so it doesn't exercise the fix itself — these show the incidental codegen changes from the image bump.

io/upbound/m/gcp/compute/subnetwork/v1beta1.py
diff --git a/schemas/python/models/io/upbound/m/gcp/compute/subnetwork/v1beta1.py b/schemas/python/models/io/upbound/m/gcp/compute/subnetwork/v1beta1.py
index 977466d..34c9050 100644
--- a/schemas/python/models/io/upbound/m/gcp/compute/subnetwork/v1beta1.py
+++ b/schemas/python/models/io/upbound/m/gcp/compute/subnetwork/v1beta1.py
@@ -3,16 +3,15 @@
 
 from __future__ import annotations
 
-from datetime import datetime
-from typing import Dict, List, Literal, Optional
+from typing import Literal
 
-from pydantic import BaseModel, Field
+from pydantic import AwareDatetime, BaseModel, Field
 
 from ......k8s.apimachinery.pkg.apis.meta import v1
 
 
 class LogConfig(BaseModel):
-    aggregationInterval: Optional[str] = None
+    aggregationInterval: str | None = None
     """
     Can only be specified if VPC flow logging for this subnetwork is enabled.
     Toggles the aggregation interval for collecting flow logs. Increasing the
@@ -21,13 +20,13 @@ class LogConfig(BaseModel):
     Default value is INTERVAL_5_SEC.
     Possible values are: INTERVAL_5_SEC, INTERVAL_30_SEC, INTERVAL_1_MIN, INTERVAL_5_MIN, INTERVAL_10_MIN, INTERVAL_15_MIN.
     """
-    filterExpr: Optional[str] = None
+    filterExpr: str | None = None
     """
     Export filter used to define which VPC flow logs should be logged, as as CEL expression. See
     https://cloud.google.com/vpc/docs/flow-logs#filtering for details on how to format this field.
     The default value is 'true', which evaluates to include everything.
     """
-    flowSampling: Optional[float] = None
+    flowSampling: float | None = None
     """
     Can only be specified if VPC flow logging for this subnetwork is enabled.
     The value of the field must be in [0, 1]. Set the sampling rate of VPC
@@ -35,7 +34,7 @@ class LogConfig(BaseModel):
     reported and 0.0 means no logs are reported. Default is 0.5 which means
     half of all collected logs are reported.
     """
-    metadata: Optional[str] = None
+    metadata: str | None = None
     """
     Can only be specified if VPC flow logging for this subnetwork is enabled.
     Configures whether metadata fields should be added to the reported VPC
@@ -43,7 +42,7 @@ class LogConfig(BaseModel):
     Default value is INCLUDE_ALL_METADATA.
     Possible values are: EXCLUDE_ALL_METADATA, INCLUDE_ALL_METADATA, CUSTOM_METADATA.
     """
-    metadataFields: Optional[List[str]] = None
+    metadataFields: list[str] | None = None
     """
     List of metadata fields that should be added to reported logs.
     Can only be specified if VPC flow logs for this subnetwork is enabled and "metadata" is set to CUSTOM_METADATA.
@@ -51,14 +50,14 @@ class LogConfig(BaseModel):
 
 
 class Policy(BaseModel):
-    resolution: Optional[Literal['Required', 'Optional']] = 'Required'
+    resolution: Literal['Required', 'Optional'] | None = 'Required'
     """
     Resolution specifies whether resolution of this reference is required.
     The default is 'Required', which means the reconcile will fail if the
     reference cannot be resolved. 'Optional' means this reference will be
     a no-op if it cannot be resolved.
     """
-    resolve: Optional[Literal['Always', 'IfNotPresent']] = None
+    resolve: Literal['Always', 'IfNotPresent'] | None = None
     """
     Resolve specifies when this reference should be resolved. The default
     is 'IfNotPresent', which will attempt to resolve the reference only when
@@ -72,38 +71,38 @@ class NetworkRef(BaseModel):
     """
     Name of the referenced object.
     """
-    namespace: Optional[str] = None
+    namespace: str | None = None
     """
     Namespace of the referenced object
     """
-    policy: Optional[Policy] = None
+    policy: Policy | None = None
     """
     Policies for referencing.
     """
 
 
 class NetworkSelector(BaseModel):
-    matchControllerRef: Optional[bool] = None
+    matchControllerRef: bool | None = None
     """
     MatchControllerRef ensures an object with the same controller reference
     as the selecting object is selected.
     """
-    matchLabels: Optional[Dict[str, str]] = None
+    matchLabels: dict[str, str] | None = None
     """
     MatchLabels ensures an object with matching labels is selected.
     """
-    namespace: Optional[str] = None
+    namespace: str | None = None
     """
     Namespace for the selector
     """
-    policy: Optional[Policy] = None
+    policy: Policy | None = None
     """
     Policies for selection.
     """
 
 
 class Params(BaseModel):
-    resourceManagerTags: Optional[Dict[str, str]] = None
+    resourceManagerTags: dict[str, str] | None = None
     """
     Resource manager tags to be bound to the subnetwork. Tag keys and values have the
     same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id},
@@ -115,7 +114,7 @@ class Params(BaseModel):
 
 
 class SecondaryIpRangeItem(BaseModel):
-    ipCidrRange: Optional[str] = None
+    ipCidrRange: str | None = None
     """
     The range of IP addresses belonging to this subnetwork secondary
     range. Provide this property when you create the subnetwork.
@@ -123,14 +122,14 @@ class SecondaryIpRangeItem(BaseModel):
     secondary IP ranges within a network. Only IPv4 is supported.
     Field is optional when reserved_internal_range is defined, otherwise required.
     """
-    rangeName: Optional[str] = None
+    rangeName: str | None = None
     """
     The name associated with this subnetwork secondary range, used
     when adding an alias IP range to a VM instance. The name must
     be 1-63 characters long, and comply with RFC1035. The name
     must be unique within the subnetwork.
     """
-    reservedInternalRange: Optional[str] = None
+    reservedInternalRange: str | None = None
     """
     The ID of the reserved internal range. Must be prefixed with networkconnectivity.googleapis.com
     E.g. networkconnectivity.googleapis.com/projects/{project}/locations/global/internalRanges/{rangeId}
@@ -138,24 +137,24 @@ class SecondaryIpRangeItem(BaseModel):
 
 
 class ForProvider(BaseModel):
-    description: Optional[str] = None
+    description: str | None = None
     """
     An optional description of this resource. Provide this property when
     you create the resource. This field can be set only at resource
     creation time.
     """
-    enableFlowLogs: Optional[bool] = None
+    enableFlowLogs: bool | None = None
     """
     Whether to enable flow logging for this subnetwork. If this field is not explicitly set,
     it will not appear in get listings. If not set the default behavior is determined by the
     org policy, if there is no org policy specified, then it will default to disabled.
     This field isn't supported if the subnet purpose field is set to REGIONAL_MANAGED_PROXY.
     """
-    externalIpv6Prefix: Optional[str] = None
+    externalIpv6Prefix: str | None = None
     """
     The range of external IPv6 addresses that are owned by this subnetwork.
     """
-    ipCidrRange: Optional[str] = None
+    ipCidrRange: str | None = None
     """
     The range of internal addresses that are owned by this subnetwork.
     Provide this property when you create the subnetwork. For example,
@@ -163,7 +162,7 @@ class ForProvider(BaseModel):
     non-overlapping within a network. Only IPv4 is supported.
     Field is optional when reserved_internal_range is defined, otherwise required.
     """
-    ipCollection: Optional[str] = None
+    ipCollection: str | None = None
     """
     Resource reference of a PublicDelegatedPrefix. The PDP must be a sub-PDP
     in EXTERNAL_IPV6_SUBNETWORK_CREATION mode.
@@ -171,14 +170,14 @@ class ForProvider(BaseModel):
     IPv6 NetLB forwarding rule using BYOIP:
     Full resource URL, as in:
     """
-    ipv6AccessType: Optional[str] = None
+    ipv6AccessType: str | None = None
     """
     The access type of IPv6 address this subnet holds. It's immutable and can only be specified during creation
     or the first time the subnet is updated into IPV4_IPV6 dual stack. If the ipv6_type is EXTERNAL then this subnet
     cannot enable direct path.
     Possible values are: EXTERNAL, INTERNAL.
     """
-    logConfig: Optional[LogConfig] = None
+    logConfig: LogConfig | None = None
     """
     This field denotes the VPC flow logging options for this subnetwork. If
     logging is enabled, logs are exported to Cloud Logging. Flow logging
@@ -186,39 +185,39 @@ class ForProvider(BaseModel):
     REGIONAL_MANAGED_PROXY or GLOBAL_MANAGED_PROXY.
     Structure is documented below.
     """
-    network: Optional[str] = None
+    network: str | None = None
     """
     The network this subnet belongs to.
     Only networks that are in the distributed mode can have subnetworks.
     """
-    networkRef: Optional[NetworkRef] = None
+    networkRef: NetworkRef | None = None
     """
     Reference to a Network in compute to populate network.
     """
-    networkSelector: Optional[NetworkSelector] = None
+    networkSelector: NetworkSelector | None = None
     """
     Selector for a Network in compute to populate network.
     """
-    params: Optional[Params] = None
+    params: Params | None = None
     """
     Additional params passed with the request, but not persisted as part of resource payload
     Structure is documented below.
     """
-    privateIpGoogleAccess: Optional[bool] = None
+    privateIpGoogleAccess: bool | None = None
     """
     When enabled, VMs in this subnetwork without external IP addresses can
     access Google APIs and services by using Private Google Access.
     """
-    privateIpv6GoogleAccess: Optional[str] = None
+    privateIpv6GoogleAccess: str | None = None
     """
     The private IPv6 google access type for the VMs in this subnet.
     """
-    project: Optional[str] = None
+    project: str | None = None
     """
     The ID of the project in which the resource belongs.
     If it is not provided, the provider project is used.
     """
-    purpose: Optional[str] = None
+    purpose: str | None = None
     """
     The purpose of the resource. This field can be either PRIVATE, REGIONAL_MANAGED_PROXY, GLOBAL_MANAGED_PROXY, PRIVATE_SERVICE_CONNECT, PEER_MIGRATION or PRIVATE_NAT(Beta).
     A subnet with purpose set to REGIONAL_MANAGED_PROXY is a user-created subnetwork that is reserved for regional Envoy-based load balancers.
@@ -233,12 +232,12 @@ class ForProvider(BaseModel):
     """
     The GCP region for this subnetwork.
     """
-    reservedInternalRange: Optional[str] = None
+    reservedInternalRange: str | None = None
     """
     The ID of the reserved internal range. Must be prefixed with networkconnectivity.googleapis.com
     E.g. networkconnectivity.googleapis.com/projects/{project}/locations/global/internalRanges/{rangeId}
     """
-    role: Optional[str] = None
+    role: str | None = None
     """
     The role of subnetwork.
     Currently, this field is only used when purpose is REGIONAL_MANAGED_PROXY.
@@ -247,7 +246,7 @@ class ForProvider(BaseModel):
     A BACKUP subnetwork is one that is ready to be promoted to ACTIVE or is currently draining.
     Possible values are: ACTIVE, BACKUP.
     """
-    secondaryIpRange: Optional[List[SecondaryIpRangeItem]] = None
+    secondaryIpRange: list[SecondaryIpRangeItem] | None = None
     """
     An array of configurations for secondary IP ranges for VM instances
     contained in this subnetwork. The primary IP of such VM must belong
@@ -258,7 +257,7 @@ class ForProvider(BaseModel):
     set send_secondary_ip_range_if_empty = true
     Structure is documented below.
     """
-    sendSecondaryIpRangeIfEmpty: Optional[bool] = None
+    sendSecondaryIpRangeIfEmpty: bool | None = None
     """
     Controls the removal behavior of secondary_ip_range.
     When false, removing secondary_ip_range from config will not produce a diff as
@@ -267,7 +266,7 @@ class ForProvider(BaseModel):
     empty list of secondary IP ranges to the API.
     Defaults to false.
     """
-    stackType: Optional[str] = None
+    stackType: str | None = None
     """
     The stack type for this subnet to identify whether the IPv6 feature is enabled or not.
     If not specified IPV4_ONLY will be used.
@@ -276,24 +275,24 @@ class ForProvider(BaseModel):
 
 
 class InitProvider(BaseModel):
-    description: Optional[str] = None
+    description: str | None = None
     """
     An optional description of this resource. Provide this property when
     you create the resource. This field can be set only at resource
     creation time.
     """
-    enableFlowLogs: Optional[bool] = None
+    enableFlowLogs: bool | None = None
     """
     Whether to enable flow logging for this subnetwork. If this field is not explicitly set,
     it will not appear in get listings. If not set the default behavior is determined by the
     org policy, if there is no org policy specified, then it will default to disabled.
     This field isn't supported if the subnet purpose field is set to REGIONAL_MANAGED_PROXY.
     """
-    externalIpv6Prefix: Optional[str] = None
+    externalIpv6Prefix: str | None = None
     """
     The range of external IPv6 addresses that are owned by this subnetwork.
     """
-    ipCidrRange: Optional[str] = None
+    ipCidrRange: str | None = None
     """
     The range of internal addresses that are owned by this subnetwork.
     Provide this property when you create the subnetwork. For example,
@@ -301,7 +300,7 @@ class InitProvider(BaseModel):
     non-overlapping within a network. Only IPv4 is supported.
     Field is optional when reserved_internal_range is defined, otherwise required.
     """
-    ipCollection: Optional[str] = None
+    ipCollection: str | None = None
     """
     Resource reference of a PublicDelegatedPrefix. The PDP must be a sub-PDP
     in EXTERNAL_IPV6_SUBNETWORK_CREATION mode.
@@ -309,14 +308,14 @@ class InitProvider(BaseModel):
     IPv6 NetLB forwarding rule using BYOIP:
     Full resource URL, as in:
     """
-    ipv6AccessType: Optional[str] = None
+    ipv6AccessType: str | None = None
     """
     The access type of IPv6 address this subnet holds. It's immutable and can only be specified during creation
     or the first time the subnet is updated into IPV4_IPV6 dual stack. If the ipv6_type is EXTERNAL then this subnet
     cannot enable direct path.
     Possible values are: EXTERNAL, INTERNAL.
     """
-    logConfig: Optional[LogConfig] = None
+    logConfig: LogConfig | None = None
     """
     This field denotes the VPC flow logging options for this subnetwork. If
     logging is enabled, logs are exported to Cloud Logging. Flow logging
@@ -324,39 +323,39 @@ class InitProvider(BaseModel):
     REGIONAL_MANAGED_PROXY or GLOBAL_MANAGED_PROXY.
     Structure is documented below.
     """
-    network: Optional[str] = None
+    network: str | None = None
     """
     The network this subnet belongs to.
     Only networks that are in the distributed mode can have subnetworks.
     """
-    networkRef: Optional[NetworkRef] = None
+    networkRef: NetworkRef | None = None
     """
     Reference to a Network in compute to populate network.
     """
-    networkSelector: Optional[NetworkSelector] = None
+    networkSelector: NetworkSelector | None = None
     """
     Selector for a Network in compute to populate network.
     """
-    params: Optional[Params] = None
+    params: Params | None = None
     """
     Additional params passed with the request, but not persisted as part of resource payload
     Structure is documented below.
     """
-    privateIpGoogleAccess: Optional[bool] = None
+    privateIpGoogleAccess: bool | None = None
     """
     When enabled, VMs in this subnetwork without external IP addresses can
     access Google APIs and services by using Private Google Access.
     """
-    privateIpv6GoogleAccess: Optional[str] = None
+    privateIpv6GoogleAccess: str | None = None
     """
     The private IPv6 google access type for the VMs in this subnet.
     """
-    project: Optional[str] = None
+    project: str | None = None
     """
     The ID of the project in which the resource belongs.
     If it is not provided, the provider project is used.
     """
-    purpose: Optional[str] = None
+    purpose: str | None = None
     """
     The purpose of the resource. This field can be either PRIVATE, REGIONAL_MANAGED_PROXY, GLOBAL_MANAGED_PROXY, PRIVATE_SERVICE_CONNECT, PEER_MIGRATION or PRIVATE_NAT(Beta).
     A subnet with purpose set to REGIONAL_MANAGED_PROXY is a user-created subnetwork that is reserved for regional Envoy-based load balancers.
@@ -367,12 +366,12 @@ class InitProvider(BaseModel):
     Note that REGIONAL_MANAGED_PROXY is the preferred setting for all regional Envoy load balancers.
     If unspecified, the purpose defaults to PRIVATE.
     """
-    reservedInternalRange: Optional[str] = None
+    reservedInternalRange: str | None = None
     """
     The ID of the reserved internal range. Must be prefixed with networkconnectivity.googleapis.com
     E.g. networkconnectivity.googleapis.com/projects/{project}/locations/global/internalRanges/{rangeId}
     """
-    role: Optional[str] = None
+    role: str | None = None
     """
     The role of subnetwork.
     Currently, this field is only used when purpose is REGIONAL_MANAGED_PROXY.
@@ -381,7 +380,7 @@ class InitProvider(BaseModel):
     A BACKUP subnetwork is one that is ready to be promoted to ACTIVE or is currently draining.
     Possible values are: ACTIVE, BACKUP.
     """
-    secondaryIpRange: Optional[List[SecondaryIpRangeItem]] = None
+    secondaryIpRange: list[SecondaryIpRangeItem] | None = None
     """
     An array of configurations for secondary IP ranges for VM instances
     contained in this subnetwork. The primary IP of such VM must belong
@@ -392,7 +391,7 @@ class InitProvider(BaseModel):
     set send_secondary_ip_range_if_empty = true
     Structure is documented below.
     """
-    sendSecondaryIpRangeIfEmpty: Optional[bool] = None
+    sendSecondaryIpRangeIfEmpty: bool | None = None
     """
     Controls the removal behavior of secondary_ip_range.
     When false, removing secondary_ip_range from config will not produce a diff as
@@ -401,7 +400,7 @@ class InitProvider(BaseModel):
     empty list of secondary IP ranges to the API.
     Defaults to false.
     """
-    stackType: Optional[str] = None
+    stackType: str | None = None
     """
     The stack type for this subnet to identify whether the IPv6 feature is enabled or not.
     If not specified IPV4_ONLY will be used.
@@ -429,7 +428,7 @@ class WriteConnectionSecretToRef(BaseModel):
 
 class Spec(BaseModel):
     forProvider: ForProvider
-    initProvider: Optional[InitProvider] = None
+    initProvider: InitProvider | None = None
     """
     THIS IS A BETA FIELD. It will be honored
     unless the Management Policies feature flag is disabled.
@@ -442,9 +441,10 @@ class Spec(BaseModel):
     for example because of an external controller is managing them, like an
     autoscaler.
     """
-    managementPolicies: Optional[
-        List[Literal['Observe', 'Create', 'Update', 'Delete', 'LateInitialize', '*']]
-    ] = ['*']
+    managementPolicies: (
+        list[Literal['Observe', 'Create', 'Update', 'Delete', 'LateInitialize', '*']]
+        | None
+    ) = ['*']
     """
     THIS IS A BETA FIELD. It is on by default but can be opted out
     through a Crossplane feature flag.
@@ -453,17 +453,15 @@ class Spec(BaseModel):
     See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223
     and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md
     """
-    providerConfigRef: Optional[ProviderConfigRef] = Field(
-        default_factory=lambda: ProviderConfigRef.model_validate(
-            {'kind': 'ClusterProviderConfig', 'name': 'default'}
-        )
+    providerConfigRef: ProviderConfigRef | None = Field(
+        {'kind': 'ClusterProviderConfig', 'name': 'default'}, validate_default=True
     )
     """
     ProviderConfigReference specifies how the provider that will be used to
     create, observe, update, and delete this managed resource should be
     configured.
     """
-    writeConnectionSecretToRef: Optional[WriteConnectionSecretToRef] = None
+    writeConnectionSecretToRef: WriteConnectionSecretToRef | None = None
     """
     WriteConnectionSecretToReference specifies the namespace and name of a
     Secret to which any connection details for this managed resource should
@@ -473,42 +471,42 @@ class Spec(BaseModel):
 
 
 class AtProvider(BaseModel):
-    creationTimestamp: Optional[str] = None
+    creationTimestamp: str | None = None
     """
     Creation timestamp in RFC3339 text format.
     """
-    description: Optional[str] = None
+    description: str | None = None
     """
     An optional description of this resource. Provide this property when
     you create the resource. This field can be set only at resource
     creation time.
     """
-    enableFlowLogs: Optional[bool] = None
+    enableFlowLogs: bool | None = None
     """
     Whether to enable flow logging for this subnetwork. If this field is not explicitly set,
     it will not appear in get listings. If not set the default behavior is determined by the
     org policy, if there is no org policy specified, then it will default to disabled.
     This field isn't supported if the subnet purpose field is set to REGIONAL_MANAGED_PROXY.
     """
-    externalIpv6Prefix: Optional[str] = None
+    externalIpv6Prefix: str | None = None
     """
     The range of external IPv6 addresses that are owned by this subnetwork.
     """
-    fingerprint: Optional[str] = None
-    gatewayAddress: Optional[str] = None
+    fingerprint: str | None = None
+    gatewayAddress: str | None = None
     """
     The gateway address for default routes to reach destination addresses
     outside this subnetwork.
     """
-    id: Optional[str] = None
+    id: str | None = None
     """
     an identifier for the resource with format projects/{{project}}/regions/{{region}}/subnetworks/{{name}}
     """
-    internalIpv6Prefix: Optional[str] = None
+    internalIpv6Prefix: str | None = None
     """
     The internal IPv6 address range that is assigned to this subnetwork.
     """
-    ipCidrRange: Optional[str] = None
+    ipCidrRange: str | None = None
     """
     The range of internal addresses that are owned by this subnetwork.
     Provide this property when you create the subnetwork. For example,
@@ -516,7 +514,7 @@ class AtProvider(BaseModel):
     non-overlapping within a network. Only IPv4 is supported.
     Field is optional when reserved_internal_range is defined, otherwise required.
     """
-    ipCollection: Optional[str] = None
+    ipCollection: str | None = None
     """
     Resource reference of a PublicDelegatedPrefix. The PDP must be a sub-PDP
     in EXTERNAL_IPV6_SUBNETWORK_CREATION mode.
@@ -524,22 +522,22 @@ class AtProvider(BaseModel):
     IPv6 NetLB forwarding rule using BYOIP:
     Full resource URL, as in:
     """
-    ipv6AccessType: Optional[str] = None
+    ipv6AccessType: str | None = None
     """
     The access type of IPv6 address this subnet holds. It's immutable and can only be specified during creation
     or the first time the subnet is updated into IPV4_IPV6 dual stack. If the ipv6_type is EXTERNAL then this subnet
     cannot enable direct path.
     Possible values are: EXTERNAL, INTERNAL.
     """
-    ipv6CidrRange: Optional[str] = None
+    ipv6CidrRange: str | None = None
     """
     The range of internal IPv6 addresses that are owned by this subnetwork.
     """
-    ipv6GceEndpoint: Optional[str] = None
+    ipv6GceEndpoint: str | None = None
     """
     Possible endpoints of this subnetwork. It can be one of the following:
     """
-    logConfig: Optional[LogConfig] = None
+    logConfig: LogConfig | None = None
     """
     This field denotes the VPC flow logging options for this subnetwork. If
     logging is enabled, logs are exported to Cloud Logging. Flow logging
@@ -547,31 +545,31 @@ class AtProvider(BaseModel):
     REGIONAL_MANAGED_PROXY or GLOBAL_MANAGED_PROXY.
     Structure is documented below.
     """
-    network: Optional[str] = None
+    network: str | None = None
     """
     The network this subnet belongs to.
     Only networks that are in the distributed mode can have subnetworks.
     """
-    params: Optional[Params] = None
+    params: Params | None = None
     """
     Additional params passed with the request, but not persisted as part of resource payload
     Structure is documented below.
     """
-    privateIpGoogleAccess: Optional[bool] = None
+    privateIpGoogleAccess: bool | None = None
     """
     When enabled, VMs in this subnetwork without external IP addresses can
     access Google APIs and services by using Private Google Access.
     """
-    privateIpv6GoogleAccess: Optional[str] = None
+    privateIpv6GoogleAccess: str | None = None
     """
     The private IPv6 google access type for the VMs in this subnet.
     """
-    project: Optional[str] = None
+    project: str | None = None
     """
     The ID of the project in which the resource belongs.
     If it is not provided, the provider project is used.
     """
-    purpose: Optional[str] = None
+    purpose: str | None = None
     """
     The purpose of the resource. This field can be either PRIVATE, REGIONAL_MANAGED_PROXY, GLOBAL_MANAGED_PROXY, PRIVATE_SERVICE_CONNECT, PEER_MIGRATION or PRIVATE_NAT(Beta).
     A subnet with purpose set to REGIONAL_MANAGED_PROXY is a user-created subnetwork that is reserved for regional Envoy-based load balancers.
@@ -582,16 +580,16 @@ class AtProvider(BaseModel):
     Note that REGIONAL_MANAGED_PROXY is the preferred setting for all regional Envoy load balancers.
     If unspecified, the purpose defaults to PRIVATE.
     """
-    region: Optional[str] = None
+    region: str | None = None
     """
     The GCP region for this subnetwork.
     """
-    reservedInternalRange: Optional[str] = None
+    reservedInternalRange: str | None = None
     """
     The ID of the reserved internal range. Must be prefixed with networkconnectivity.googleapis.com
     E.g. networkconnectivity.googleapis.com/projects/{project}/locations/global/internalRanges/{rangeId}
     """
-    role: Optional[str] = None
+    role: str | None = None
     """
     The role of subnetwork.
     Currently, this field is only used when purpose is REGIONAL_MANAGED_PROXY.
@@ -600,7 +598,7 @@ class AtProvider(BaseModel):
     A BACKUP subnetwork is one that is ready to be promoted to ACTIVE or is currently draining.
     Possible values are: ACTIVE, BACKUP.
     """
-    secondaryIpRange: Optional[List[SecondaryIpRangeItem]] = None
+    secondaryIpRange: list[SecondaryIpRangeItem] | None = None
     """
     An array of configurations for secondary IP ranges for VM instances
     contained in this subnetwork. The primary IP of such VM must belong
@@ -611,11 +609,11 @@ class AtProvider(BaseModel):
     set send_secondary_ip_range_if_empty = true
     Structure is documented below.
     """
-    selfLink: Optional[str] = None
+    selfLink: str | None = None
     """
     The URI of the created resource.
     """
-    sendSecondaryIpRangeIfEmpty: Optional[bool] = None
+    sendSecondaryIpRangeIfEmpty: bool | None = None
     """
     Controls the removal behavior of secondary_ip_range.
     When false, removing secondary_ip_range from config will not produce a diff as
@@ -624,37 +622,37 @@ class AtProvider(BaseModel):
     empty list of secondary IP ranges to the API.
     Defaults to false.
     """
-    stackType: Optional[str] = None
+    stackType: str | None = None
     """
     The stack type for this subnet to identify whether the IPv6 feature is enabled or not.
     If not specified IPV4_ONLY will be used.
     Possible values are: IPV4_ONLY, IPV4_IPV6, IPV6_ONLY.
     """
-    state: Optional[str] = None
+    state: str | None = None
     """
     'The state of the subnetwork, which can be one of the following values:
     READY: Subnetwork is created and ready to use DRAINING: only applicable to subnetworks that have the purpose
     set to INTERNAL_HTTPS_LOAD_BALANCER and indicates that connections to the load balancer are being drained.
     A subnetwork that is draining cannot be used or modified until it reaches a status of READY'
     """
-    subnetworkId: Optional[float] = None
+    subnetworkId: float | None = None
     """
     The unique identifier number for the resource. This identifier is defined by the server.
     """
 
 
 class Condition(BaseModel):
-    lastTransitionTime: datetime
+    lastTransitionTime: AwareDatetime
     """
     LastTransitionTime is the last time this condition transitioned from one
     status to another.
     """
-    message: Optional[str] = None
+    message: str | None = None
     """
     A Message containing details about this condition's last transition from
     one status to another, if any.
     """
-    observedGeneration: Optional[int] = None
+    observedGeneration: int | None = None
     """
     ObservedGeneration represents the .metadata.generation that the condition was set based upon.
     For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
@@ -676,12 +674,12 @@ class Condition(BaseModel):
 
 
 class Status(BaseModel):
-    atProvider: Optional[AtProvider] = None
-    conditions: Optional[List[Condition]] = None
+    atProvider: AtProvider | None = None
+    conditions: list[Condition] | None = None
     """
     Conditions of the resource.
     """
-    observedGeneration: Optional[int] = None
+    observedGeneration: int | None = None
     """
     ObservedGeneration is the latest metadata.generation
     which resulted in either a ready state, or stalled due to error
@@ -690,17 +688,17 @@ class Status(BaseModel):
 
 
 class Subnetwork(BaseModel):
-    apiVersion: Optional[Literal['compute.gcp.m.upbound.io/v1beta1']] = (
+    apiVersion: Literal['compute.gcp.m.upbound.io/v1beta1'] | None = (
         'compute.gcp.m.upbound.io/v1beta1'
     )
     """
     APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
     """
-    kind: Optional[Literal['Subnetwork']] = 'Subnetwork'
+    kind: Literal['Subnetwork'] | None = 'Subnetwork'
     """
     Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
     """
-    metadata: Optional[v1.ObjectMeta] = None
+    metadata: v1.ObjectMeta | None = None
     """
     Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
     """
@@ -708,26 +706,26 @@ class Subnetwork(BaseModel):
     """
     SubnetworkSpec defines the desired state of Subnetwork
     """
-    status: Optional[Status] = None
+    status: Status | None = None
     """
     SubnetworkStatus defines the observed state of Subnetwork.
     """
 
 
 class SubnetworkList(BaseModel):
-    apiVersion: Optional[str] = None
+    apiVersion: str | None = None
     """
     APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
     """
-    items: List[Subnetwork]
+    items: list[Subnetwork]
     """
     List of subnetworks. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md
     """
-    kind: Optional[str] = None
+    kind: str | None = None
     """
     Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
     """
-    metadata: Optional[v1.ListMeta] = None
+    metadata: v1.ListMeta | None = None
     """
     Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
     """
\ No newline at end of file
io/k8s/apimachinery/pkg/apis/meta/v1.py
diff --git a/schemas/python/models/io/k8s/apimachinery/pkg/apis/meta/v1.py b/schemas/python/models/io/k8s/apimachinery/pkg/apis/meta/v1.py
index 7e0b39c..5c57345 100644
--- a/schemas/python/models/io/k8s/apimachinery/pkg/apis/meta/v1.py
+++ b/schemas/python/models/io/k8s/apimachinery/pkg/apis/meta/v1.py
@@ -1,12 +1,9 @@
 # generated by datamodel-codegen:
-#   filename:  workdir/infrastructure_modelplane_ai_v1alpha1_ekscluster.yaml
+#   filename:  workdir/compute_gcp_m_upbound_io_v1beta1_address.yaml
 
 from __future__ import annotations
 
-from datetime import datetime
-from typing import Dict, List, Optional
-
-from pydantic import BaseModel, Field, RootModel
+from pydantic import AwareDatetime, BaseModel, Field, RootModel
 
 
 class FieldsV1(BaseModel):
@@ -14,19 +11,19 @@ class FieldsV1(BaseModel):
 
 
 class ListMeta(BaseModel):
-    continue_: Optional[str] = Field(None, alias='continue')
+    continue_: str | None = Field(None, alias='continue')
     """
     continue may be set if the user set a limit on the number of items returned, and indicates that the server has more data available. The value is opaque and may be used to issue another request to the endpoint that served this list to retrieve the next set of available objects. Continuing a consistent list may not be possible if the server configuration has changed or more than a few minutes have passed. The resourceVersion field returned when using this continue value will be identical to the value in the first response, unless you have received this token from an error message.
     """
-    remainingItemCount: Optional[int] = None
+    remainingItemCount: int | None = None
     """
     remainingItemCount is the number of subsequent items in the list which are not included in this list response. If the list request contained label or field selectors, then the number of remaining items is unknown and the field will be left unset and omitted during serialization. If the list is complete (either because it is not chunking or because this is the last chunk), then there are no more remaining items and this field will be left unset and omitted during serialization. Servers older than v1.15 do not set this field. The intended use of the remainingItemCount is *estimating* the size of a collection. Clients should not rely on the remainingItemCount to be set or to be exact.
     """
-    resourceVersion: Optional[str] = None
+    resourceVersion: str | None = None
     """
     String that identifies the server's internal version of this object that can be used by clients to determine when objects have changed. Value must be treated as opaque by clients and passed unmodified back to the server. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
     """
-    selfLink: Optional[str] = None
+    selfLink: str | None = None
     """
     Deprecated: selfLink is a legacy read-only field that is no longer populated by the system.
     """
@@ -37,11 +34,11 @@ class OwnerReference(BaseModel):
     """
     API version of the referent.
     """
-    blockOwnerDeletion: Optional[bool] = None
+    blockOwnerDeletion: bool | None = None
     """
     If true, AND if the owner has the "foregroundDeletion" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. See https://kubernetes.io/docs/concepts/architecture/garbage-collection/#foreground-deletion for how the garbage collector interacts with this field and enforces the foreground deletion. Defaults to false. To set this field, a user needs "delete" permission of the owner, otherwise 422 (Unprocessable Entity) will be returned.
     """
-    controller: Optional[bool] = None
+    controller: bool | None = None
     """
     If true, this reference points to the managing controller.
     """
@@ -64,18 +61,18 @@ class Patch(BaseModel):
 
 
 class Preconditions(BaseModel):
-    resourceVersion: Optional[str] = None
+    resourceVersion: str | None = None
     """
     Specifies the target ResourceVersion
     """
-    uid: Optional[str] = None
+    uid: str | None = None
     """
     Specifies the target UID.
     """
 
 
 class StatusCause(BaseModel):
-    field: Optional[str] = None
+    field: str | None = None
     """
     The field of the resource that has caused this error, as named by its JSON serialization. May include dot and postfix notation for nested attributes. Arrays are zero-indexed.  Fields may appear more than once in an array of causes due to fields having multiple errors. Optional.
 
@@ -83,142 +80,142 @@ class StatusCause(BaseModel):
       "name" - the field "name" on the current resource
       "items[0].name" - the field "name" on the first array entry in "items"
     """
-    message: Optional[str] = None
+    message: str | None = None
     """
     A human-readable description of the cause of the error.  This field may be presented as-is to a reader.
     """
-    reason: Optional[str] = None
+    reason: str | None = None
     """
     A machine-readable description of the cause of the error. If this value is empty there is no information available.
     """
 
 
 class StatusDetails(BaseModel):
-    causes: Optional[List[StatusCause]] = None
+    causes: list[StatusCause] | None = None
     """
     The Causes array includes more details associated with the StatusReason failure. Not all StatusReasons may provide detailed causes.
     """
-    group: Optional[str] = None
+    group: str | None = None
     """
     The group attribute of the resource associated with the status StatusReason.
     """
-    kind: Optional[str] = None
+    kind: str | None = None
     """
     The kind attribute of the resource associated with the status StatusReason. On some operations may differ from the requested resource Kind. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
     """
-    name: Optional[str] = None
+    name: str | None = None
     """
     The name attribute of the resource associated with the status StatusReason (when there is a single name which can be described).
     """
-    retryAfterSeconds: Optional[int] = None
+    retryAfterSeconds: int | None = None
     """
     If specified, the time in seconds before the operation should be retried. Some errors may indicate the client must take an alternate action - for those errors this field may indicate how long to wait before taking the alternate action.
     """
-    uid: Optional[str] = None
+    uid: str | None = None
     """
     UID of the resource. (when there is a single resource which can be described). More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids
     """
 
 
-class Time(RootModel[datetime]):
-    root: datetime
+class Time(RootModel[AwareDatetime]):
+    root: AwareDatetime
     """
     Time is a wrapper around time.Time which supports correct marshaling to YAML and JSON.  Wrappers are provided for many of the factory methods that the time package offers.
     """
 
 
 class DeleteOptions(BaseModel):
-    apiVersion: Optional[str] = None
+    apiVersion: str | None = None
     """
     APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
     """
-    dryRun: Optional[List[str]] = None
+    dryRun: list[str] | None = None
     """
     When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed
     """
-    gracePeriodSeconds: Optional[int] = None
+    gracePeriodSeconds: int | None = None
     """
     The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately.
     """
-    ignoreStoreReadErrorWithClusterBreakingPotential: Optional[bool] = None
+    ignoreStoreReadErrorWithClusterBreakingPotential: bool | None = None
     """
     if set to true, it will trigger an unsafe deletion of the resource in case the normal deletion flow fails with a corrupt object error. A resource is considered corrupt if it can not be retrieved from the underlying storage successfully because of a) its data can not be transformed e.g. decryption failure, or b) it fails to decode into an object. NOTE: unsafe deletion ignores finalizer constraints, skips precondition checks, and removes the object from the storage. WARNING: This may potentially break the cluster if the workload associated with the resource being unsafe-deleted relies on normal deletion flow. Use only if you REALLY know what you are doing. The default value is false, and the user must opt in to enable it
     """
-    kind: Optional[str] = None
+    kind: str | None = None
     """
     Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
     """
-    orphanDependents: Optional[bool] = None
+    orphanDependents: bool | None = None
     """
     Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both.
     """
-    preconditions: Optional[Preconditions] = None
+    preconditions: Preconditions | None = None
     """
     Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned.
     """
-    propagationPolicy: Optional[str] = None
+    propagationPolicy: str | None = None
     """
     Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground.
     """
 
 
 class ManagedFieldsEntry(BaseModel):
-    apiVersion: Optional[str] = None
+    apiVersion: str | None = None
     """
     APIVersion defines the version of this resource that this field set applies to. The format is "group/version" just like the top-level APIVersion field. It is necessary to track the version of a field set because it cannot be automatically converted.
     """
-    fieldsType: Optional[str] = None
+    fieldsType: str | None = None
     """
     FieldsType is the discriminator for the different fields format and version. There is currently only one possible value: "FieldsV1"
     """
-    fieldsV1: Optional[FieldsV1] = None
+    fieldsV1: FieldsV1 | None = None
     """
     FieldsV1 holds the first JSON version format as described in the "FieldsV1" type.
     """
-    manager: Optional[str] = None
+    manager: str | None = None
     """
     Manager is an identifier of the workflow managing these fields.
     """
-    operation: Optional[str] = None
+    operation: str | None = None
     """
     Operation is the type of operation which lead to this ManagedFieldsEntry being created. The only valid values for this field are 'Apply' and 'Update'.
     """
-    subresource: Optional[str] = None
+    subresource: str | None = None
     """
     Subresource is the name of the subresource used to update that object, or empty string if the object was updated through the main resource. The value of this field is used to distinguish between managers, even if they share the same name. For example, a status update will be distinct from a regular update using the same manager name. Note that the APIVersion field is not related to the Subresource field and it always corresponds to the version of the main resource.
     """
-    time: Optional[Time] = None
+    time: Time | None = None
     """
     Time is the timestamp of when the ManagedFields entry was added. The timestamp will also be updated if a field is added, the manager changes any of the owned fields value or removes a field. The timestamp does not update when a field is removed from the entry because another manager took it over.
     """
 
 
 class ObjectMeta(BaseModel):
-    annotations: Optional[Dict[str, str]] = None
+    annotations: dict[str, str] | None = None
     """
     Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations
     """
-    creationTimestamp: Optional[Time] = None
+    creationTimestamp: Time | None = None
     """
     CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.
 
     Populated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
     """
-    deletionGracePeriodSeconds: Optional[int] = None
+    deletionGracePeriodSeconds: int | None = None
     """
     Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set. May only be shortened. Read-only.
     """
-    deletionTimestamp: Optional[Time] = None
+    deletionTimestamp: Time | None = None
     """
     DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted. This field is set by the server when a graceful deletion is requested by the user, and is not directly settable by a client. The resource is expected to be deleted (no longer visible from resource lists, and not reachable by name) after the time in this field, once the finalizers list is empty. As long as the finalizers list contains items, deletion is blocked. Once the deletionTimestamp is set, this value may not be unset or be set further into the future, although it may be shortened or the resource may be deleted prior to this time. For example, a user may request that a pod is deleted in 30 seconds. The Kubelet will react by sending a graceful termination signal to the containers in the pod. After that 30 seconds, the Kubelet will send a hard termination signal (SIGKILL) to the container and after cleanup, remove the pod from the API. In the presence of network partitions, this object may still exist after this timestamp, until an administrator or automated process can determine the resource is fully terminated. If not set, graceful deletion of the object has not been requested.
 
     Populated by the system when a graceful deletion is requested. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
     """
-    finalizers: Optional[List[str]] = None
+    finalizers: list[str] | None = None
     """
     Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed. Finalizers may be processed and removed in any order.  Order is NOT enforced because it introduces significant risk of stuck finalizers. finalizers is a shared field, any actor with permission can reorder it. If the finalizer list is processed in order, then this can lead to a situation in which the component responsible for the first finalizer in the list is waiting for a signal (field value, external system, or other) produced by a component responsible for a finalizer later in the list, resulting in a deadlock. Without enforced ordering finalizers are free to order amongst themselves and are not vulnerable to ordering changes in the list.
     """
-    generateName: Optional[str] = None
+    generateName: str | None = None
     """
     GenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided. If this field is used, the name returned to the client will be different than the name passed. This value will also be combined with a unique suffix. The provided value has the same validation rules as the Name field, and may be truncated by the length of the suffix required to make the value unique on the server.
 
@@ -226,43 +223,43 @@ class ObjectMeta(BaseModel):
 
     Applied only if Name is not specified. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency
     """
-    generation: Optional[int] = None
+    generation: int | None = None
     """
     A sequence number representing a specific generation of the desired state. Populated by the system. Read-only.
     """
-    labels: Optional[Dict[str, str]] = None
+    labels: dict[str, str] | None = None
     """
     Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
     """
-    managedFields: Optional[List[ManagedFieldsEntry]] = None
+    managedFields: list[ManagedFieldsEntry] | None = None
     """
     ManagedFields maps workflow-id and version to the set of fields that are managed by that workflow. This is mostly for internal housekeeping, and users typically shouldn't need to set or understand this field. A workflow can be the user's name, a controller's name, or the name of a specific apply path like "ci-cd". The set of fields is always in the version that the workflow used when modifying the object.
     """
-    name: Optional[str] = None
+    name: str | None = None
     """
     Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names
     """
-    namespace: Optional[str] = None
+    namespace: str | None = None
     """
     Namespace defines the space within which each name must be unique. An empty namespace is equivalent to the "default" namespace, but "default" is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty.
 
     Must be a DNS_LABEL. Cannot be updated. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces
     """
-    ownerReferences: Optional[List[OwnerReference]] = None
+    ownerReferences: list[OwnerReference] | None = None
     """
     List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.
     """
-    resourceVersion: Optional[str] = None
+    resourceVersion: str | None = None
     """
     An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. May be used for optimistic concurrency, change detection, and the watch operation on a resource or set of resources. Clients must treat these values as opaque and passed unmodified back to the server. They may only be valid for a particular resource or set of resources.
 
     Populated by the system. Read-only. Value must be treated as opaque by clients and . More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
     """
-    selfLink: Optional[str] = None
+    selfLink: str | None = None
     """
     Deprecated: selfLink is a legacy read-only field that is no longer populated by the system.
     """
-    uid: Optional[str] = None
+    uid: str | None = None
     """
     UID is the unique in time and space value for this object. It is typically generated by the server on successful creation of a resource and is not allowed to change on PUT operations.
 
@@ -271,35 +268,35 @@ class ObjectMeta(BaseModel):
 
 
 class Status(BaseModel):
-    apiVersion: Optional[str] = None
+    apiVersion: str | None = None
     """
     APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
     """
-    code: Optional[int] = None
+    code: int | None = None
     """
     Suggested HTTP return code for this status, 0 if not set.
     """
-    details: Optional[StatusDetails] = None
+    details: StatusDetails | None = None
     """
     Extended data associated with the reason.  Each reason may define its own extended details. This field is optional and the data returned is not guaranteed to conform to any schema except that defined by the reason type.
     """
-    kind: Optional[str] = None
+    kind: str | None = None
     """
     Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
     """
-    message: Optional[str] = None
+    message: str | None = None
     """
     A human-readable description of the status of this operation.
     """
-    metadata: Optional[ListMeta] = {}
+    metadata: ListMeta | None = Field({}, validate_default=True)
     """
     Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
     """
-    reason: Optional[str] = None
+    reason: str | None = None
     """
     A machine-readable description of why this operation is in the "Failure" status. If this value is empty there is no information available. A Reason clarifies an HTTP status code but does not override it.
     """
-    status: Optional[str] = None
+    status: str | None = None
     """
     Status of the operation. One of: "Success" or "Failure". More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
     """

@negz negz marked this pull request as ready for review June 3, 2026 20:09
@negz negz requested review from a team, jcogilvie and tampakrap as code owners June 3, 2026 20:09
@negz negz requested review from phisco and removed request for a team June 3, 2026 20:09
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR upgrades the Python schema code generator Docker image to version 0.59.0 and refactors the post-processing pipeline to remove intermediate helper functions that are now handled upstream by the newer image version.

Changes

Python code generator upgrade and pipeline simplification

Layer / File(s) Summary
Upgrade Docker image tag
internal/schemas/generator/python.go
The pythonImage constant is updated from datamodel-code-generator:0.31.2 to datamodel-code-generator:0.59.0, providing access to upstream improvements.
Simplify post-processing pipeline
internal/schemas/generator/python.go
Removed postProcessFile and fixAliasedTypesInFile helper functions. Refactored postTransformOpenAPI to call adjustImportsInFile directly for each generated file, eliminating local aliasing token replacements now handled by the upgraded code generator.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and directly describes the main fix: addressing Python schema generation for fields named int or bool.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Breaking Changes ✅ Passed The breaking-changes check only applies to files under 'apis/' or 'cmd/'. This PR only modifies 'internal/schemas/generator/python.go', which is outside the scope of the check.
Feature Gate Requirement ✅ Passed This PR fixes a bug in Python schema generation, not introducing experimental features. It updates the datamodel-code-generator image to fix broken output when properties are named "int" or "bool".
Description check ✅ Passed The pull request description clearly relates to the changeset, explaining the fix for Python schema generation with int/bool field names and the Docker image upgrade.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/schemas/generator/python.go`:
- Around line 577-578: The wrapped error from adjustImportsInFile drops the file
context making failure messages unhelpful; update the errors.Wrapf call in the
caller that invokes adjustImportsInFile (the block containing if err :=
adjustImportsInFile(fs, destPath); err != nil) to include destPath and a short
user-facing hint (e.g., "unable to update imports for generated file %s; check
file permissions or import paths and re-run generation") so the error becomes
errors.Wrapf(err, "unable to update imports for generated file %s; check file
permissions or import paths and re-run generation", destPath).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 195be654-f908-4931-9b7a-e23cc3fc7267

📥 Commits

Reviewing files that changed from the base of the PR and between 9776e2d and b1674d2.

📒 Files selected for processing (1)
  • internal/schemas/generator/python.go

Comment on lines +577 to +578
if err := adjustImportsInFile(fs, destPath); err != nil {
return errors.Wrapf(err, "adjusting imports")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Restore actionable context in the wrapped import-adjustment error.

At Line 578, the wrap message dropped file context, which makes failures hard to act on during generation. Can we include destPath and a brief user-facing hint?

💡 Proposed fix
-		if err := adjustImportsInFile(fs, destPath); err != nil {
-			return errors.Wrapf(err, "adjusting imports")
+		if err := adjustImportsInFile(fs, destPath); err != nil {
+			return errors.Wrapf(err, "cannot adjust generated python imports for %q; verify generated model paths and try again", destPath)
 		}

As per coding guidelines, "CRITICAL: Ensure all error messages are meaningful to end users, not just developers - avoid technical jargon, include context about what the user was trying to do, and suggest next steps when possible."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if err := adjustImportsInFile(fs, destPath); err != nil {
return errors.Wrapf(err, "adjusting imports")
if err := adjustImportsInFile(fs, destPath); err != nil {
return errors.Wrapf(err, "cannot adjust generated python imports for %q; verify generated model paths and try again", destPath)
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/schemas/generator/python.go` around lines 577 - 578, The wrapped
error from adjustImportsInFile drops the file context making failure messages
unhelpful; update the errors.Wrapf call in the caller that invokes
adjustImportsInFile (the block containing if err := adjustImportsInFile(fs,
destPath); err != nil) to include destPath and a short user-facing hint (e.g.,
"unable to update imports for generated file %s; check file permissions or
import paths and re-run generation") so the error becomes errors.Wrapf(err,
"unable to update imports for generated file %s; check file permissions or
import paths and re-run generation", destPath).

@negz
Copy link
Copy Markdown
Member Author

negz commented Jun 3, 2026

It looks like datamodel-code-generator changed how it emits a field's default value.

Before:

providerConfigRef: Optional[ProviderConfigRef] = Field(
    default_factory=lambda: ProviderConfigRef.model_validate(
        {'kind': 'ClusterProviderConfig', 'name': 'default'}
    )
)

After:

providerConfigRef: ProviderConfigRef | None = Field(
    {'kind': 'ClusterProviderConfig', 'name': 'default'}, validate_default=True
)

function-sdk-python serializes composed resources with model_dump(exclude_defaults=True). The two forms behave differently under exclude_defaults:

  • default_factory: Pydantic recognizes an unset field as still equal to its default, so exclude_defaults=True omits it. The composed resource had no spec.providerConfigRef.
  • raw default + validate_default=True: the default is eagerly validated into a model instance at construction, which exclude_defaults no longer treats as "unset/default", so it is emitted.

So every composed upbound (GCP/AWS) resource now has an explicit spec.providerConfigRef: {kind: ClusterProviderConfig, name: default} that it previously omitted.

@adamwg
Copy link
Copy Markdown
Member

adamwg commented Jun 3, 2026

function-sdk-python serializes composed resources with model_dump(exclude_defaults=True). The two forms behave differently under exclude_defaults:

  • default_factory: Pydantic recognizes an unset field as still equal to its default, so exclude_defaults=True omits it. The composed resource had no spec.providerConfigRef.
  • raw default + validate_default=True: the default is eagerly validated into a model instance at construction, which exclude_defaults no longer treats as "unset/default", so it is emitted.

So every composed upbound (GCP/AWS) resource now has an explicit spec.providerConfigRef: {kind: ClusterProviderConfig, name: default} that it previously omitted.

@negz Will functions setting the providerConfigRef cause any issues with respect to field ownership?

Copy link
Copy Markdown
Member

@adamwg adamwg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. From the diffs, it looks to me like this shouldn't be a breaking change for any existing Python functions using the schemas.

Probably best to wait until we have some e2e tests in place to help validate changes, but I wonder if we could get renovate to automatically bump versions of the third-party images we depend on for things like this.

@negz
Copy link
Copy Markdown
Member Author

negz commented Jun 4, 2026

LGTM. From the diffs, it looks to me like this shouldn't be a breaking change for any existing Python functions using the schemas.

@adamwg I don't think it's a breaking change but there is a subtle behavior change around defaults in there. See crossplane/function-sdk-python#207 for an analysis.

@negz
Copy link
Copy Markdown
Member Author

negz commented Jun 4, 2026

I'll merge this, but I've added a label to try remind us to not the behavior change in the release notes. I think it'll work best if we also bump the functions to use crossplane/function-sdk-python#208.

@negz negz merged commit b88f8a1 into crossplane:main Jun 4, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

crossplane project build generates broken Python schemas for OpenAPI fields named int/bool

2 participants