PyCQA / PyCQA/pyflakes

F811 redefinition of unused incorrectly triggered for `__class__`

Open
#372 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
190
Avg merge
8m
Merged PRs (30d)
13

Description

class A:
    @property
    def __class__(self):
        return int

    @__class__.setter
    def __class__(self, __type):
        raise NotImplementedError()

    @property
    def blah(self):
        return int

    @blah.setter
    def blah(self, __type):
        raise NotImplementedError()

This fails like this:

$ pyflakes foo.py 
foo.py:6: redefinition of unused '__class__' from line 2

I included a 2nd property definition to show that it wasn't happening normally. (Seems to be a special situation for __class__

$ pyflakes --version
2.0.0

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with the supplied class definition using pyflakes 2.0.0, then trace the linter's handling of the special __class__ property setter and compare it with the blah setter. Done means the valid __class__ property definition no longer produces an F811 warning while the existing redefinition check remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.