Skip to content

Request: detecting empty list in set.union(*[]) #8538

Open
@jamesbraza

Description

@jamesbraza

Current problem

Please see the below code snippet revolving around set construction with Python 3.10.10:

# Empty list
set.union(*[])  # classmethod: TypeError: unbound method set.union() needs an argument
set().union(*[])  # method: works

# Non-empty list of empty set
set.union(*[{}])  # classmethod: TypeError: descriptor 'union' for 'set' objects doesn't apply to a 'dict' object
set().union(*[{}])  # method: works

# Non-empty list of non-empty set
set.union(*[{1}])  # classmethod: works
set().union(*[{1}])  # method: works

pylint==2.17.2 currently doesn't detect any of the failure cases.

Desired solution

It would be handy if pylint could detect the failure cases.

Additional context

This actually gets discussed in the comments of this Stack Overflow answer: https://stackoverflow.com/a/31253153

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions