Skip to content

E713 test failing on text inside double quotes #2004

@adamloverro

Description

@adamloverro

how did you install flake8?

Initially, flake8 was run with pre-commit;
.pre-commit-config.yaml:
  - repo: https://github.com/pycqa/flake8
    rev: 6.0.0
    hooks:
      - id: flake8
        args: [
          # E501 let black handle all line length decisions
          # W503 black conflicts with "line break before operator" rule
          # E203 black conflicts with "whitespace before ':'" rule
          '--ignore=E501,W503,E203,C901,E202' ]

unmodified output of flake8 --bug-report

{
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.13.8",
    "system": "Darwin"
  },
  "plugins": [
    {
      "plugin": "mccabe",
      "version": "0.7.0"
    },
    {
      "plugin": "pycodestyle",
      "version": "2.14.0"
    },
    {
      "plugin": "pyflakes",
      "version": "3.4.0"
    }
  ],
  "version": "7.3.0"
}

describe the problem

what I expected to happen

No errors to be emitted
...

what did happen

flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/integration/test_azure_integration.py:116:40: E713 test for membership should be 'not in'

sample code

  if "authentication" in str(e).lower() or "credential" in str(e).lower():
      pytest.skip(
          f"Managed identity not available in current environment: {e}"
      )

commands ran

$ pre-commit run --all-files
...

Hypothesis

Rule E713 is triggered by this line of code because it probably matches the pattern if ... not availabile in .... This shouldn't apply in this scenario though since the not available in text is part of a string, and not part of the main if statement logic.

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