PyCQA / PyCQA/pycodestyle

E721: mistake due to isidentifier() not considering '.'

Open
#662 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.2k
Forks
754
PR merge metrics
No merged PRs in 30d

Description

E721 (do not compare types, use 'isinstance()') has an exception that allows comparison for types which are not obvious. It uses isidentifier() to determine whether it is a variable. This will miss the cases where '.' is included, such as 'type(self.member1)'. So the warning will appear while it shouldn't.

Contributor guide

Open the contributing guide

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

Start by locating the E721 implementation and its isidentifier()-based exception logic in the repository. Reproduce the case involving type(self.member1), then add regression coverage showing that this comparison should not produce a warning; done means the test passes and the existing E721 behavior remains covered.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.