Skip to content

STYLE: fix pylint redefined-oute-name warnings (pandas-dev#49656) #49668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/core/internals/concat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

import copy
import copy as _copy_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about import copy as stdlib_copy?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, i am working on that.

import itertools
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -691,7 +691,7 @@ def _trim_join_unit(join_unit: JoinUnit, length: int) -> JoinUnit:
else:
extra_block = join_unit.block

extra_indexers = copy.copy(join_unit.indexers)
extra_indexers = _copy_.copy(join_unit.indexers)
extra_indexers[0] = extra_indexers[0][length:]
join_unit.indexers[0] = join_unit.indexers[0][:length]

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/reshape/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
from __future__ import annotations

import copy
import copy as _copy_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above

import datetime
from functools import partial
import string
Expand Down Expand Up @@ -1637,7 +1637,7 @@ def get_join_indexers(

lkey, rkey, count = _factorize_keys(lkey, rkey, sort=sort, how=how)
# preserve left frame order if how == 'left' and sort == False
kwargs = copy.copy(kwargs)
kwargs = _copy_.copy(kwargs)
if how in ("left", "right"):
kwargs["sort"] = sort
join_func = {
Expand Down
32 changes: 16 additions & 16 deletions pandas/io/json/_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@

import numpy as np

from pandas._libs import json
from pandas._libs.json import (
loads,
dumps,
)
from pandas._libs.tslibs import iNaT
from pandas._typing import (
CompressionOptions,
Expand Down Expand Up @@ -73,9 +76,6 @@

FrameSeriesStrT = TypeVar("FrameSeriesStrT", bound=Literal["frame", "series"])

loads = json.loads
dumps = json.dumps


# interface to/from
@overload
Expand Down Expand Up @@ -912,7 +912,7 @@ def read(self) -> DataFrame | Series:
self.close()
return obj

def _get_object_parser(self, json) -> DataFrame | Series:
def _get_object_parser(self, json_object) -> DataFrame | Series:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you're no longer import json, then can this argument stay the same?

"""
Parses a json document into a pandas object.
"""
Expand All @@ -929,12 +929,12 @@ def _get_object_parser(self, json) -> DataFrame | Series:
}
obj = None
if typ == "frame":
obj = FrameParser(json, **kwargs).parse()
obj = FrameParser(json_object, **kwargs).parse()

if typ == "series" or obj is None:
if not isinstance(dtype, bool):
kwargs["dtype"] = dtype
obj = SeriesParser(json, **kwargs).parse()
obj = SeriesParser(json_object, **kwargs).parse()

return obj

Expand Down Expand Up @@ -1009,7 +1009,7 @@ class Parser:

def __init__(
self,
json,
json_object,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

orient,
dtype: DtypeArg | None = None,
convert_axes: bool = True,
Expand All @@ -1018,7 +1018,7 @@ def __init__(
precise_float: bool = False,
date_unit=None,
) -> None:
self.json = json
self.json_object = json_object

if orient is None:
orient = self._default_orient
Expand Down Expand Up @@ -1214,7 +1214,7 @@ class SeriesParser(Parser):
_split_keys = ("name", "index", "data")

def _parse(self) -> None:
data = loads(self.json, precise_float=self.precise_float)
data = loads(self.json_object, precise_float=self.precise_float)

if self.orient == "split":
decoded = {str(k): v for k, v in data.items()}
Expand All @@ -1239,31 +1239,31 @@ class FrameParser(Parser):

def _parse(self) -> None:

json = self.json
json_object = self.json_object
orient = self.orient

if orient == "columns":
self.obj = DataFrame(
loads(json, precise_float=self.precise_float), dtype=None
loads(json_object, precise_float=self.precise_float), dtype=None
)
elif orient == "split":
decoded = {
str(k): v
for k, v in loads(json, precise_float=self.precise_float).items()
for k, v in loads(json_object, precise_float=self.precise_float).items()
}
self.check_keys_split(decoded)
self.obj = DataFrame(dtype=None, **decoded)
elif orient == "index":
self.obj = DataFrame.from_dict(
loads(json, precise_float=self.precise_float),
loads(json_object, precise_float=self.precise_float),
dtype=None,
orient="index",
)
elif orient == "table":
self.obj = parse_table_schema(json, precise_float=self.precise_float)
self.obj = parse_table_schema(json_object, precise_float=self.precise_float)
else:
self.obj = DataFrame(
loads(json, precise_float=self.precise_float), dtype=None
loads(json_object, precise_float=self.precise_float), dtype=None
)

def _process_converter(self, f, filt=None) -> None:
Expand Down