Skip to content

B008: mark builtins.slice() as immutable #21565

@anabelle2001

Description

@anabelle2001

Example

def a(b=float("inf")): ... # True Negative
def c(d=slice(None)): ... # False Positive, as slice() is immutable

There is also the semi-related corner case of def e(f: slice = dict()): .... This is clearly erroneous code, but it is incorrectly flagged as violating B008, despite the docs saying "Parameters with immutable type annotations will be ignored by this rule". (e.g., def g(h: int = dict()): ..., does not trigger B008)

see also: docs.python.org > builtins > slice

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions