Description
This warning could potentially prevent bugs, so I'm pretty keen on putting in the effort to enable it.
Many people can work on this one together. To work on it, please:
- choose 2-3 files
- make sure you have
pylint
version 2.15.5 installed (pip install pylint==2.15.5
) - check this is the same as the number in the.pre-commit-config.yaml
file - for each file, run
pylint --disable=all --enable=redefined-outer-name <file>
- fix up the file until it passes
- stage, commit, push, open pull request
For example, suppose you choose the file pandas/io/json/_table_schema.py
. Running pylint
on it, you get:
$ pylint --disable=all --enable=redefined-outer-name pandas/io/json/_table_schema.py
************* Module pandas.io.json._table_schema
pandas/io/json/_table_schema.py:314:23: W0621: Redefining name 'json' from outer scope (line 15) (redefined-outer-name)
-----------------------------------
Your code has been rated at 9.92/10
If we look at that file, we see that there's a function
def parse_table_schema(json, precise_float):
which takes json
as an argument, but the file also has
from pandas._libs import json
at the top.
The simplest fix is probably to just modify the import to be
from pandas._libs.json import loads
and then to remove
pandas/pandas/io/json/_table_schema.py
Line 44 in f9ff379
as loads
is the only function used from pandas._libs.json
.
Other notes:
- multiple people can work on this issue at the same time, please don't comment 'take'
- please choose no more than 3 files to work on in the same PR. Comment which files you'd like to take so we don't duplicate work
It's probably worth running pylint
on a directory first to see what files need working on, e.g.
pylint --disable=all --enable=redefined-outer-name pandas/io/
Files that still need fixing:
- pandas/_version.py
- pandas/conftest.py
- pandas/core/generic.py
- pandas/core/internals/concat.py
- pandas/core/reshape/merge.py
- pandas/core/tools/datetimes.py
- pandas/io/formats/format.py
- pandas/io/formats/style.py
- pandas/io/json/_json.py
- pandas/io/xml.py
- pandas/util/_decorators.py
- pandas/util/_doctools.py
Let's ignore test files for now