Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix python3.12 dataclass issues #6620

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 35 additions & 17 deletions tests/infra/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def from_json(json):

@dataclass
class NodeByRoleResolver:
target: TargetRole = TargetRole(role=NodeRole.primary)
target: TargetRole = field(default_factory=lambda: NodeRole.primary)
kind: str = "NodeByRole"

@staticmethod
Expand Down Expand Up @@ -131,9 +131,9 @@ def from_json(json):

@dataclass
class RedirectionConfig:
to_primary: RedirectionResolver = NodeByRoleResolver()
to_backup: RedirectionResolver = NodeByRoleResolver(
target=TargetRole(role=NodeRole.backup)
to_primary: NodeByRoleResolver = field(default_factory=lambda: NodeByRoleResolver())
to_backup: NodeByRoleResolver = field(
default_factory=lambda: NodeByRoleResolver(target=TargetRole(NodeRole.backup))
)

@staticmethod
Expand Down Expand Up @@ -167,27 +167,45 @@ def resolver_from_json(obj):
@dataclass
class RPCInterface(Interface):
# How nodes are created (local, ssh, ...)
protocol: str = "local"
protocol: str = field(default_factory=lambda: "local")
# Underlying transport layer protocol (tcp, udp)
transport: str = "tcp"
transport: str = field(default_factory=lambda: "tcp")
# Host name/IP
public_host: Optional[str] = None
# Host port
public_port: Optional[int] = None
max_open_sessions_soft: Optional[int] = DEFAULT_MAX_OPEN_SESSIONS_SOFT
max_open_sessions_hard: Optional[int] = DEFAULT_MAX_OPEN_SESSIONS_HARD
max_http_body_size: Optional[int] = DEFAULT_MAX_HTTP_BODY_SIZE
max_http_header_size: Optional[int] = DEFAULT_MAX_HTTP_HEADER_SIZE
max_http_headers_count: Optional[int] = DEFAULT_MAX_HTTP_HEADERS_COUNT
max_concurrent_streams_count: Optional[int] = DEFAULT_MAX_CONCURRENT_STREAMS_COUNT
initial_window_size: Optional[int] = DEFAULT_INITIAL_WINDOW_SIZE
max_frame_size: Optional[int] = DEFAULT_MAX_FRAME_SIZE
endorsement: Optional[Endorsement] = Endorsement()
max_open_sessions_soft: Optional[int] = field(
default_factory=lambda: DEFAULT_MAX_OPEN_SESSIONS_SOFT
)
max_open_sessions_hard: Optional[int] = field(
default_factory=lambda: DEFAULT_MAX_OPEN_SESSIONS_HARD
)
max_http_body_size: Optional[int] = field(
default_factory=lambda: DEFAULT_MAX_HTTP_BODY_SIZE
)
max_http_header_size: Optional[int] = field(
default_factory=lambda: DEFAULT_MAX_HTTP_HEADER_SIZE
)
max_http_headers_count: Optional[int] = field(
default_factory=lambda: DEFAULT_MAX_HTTP_HEADERS_COUNT
)
max_concurrent_streams_count: Optional[int] = field(
default_factory=lambda: DEFAULT_MAX_CONCURRENT_STREAMS_COUNT
)
initial_window_size: Optional[int] = field(
default_factory=lambda: DEFAULT_INITIAL_WINDOW_SIZE
)
max_frame_size: Optional[int] = field(
default_factory=lambda: DEFAULT_MAX_FRAME_SIZE
)
endorsement: Optional[Endorsement] = field(default_factory=lambda: Endorsement())
acme_configuration: Optional[str] = None
accepted_endpoints: Optional[str] = None
forwarding_timeout_ms: Optional[int] = DEFAULT_FORWARDING_TIMEOUT_MS
forwarding_timeout_ms: Optional[int] = field(
default_factory=lambda: DEFAULT_FORWARDING_TIMEOUT_MS
)
redirections: Optional[RedirectionConfig] = None
app_protocol: str = "HTTP1"
app_protocol: str = field(default_factory=lambda: "HTTP1")

@staticmethod
def from_args(args):
Expand Down
Loading