Skip to content
This repository was archived by the owner on Feb 4, 2024. It is now read-only.
This repository was archived by the owner on Feb 4, 2024. It is now read-only.

Small optimisation of YTT202 #2

Closed
@hugovk

Description

@hugovk

With this code:

import six
if not six.PY3:
    pass

The plugin correctly gives:

$ flake8 --select YTT 1.py
1.py:2:8: YTT202: `six.PY3` referenced (python4), use `not six.PY2`

Perhaps it could detect the not before six.PY3, and suggest a clean six.PY2 instead?

For example:

$ flake8 --select YTT 1.py
1.py:2:X: YTT20X: `not six.PY3` referenced (python4), use `six.PY2`

That is:

# Bad
if not six.PY3:

# Better (sort of)
if not not six.PY2:

# Best
if six.PY2:

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