Add error on imports inside class definitions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.2k
- Forks
- 754
- PR merge metrics
- No merged PRs in 30d
Description
Opening a new issue for this based on discussion from @ncoghlan on issue #304 .
Flagging module level imports that don't occur at the start of the file and imports inside class definitions as errors seem like reasonable additions to me. The latter is technically going beyond the text of the PEP itself, but I'd be incredibly surprised if anyone complained about you flagging it as an error - while imports at class scope are permitted by the language, deliberately adding a module as a class attribute would just be weird.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading issue #304 and the repository's single Python file to find the existing checks for module-level imports. Determine where imports inside class definitions are identified and review any nearby tests, if present. Done means the checker reports class-scope imports as errors without changing the handling of permitted imports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100