Skip to content

Change in behavior of F811 (redefinition of unused variable) in Python 3.8 #487

@adamjstewart

Description

@adamjstewart

In Python 3.7.4, with Flake8 3.7.8, Entrypoints 0.3, McCabe 0.6.1, PyCodeStyle 2.1.1, and PyFlakes 2.1.1, the following code snippet is determined to be "clean" by flake8:

def foo(self):
    pass


@when('condition')  # noqa: F811
def foo(self):
    pass

However, in Python 3.8.0, with the same versions of Flake8 and friends, it raises:

[F811] redefinition of unused 'foo'

If I instead change the above snippet to:

def foo(self):
    pass


@when('condition')
def foo(self):  # noqa: F811
    pass

flake8 is happy again. Is this a known change in the behavior of PyFlakes/Flake8, or is this a bug somewhere? I saw #482 but I think that's specific to the builtin @overload decorator.

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