Skip to content

Do WPS349 should check bytes slices? #3627

@skv0zsneg

Description

@skv0zsneg

What's wrong

WPS349 checking redundant components in a subscript’s slice

In case when array[0] and array[0:1] return same types the rule is working correct:

array = [1, 2, 3]

array[0]  # <- no error, return int  
array[0:1]  # <- WPS349 violation, return int 

But for bytes it broken because different types is returning:

array = b"123"

array[0]  # <- no error, return int  
array[0:1]  # <- WPS349 violation, but return bytes 

How it should be

I'm expected no violation error.

Flake8 version and plugins

{
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.12.10",
    "system": "Linux"
  },
  "plugins": [
    {
      "plugin": "mccabe",
      "version": "0.7.0"
    },
    {
      "plugin": "pycodestyle",
      "version": "2.14.0"
    },
    {
      "plugin": "pyflakes",
      "version": "3.4.0"
    },
    {
      "plugin": "wemake-python-styleguide",
      "version": "1.6.1"
    }
  ],
  "version": "7.3.0"
}

pip information

Not sure if that's necessary in this case.

OS information

Not sure if that's necessary in this case.

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