Skip to content

Incorrect _DEFAULT typing for ConnectionParameters arguments #11

@rqueue

Description

@rqueue

For the ConnectionParameters, the type are defined as follows:

class ConnectionParameters(Parameters):

    class _DEFAULT:
        ...

    def __init__(
        self,
        host: Union[str, _DEFAULT] = ...,
        port: Union[int, _DEFAULT] = ...,
        virtual_host: Union[str, _DEFAULT] = ...,
        credentials: Union[credentials_.VALID_TYPES, _DEFAULT] = ...,
        channel_max: Union[int, _DEFAULT] = ...,
        frame_max: Union[int, _DEFAULT] = ...,
        heartbeat: Union[int, _OnHeartbeatTimeoutCallback, None, _DEFAULT] = ...,
        ssl_options: Union[SSLOptions, _DEFAULT] = ...,
        connection_attempts: Union[int, _DEFAULT] = ...,
        retry_delay: Union[numbers.Real, _DEFAULT] = ...,
        socket_timeout: Union[numbers.Real, _DEFAULT] = ...,
        stack_timeout: Union[numbers.Real, _DEFAULT] = ...,
        locale: Union[str, _DEFAULT] = ...,
        blocked_connection_timeout: Union[numbers.Real, None, _DEFAULT] = ...,
        client_properties: Union[Mapping[str, Any], None, _DEFAULT] = ...,
        tcp_options: Union[Mapping[str, Any], None, _DEFAULT] = ...,
        **kwargs: Any,
    ): ...

The _DEFAULT type defined expects an instance, but the actual method only checks for the _DEFAULT type itself. I believe the _DEFAULT type should be changed to Type[_DEFAULT]:

class ConnectionParameters(Parameters):

    class _DEFAULT:
        ...

    def __init__(
        self,
        host: Union[str, Type[_DEFAULT]] = ...,
        port: Union[int, Type[_DEFAULT]] = ...,
        virtual_host: Union[str, Type[_DEFAULT]] = ...,
        credentials: Union[credentials_.VALID_TYPES, Type[_DEFAULT]] = ...,
        channel_max: Union[int, Type[_DEFAULT]] = ...,
        frame_max: Union[int, Type[_DEFAULT]] = ...,
        heartbeat: Union[int, _OnHeartbeatTimeoutCallback, None, Type[_DEFAULT]] = ...,
        ssl_options: Union[SSLOptions, Type[_DEFAULT]] = ...,
        connection_attempts: Union[int, Type[_DEFAULT]] = ...,
        retry_delay: Union[numbers.Real, Type[_DEFAULT]] = ...,
        socket_timeout: Union[numbers.Real, Type[_DEFAULT]] = ...,
        stack_timeout: Union[numbers.Real, Type[_DEFAULT]] = ...,
        locale: Union[str, Type[_DEFAULT]] = ...,
        blocked_connection_timeout: Union[numbers.Real, None, Type[_DEFAULT]] = ...,
        client_properties: Union[Mapping[str, Any], None, Type[_DEFAULT]] = ...,
        tcp_options: Union[Mapping[str, Any], None, Type[_DEFAULT]] = ...,
        **kwargs: Any,
    ): ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions