Skip to content

Commit

Permalink
feature: Avoid builtins in field names (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
aiven-anton authored Oct 14, 2023
1 parent d34e451 commit 32ce01a
Show file tree
Hide file tree
Showing 573 changed files with 23 additions and 1,158 deletions.
11 changes: 10 additions & 1 deletion codegen/case.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import builtins
from itertools import count
from typing import Final

_builtins: Final = frozenset(dir(builtins))


def to_snake_case(value: str) -> str:
Expand All @@ -13,6 +17,8 @@ def to_snake_case(value: str) -> str:
'what_is_q'
>>> to_snake_case("V3AndBelow")
'v3_and_below'
>>> to_snake_case("Type")
'type_'
"""

groups = []
Expand Down Expand Up @@ -48,7 +54,10 @@ def to_snake_case(value: str) -> str:
current_group += current

groups.append(current_group)
return ("_".join(groups)).lower()

formatted = ("_".join(groups)).lower()

return formatted + "_" if formatted in _builtins else formatted


def capitalize_first(value: str) -> str:
Expand Down
2 changes: 0 additions & 2 deletions codegen/generate_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
{schema_repository_source}{schema_source}
"""
# ruff: noqa: A003
import datetime
from dataclasses import dataclass, field
from typing import Annotated, ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_offsets_to_txn/v0/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddOffsetsToTxnRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_offsets_to_txn/v0/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddOffsetsToTxnResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_offsets_to_txn/v1/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddOffsetsToTxnRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_offsets_to_txn/v1/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddOffsetsToTxnResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_offsets_to_txn/v2/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddOffsetsToTxnRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_offsets_to_txn/v2/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddOffsetsToTxnResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_offsets_to_txn/v3/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddOffsetsToTxnRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_offsets_to_txn/v3/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddOffsetsToTxnResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_partitions_to_txn/v0/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddPartitionsToTxnRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_partitions_to_txn/v0/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddPartitionsToTxnResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_partitions_to_txn/v1/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddPartitionsToTxnRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_partitions_to_txn/v1/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddPartitionsToTxnResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_partitions_to_txn/v2/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddPartitionsToTxnRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_partitions_to_txn/v2/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddPartitionsToTxnResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_partitions_to_txn/v3/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddPartitionsToTxnRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_partitions_to_txn/v3/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddPartitionsToTxnResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_partitions_to_txn/v4/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddPartitionsToTxnRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/add_partitions_to_txn/v4/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AddPartitionsToTxnResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/allocate_producer_ids/v0/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AllocateProducerIdsRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/allocate_producer_ids/v0/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AllocateProducerIdsResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_client_quotas/v0/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterClientQuotasRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_client_quotas/v0/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterClientQuotasResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_client_quotas/v1/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterClientQuotasRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_client_quotas/v1/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterClientQuotasResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_configs/v0/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterConfigsRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_configs/v0/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterConfigsResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_configs/v1/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterConfigsRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_configs/v1/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterConfigsResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_configs/v2/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterConfigsRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_configs/v2/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterConfigsResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_partition/v0/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterPartitionRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_partition/v0/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterPartitionResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_partition/v1/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterPartitionRequest.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_partition/v1/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterPartitionResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_partition/v2/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterPartitionRequest.json
"""

# ruff: noqa: A003

import uuid
from dataclasses import dataclass
from dataclasses import field
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_partition/v2/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterPartitionResponse.json
"""

# ruff: noqa: A003

import uuid
from dataclasses import dataclass
from dataclasses import field
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_partition/v3/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterPartitionRequest.json
"""

# ruff: noqa: A003

import uuid
from dataclasses import dataclass
from dataclasses import field
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_partition/v3/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterPartitionResponse.json
"""

# ruff: noqa: A003

import uuid
from dataclasses import dataclass
from dataclasses import field
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_partition_reassignments/v0/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterPartitionReassignmentsRequest.json
"""

# ruff: noqa: A003

import datetime
from dataclasses import dataclass
from dataclasses import field
Expand Down
2 changes: 0 additions & 2 deletions src/kio/schema/alter_partition_reassignments/v0/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
https://github.com/apache/kafka/tree/3.5.1/clients/src/main/resources/common/message/AlterPartitionReassignmentsResponse.json
"""

# ruff: noqa: A003

from dataclasses import dataclass
from dataclasses import field
from typing import ClassVar
Expand Down
Loading

0 comments on commit 32ce01a

Please sign in to comment.