Skip to content

Mutable types are used as default args #1212

Closed
@jeffwidman

Description

@jeffwidman

I noticed there are a bunch of places where a mutable type is used for the default value. For example, there are a bunch of payloads=[] in kafka/client.py:

def send_metadata_request(self, payloads=[], fail_on_error=True,

Using mutable types for default args is typically a no-no unless their surprising behavior is being explicitly abused, for an explanation see: http://effbot.org/zone/default-values.htm

I haven't spelunked in the code much, but I suspect:

  1. They are an oversight rather than intentional.
  2. A simple fix of switching these to tuples would solve the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions