Warn on unnecessary use of `global`
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start by inspecting the repository's existing lint-rule implementations and tests; no specific files or entry points are named in the issue. The change is complete when code that declares global only to read a name produces a warning, while declarations needed for assignment do not.
Written by the indexing model from the issue text.
Description
CONSTANT = 1
def fn(x):
global CONSTANT # <- unnecessary, unidiomatic, and a (small) performance hit
return x + CONSTANT
The global statement is only required when assigning to a global variable; you can reference outer namespaces without it. I think it'd be nice to have a lint rule that pointed this out, to help newer Pythonistas understand how scoping works.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 147
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 39
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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.
More from PyCQA/flake8-bugbear
-
Difficulty 3/5 1-2 days Newbie friendliness 44/100
PyCQA/flake8-bugbear#620 · 4 comments ·
Maintainers usually reply within 2 days
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
PyCQA/flake8-bugbear#538 · 4 comments ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
PyCQA/flake8-bugbear#536 ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
PyCQA/flake8-bugbear#467 · 7 comments · 1 reaction ·
Maintainers usually reply within 2 days
-
B909 improvementsOpen
Difficulty 5/5 Over a week Newbie friendliness 25/100
PyCQA/flake8-bugbear#454 · 4 comments · 1 reaction ·
Maintainers usually reply within 2 days
All issues in PyCQA/flake8-bugbear
Similar issues
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
NatLabRockies/openstudio-mcp#286 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
intersystems/ipm#1338 ·
Maintainers usually reply within 1 day
-
separate_packages splits imports from the same explicitly configured packagePossibly taken @rahul05ranjan claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
The v0-through-v1 path derives ShutdownDuration its own way, silently overriding a user's definitionOpenv1
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day