The following issues were found

pandas/tests/arrays/period/test_arrow_compat.py
48 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

import pandas.util._test_decorators as td

from pandas.core.dtypes.dtypes import PeriodDtype

import pandas as pd
import pandas._testing as tm
from pandas.core.arrays import (

            

Reported by Pylint.

Unable to import 'pyarrow'
Error

Line: 41 Column: 5

                  ],
)
def test_arrow_array(data, freq):
    import pyarrow as pa

    from pandas.core.arrays._arrow_utils import ArrowPeriodType

    periods = period_array(data, freq=freq)
    result = pa.array(periods)

            

Reported by Pylint.

Unable to import 'pyarrow'
Error

Line: 67 Column: 5

              
@pyarrow_skip
def test_arrow_array_missing():
    import pyarrow as pa

    from pandas.core.arrays._arrow_utils import ArrowPeriodType

    arr = PeriodArray([1, 2, 3], freq="D")
    arr[1] = pd.NaT

            

Reported by Pylint.

Unable to import 'pyarrow'
Error

Line: 83 Column: 5

              
@pyarrow_skip
def test_arrow_table_roundtrip():
    import pyarrow as pa

    from pandas.core.arrays._arrow_utils import ArrowPeriodType

    arr = PeriodArray([1, 2, 3], freq="D")
    arr[1] = pd.NaT

            

Reported by Pylint.

Unable to import 'pyarrow'
Error

Line: 106 Column: 5

              @pyarrow_skip
def test_arrow_load_from_zero_chunks():
    # GH-41040
    import pyarrow as pa

    from pandas.core.arrays._arrow_utils import ArrowPeriodType

    arr = PeriodArray([], freq="D")
    df = pd.DataFrame({"a": arr})

            

Reported by Pylint.

Unable to import 'pyarrow'
Error

Line: 125 Column: 5

              
@pyarrow_skip
def test_arrow_table_roundtrip_without_metadata():
    import pyarrow as pa

    arr = PeriodArray([1, 2, 3], freq="H")
    arr[1] = pd.NaT
    df = pd.DataFrame({"a": arr})


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

import pandas.util._test_decorators as td

from pandas.core.dtypes.dtypes import PeriodDtype

import pandas as pd
import pandas._testing as tm
from pandas.core.arrays import (

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 1

              

@pyarrow_skip
def test_arrow_extension_type():
    from pandas.core.arrays._arrow_utils import ArrowPeriodType

    p1 = ArrowPeriodType("D")
    p2 = ArrowPeriodType("D")
    p3 = ArrowPeriodType("M")

            

Reported by Pylint.

Import outside toplevel (pandas.core.arrays._arrow_utils.ArrowPeriodType)
Error

Line: 19 Column: 5

              
@pyarrow_skip
def test_arrow_extension_type():
    from pandas.core.arrays._arrow_utils import ArrowPeriodType

    p1 = ArrowPeriodType("D")
    p2 = ArrowPeriodType("D")
    p3 = ArrowPeriodType("M")


            

Reported by Pylint.

Variable name "p1" doesn't conform to snake_case naming style
Error

Line: 21 Column: 5

              def test_arrow_extension_type():
    from pandas.core.arrays._arrow_utils import ArrowPeriodType

    p1 = ArrowPeriodType("D")
    p2 = ArrowPeriodType("D")
    p3 = ArrowPeriodType("M")

    assert p1.freq == "D"
    assert p1 == p2

            

Reported by Pylint.

pandas/tests/io/parser/common/test_file_buffer_url.py
48 issues
Unable to import 'pytest'
Error

Line: 13 Column: 1

              import platform
from urllib.error import URLError

import pytest

from pandas.errors import (
    EmptyDataError,
    ParserError,
)

            

Reported by Pylint.

TODO: FTP testing
Error

Line: 27 Column: 3

              
@tm.network
def test_url(all_parsers, csv_dir_path):
    # TODO: FTP testing
    parser = all_parsers
    kwargs = {"sep": "\t"}

    url = (
        "https://raw.github.com/pandas-dev/pandas/master/"

            

Reported by Pylint.

Access to a protected member _engine of a client class
Error

Line: 390 Column: 16

                  path = datapath("io", "data", "csv", "iris.csv")

    reader = parser.read_csv(path, chunksize=1)
    assert not reader._engine.handles.handle.closed
    try:
        with reader:
            next(reader)
            assert False
    except AssertionError:

            

Reported by Pylint.

Access to a protected member _engine of a client class
Error

Line: 396 Column: 16

                          next(reader)
            assert False
    except AssertionError:
        assert reader._engine.handles.handle.closed


def test_context_manageri_user_provided(all_parsers, datapath):
    # make sure that user-provided handles are not closed
    parser = all_parsers

            

Reported by Pylint.

Access to a protected member _engine of a client class
Error

Line: 406 Column: 20

                  with open(datapath("io", "data", "csv", "iris.csv")) as path:

        reader = parser.read_csv(path, chunksize=1)
        assert not reader._engine.handles.handle.closed
        try:
            with reader:
                next(reader)
                assert False
        except AssertionError:

            

Reported by Pylint.

Access to a protected member _engine of a client class
Error

Line: 412 Column: 24

                              next(reader)
                assert False
        except AssertionError:
            assert not reader._engine.handles.handle.closed


def test_file_descriptor_leak(all_parsers):
    # GH 31488


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 1

              

@tm.network
def test_url(all_parsers, csv_dir_path):
    # TODO: FTP testing
    parser = all_parsers
    kwargs = {"sep": "\t"}

    url = (

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 43 Column: 1

              

@pytest.mark.slow
def test_local_file(all_parsers, csv_dir_path):
    parser = all_parsers
    kwargs = {"sep": "\t"}

    local_path = os.path.join(csv_dir_path, "salaries.csv")
    local_result = parser.read_csv(local_path, **kwargs)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 59 Column: 1

                      pytest.skip("Failing on: " + " ".join(platform.uname()))


def test_path_path_lib(all_parsers):
    parser = all_parsers
    df = tm.makeDataFrame()
    result = tm.round_trip_pathlib(df.to_csv, lambda p: parser.read_csv(p, index_col=0))
    tm.assert_frame_equal(df, result)


            

Reported by Pylint.

Variable name "df" doesn't conform to snake_case naming style
Error

Line: 61 Column: 5

              
def test_path_path_lib(all_parsers):
    parser = all_parsers
    df = tm.makeDataFrame()
    result = tm.round_trip_pathlib(df.to_csv, lambda p: parser.read_csv(p, index_col=0))
    tm.assert_frame_equal(df, result)


def test_path_local_path(all_parsers):

            

Reported by Pylint.

pandas/tests/indexes/multi/test_names.py
48 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

import pandas as pd
from pandas import MultiIndex
import pandas._testing as tm


def check_level_names(index, names):
    assert [level.name for level in index.levels] == list(names)

            

Reported by Pylint.

Instance of 'tuple' has no 'names' member
Error

Line: 14 Column: 12

              
def test_slice_keep_name():
    x = MultiIndex.from_tuples([("a", "b"), (1, 2), ("c", "d")], names=["x", "y"])
    assert x[1:].names == x.names


def test_index_name_retained():
    # GH9857
    result = pd.DataFrame({"x": [1, 2, 6], "y": [2, 2, 8], "z": [-5, 0, 5]})

            

Reported by Pylint.

Access to a protected member _view of a client class
Error

Line: 34 Column: 20

              
    view = idx.view()
    copy = idx.copy()
    shallow_copy = idx._view()

    # changing names should not change level names on object
    new_names = [name + "a" for name in idx.names]
    idx.names = new_names
    check_level_names(idx, ["firsta", "seconda"])

            

Reported by Pylint.

Access to a protected member _get_level_number of a client class
Error

Line: 128 Column: 9

                  # GH19029
    idx.names = ["foo", "foo"]
    with pytest.raises(ValueError, match="name foo occurs multiple times"):
        idx._get_level_number("foo")


def test_get_names_from_levels():
    idx = MultiIndex.from_product([["a"], [1, 2]], names=["a", "b"])


            

Reported by Pylint.

Access to a protected member _no_setting_name of a client class
Error

Line: 150 Column: 12

                  with pytest.raises(RuntimeError, match="set_names"):
        new.index.name = "bar"

    assert pd.Index._no_setting_name is False
    assert pd.Int64Index._no_setting_name is False
    assert pd.RangeIndex._no_setting_name is False


@pytest.mark.parametrize("func", ["rename", "set_names"])

            

Reported by Pylint.

Access to a protected member _no_setting_name of a client class
Error

Line: 151 Column: 12

                      new.index.name = "bar"

    assert pd.Index._no_setting_name is False
    assert pd.Int64Index._no_setting_name is False
    assert pd.RangeIndex._no_setting_name is False


@pytest.mark.parametrize("func", ["rename", "set_names"])
@pytest.mark.parametrize(

            

Reported by Pylint.

Access to a protected member _no_setting_name of a client class
Error

Line: 152 Column: 12

              
    assert pd.Index._no_setting_name is False
    assert pd.Int64Index._no_setting_name is False
    assert pd.RangeIndex._no_setting_name is False


@pytest.mark.parametrize("func", ["rename", "set_names"])
@pytest.mark.parametrize(
    "rename_dict, exp_names",

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

import pandas as pd
from pandas import MultiIndex
import pandas._testing as tm


def check_level_names(index, names):
    assert [level.name for level in index.levels] == list(names)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              import pandas._testing as tm


def check_level_names(index, names):
    assert [level.name for level in index.levels] == list(names)


def test_slice_keep_name():
    x = MultiIndex.from_tuples([("a", "b"), (1, 2), ("c", "d")], names=["x", "y"])

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 9
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              

def check_level_names(index, names):
    assert [level.name for level in index.levels] == list(names)


def test_slice_keep_name():
    x = MultiIndex.from_tuples([("a", "b"), (1, 2), ("c", "d")], names=["x", "y"])
    assert x[1:].names == x.names

            

Reported by Bandit.

pandas/core/computation/ops.py
48 issues
Unused argument 'side'
Error

Line: 83 Column: 33

              

class Term:
    def __new__(cls, name, env, side=None, encoding=None):
        klass = Constant if not isinstance(name, str) else cls
        # error: Argument 2 for "super" not an instance of argument 1
        supr_new = super(Term, klass).__new__  # type: ignore[misc]
        return supr_new(klass)


            

Reported by Pylint.

Unused argument 'env'
Error

Line: 83 Column: 28

              

class Term:
    def __new__(cls, name, env, side=None, encoding=None):
        klass = Constant if not isinstance(name, str) else cls
        # error: Argument 2 for "super" not an instance of argument 1
        supr_new = super(Term, klass).__new__  # type: ignore[misc]
        return supr_new(klass)


            

Reported by Pylint.

Unused argument 'encoding'
Error

Line: 83 Column: 44

              

class Term:
    def __new__(cls, name, env, side=None, encoding=None):
        klass = Constant if not isinstance(name, str) else cls
        # error: Argument 2 for "super" not an instance of argument 1
        supr_new = super(Term, klass).__new__  # type: ignore[misc]
        return supr_new(klass)


            

Reported by Pylint.

Unused argument 'kwargs'
Error

Line: 111 Column: 1

                  def __call__(self, *args, **kwargs):
        return self.value

    def evaluate(self, *args, **kwargs):
        return self

    def _resolve_name(self):
        res = self.env.resolve(self.local_name, is_local=self.is_local)
        self.update(res)

            

Reported by Pylint.

Unused argument 'args'
Error

Line: 111 Column: 1

                  def __call__(self, *args, **kwargs):
        return self.value

    def evaluate(self, *args, **kwargs):
        return self

    def _resolve_name(self):
        res = self.env.resolve(self.local_name, is_local=self.is_local)
        self.update(res)

            

Reported by Pylint.

Redefining built-in 'eval'
Error

Line: 457 Column: 17

                          if self.op in eval_in_python:
                res = self.func(left.value, right.value)
            else:
                from pandas.core.computation.eval import eval

                res = eval(self, local_dict=env, engine=engine, parser=parser)

        name = env.add_tmp(res)
        return term_type(name, env=env)

            

Reported by Pylint.

Missing class docstring
Error

Line: 82 Column: 1

                      super().__init__(msg)


class Term:
    def __new__(cls, name, env, side=None, encoding=None):
        klass = Constant if not isinstance(name, str) else cls
        # error: Argument 2 for "super" not an instance of argument 1
        supr_new = super(Term, klass).__new__  # type: ignore[misc]
        return supr_new(klass)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 102 Column: 5

                      self.encoding = encoding

    @property
    def local_name(self) -> str:
        return self.name.replace(LOCAL_TAG, "")

    def __repr__(self) -> str:
        return pprint_thing(self.name)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 111 Column: 5

                  def __call__(self, *args, **kwargs):
        return self.value

    def evaluate(self, *args, **kwargs):
        return self

    def _resolve_name(self):
        res = self.env.resolve(self.local_name, is_local=self.is_local)
        self.update(res)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 143 Column: 5

                      self.value = value

    @property
    def is_scalar(self) -> bool:
        return is_scalar(self._value)

    @property
    def type(self):
        try:

            

Reported by Pylint.

pandas/core/arrays/string_arrow.py
48 issues
No name 'lib' in module 'pandas._libs'
Error

Line: 14 Column: 1

              
import numpy as np

from pandas._libs import lib
from pandas._typing import (
    Dtype,
    NpDtype,
    PositionalIndexer,
    Scalar,

            

Reported by Pylint.

Unable to import 'pyarrow'
Error

Line: 64 Column: 5

              # file is imported from even if pyarrow is < 1.0.0, before pyarrow.compute
# and its compute functions existed. GH38801
if not pa_version_under1p0:
    import pyarrow as pa
    import pyarrow.compute as pc

    ARROW_CMP_FUNCS = {
        "eq": pc.equal,
        "ne": pc.not_equal,

            

Reported by Pylint.

Unable to import 'pyarrow.compute'
Error

Line: 65 Column: 5

              # and its compute functions existed. GH38801
if not pa_version_under1p0:
    import pyarrow as pa
    import pyarrow.compute as pc

    ARROW_CMP_FUNCS = {
        "eq": pc.equal,
        "ne": pc.not_equal,
        "lt": pc.less,

            

Reported by Pylint.

TODO: Inherit directly from BaseStringArrayMethods. Currently we inherit from
Error

Line: 87 Column: 3

                      raise ImportError(msg)


# TODO: Inherit directly from BaseStringArrayMethods. Currently we inherit from
# ObjectStringArrayMixin because we want to have the object-dtype based methods as
# fallback for the ones that pyarrow doesn't yet support


class ArrowStringArray(OpsMixin, BaseStringArray, ObjectStringArrayMixin):

            

Reported by Pylint.

Parameters differ from overridden '_from_sequence' method
Error

Line: 151 Column: 5

                          )

    @classmethod
    def _from_sequence(cls, scalars, dtype: Dtype | None = None, copy: bool = False):
        from pandas.core.arrays.masked import BaseMaskedArray

        _chk_pyarrow_available()

        if dtype and not (isinstance(dtype, str) and dtype == "string"):

            

Reported by Pylint.

Access to a protected member _mask of a client class
Error

Line: 163 Column: 25

                      if isinstance(scalars, BaseMaskedArray):
            # avoid costly conversion to object dtype in ensure_string_array and
            # numerical issues with Float32Dtype
            na_values = scalars._mask
            result = scalars._data
            result = lib.ensure_string_array(result, copy=copy, convert_na_value=False)
            return cls(pa.array(result, mask=na_values, type=pa.string()))

        # convert non-na-likes to str

            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 164 Column: 22

                          # avoid costly conversion to object dtype in ensure_string_array and
            # numerical issues with Float32Dtype
            na_values = scalars._mask
            result = scalars._data
            result = lib.ensure_string_array(result, copy=copy, convert_na_value=False)
            return cls(pa.array(result, mask=na_values, type=pa.string()))

        # convert non-na-likes to str
        result = lib.ensure_string_array(scalars, copy=copy)

            

Reported by Pylint.

Parameters differ from overridden '_from_sequence_of_strings' method
Error

Line: 173 Column: 5

                      return cls(pa.array(result, type=pa.string(), from_pandas=True))

    @classmethod
    def _from_sequence_of_strings(
        cls, strings, dtype: Dtype | None = None, copy: bool = False
    ):
        return cls._from_sequence(strings, dtype=dtype, copy=copy)

    @property

            

Reported by Pylint.

Redefining built-in 'type'
Error

Line: 189 Column: 31

                      """Correctly construct numpy arrays when passed to `np.asarray()`."""
        return self.to_numpy(dtype=dtype)

    def __arrow_array__(self, type=None):
        """Convert myself to a pyarrow Array or ChunkedArray."""
        return self._data

    # error: Argument 1 of "to_numpy" is incompatible with supertype "ExtensionArray";
    # supertype defines the argument type as "Union[ExtensionDtype, str, dtype[Any],

            

Reported by Pylint.

Unused argument 'type'
Error

Line: 189 Column: 31

                      """Correctly construct numpy arrays when passed to `np.asarray()`."""
        return self.to_numpy(dtype=dtype)

    def __arrow_array__(self, type=None):
        """Convert myself to a pyarrow Array or ChunkedArray."""
        return self._data

    # error: Argument 1 of "to_numpy" is incompatible with supertype "ExtensionArray";
    # supertype defines the argument type as "Union[ExtensionDtype, str, dtype[Any],

            

Reported by Pylint.

pandas/tests/series/methods/test_rename.py
47 issues
FIXME: dont leave commenred-out
Error

Line: 65 Column: 3

                      s = Series(range(5))
        s.rename({}, axis=0)
        s.rename({}, axis="index")
        # FIXME: dont leave commenred-out
        # TODO: clean up shared index validation
        # with pytest.raises(ValueError, match="No axis named 5"):
        #     s.rename({}, axis=5)

    def test_rename_inplace(self, datetime_series):

            

Reported by Pylint.

TODO: clean up shared index validation
Error

Line: 66 Column: 3

                      s.rename({}, axis=0)
        s.rename({}, axis="index")
        # FIXME: dont leave commenred-out
        # TODO: clean up shared index validation
        # with pytest.raises(ValueError, match="No axis named 5"):
        #     s.rename({}, axis=5)

    def test_rename_inplace(self, datetime_series):
        renamer = lambda x: x.strftime("%Y%m%d")

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 100 Column: 29

                      # GH 17407
        s = Series(range(1, 6), index=Index(range(2, 7), name="IntIndex"))
        result = s.rename(str)
        expected = s.rename(lambda i: str(i))
        tm.assert_series_equal(result, expected)

        assert result.name == expected.name

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from datetime import datetime

import numpy as np

from pandas import (
    Index,
    Series,
)
import pandas._testing as tm

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              import pandas._testing as tm


class TestRename:
    def test_rename(self, datetime_series):
        ts = datetime_series
        renamer = lambda x: x.strftime("%Y%m%d")
        renamed = ts.rename(renamer)
        assert renamed.index[0] == renamer(ts.index[0])

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 5

              

class TestRename:
    def test_rename(self, datetime_series):
        ts = datetime_series
        renamer = lambda x: x.strftime("%Y%m%d")
        renamed = ts.rename(renamer)
        assert renamed.index[0] == renamer(ts.index[0])


            

Reported by Pylint.

Method could be a function
Error

Line: 13 Column: 5

              

class TestRename:
    def test_rename(self, datetime_series):
        ts = datetime_series
        renamer = lambda x: x.strftime("%Y%m%d")
        renamed = ts.rename(renamer)
        assert renamed.index[0] == renamer(ts.index[0])


            

Reported by Pylint.

Variable name "ts" doesn't conform to snake_case naming style
Error

Line: 14 Column: 9

              
class TestRename:
    def test_rename(self, datetime_series):
        ts = datetime_series
        renamer = lambda x: x.strftime("%Y%m%d")
        renamed = ts.rename(renamer)
        assert renamed.index[0] == renamer(ts.index[0])

        # dict

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 17
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      ts = datetime_series
        renamer = lambda x: x.strftime("%Y%m%d")
        renamed = ts.rename(renamer)
        assert renamed.index[0] == renamer(ts.index[0])

        # dict
        rename_dict = dict(zip(ts.index, renamed.index))
        renamed2 = ts.rename(rename_dict)
        tm.assert_series_equal(renamed, renamed2)

            

Reported by Bandit.

Variable name "s" doesn't conform to snake_case naming style
Error

Line: 25 Column: 9

                      tm.assert_series_equal(renamed, renamed2)

        # partial dict
        s = Series(np.arange(4), index=["a", "b", "c", "d"], dtype="int64")
        renamed = s.rename({"b": "foo", "d": "bar"})
        tm.assert_index_equal(renamed.index, Index(["a", "foo", "c", "bar"]))

        # index with name
        renamer = Series(

            

Reported by Pylint.

pandas/tests/extension/test_integer.py
47 issues
Unable to import 'pytest'
Error

Line: 17 Column: 1

              
"""
import numpy as np
import pytest

import pandas as pd
import pandas._testing as tm
from pandas.api.types import (
    is_extension_array_dtype,

            

Reported by Pylint.

Redefining name 'dtype' from outer scope (line 52)
Error

Line: 59 Column: 10

              

@pytest.fixture
def data(dtype):
    return pd.array(make_data(), dtype=dtype)


@pytest.fixture
def data_for_twos(dtype):

            

Reported by Pylint.

Redefining name 'dtype' from outer scope (line 52)
Error

Line: 64 Column: 19

              

@pytest.fixture
def data_for_twos(dtype):
    return pd.array(np.ones(100) * 2, dtype=dtype)


@pytest.fixture
def data_missing(dtype):

            

Reported by Pylint.

Redefining name 'dtype' from outer scope (line 52)
Error

Line: 69 Column: 18

              

@pytest.fixture
def data_missing(dtype):
    return pd.array([pd.NA, 1], dtype=dtype)


@pytest.fixture
def data_for_sorting(dtype):

            

Reported by Pylint.

Redefining name 'dtype' from outer scope (line 52)
Error

Line: 74 Column: 22

              

@pytest.fixture
def data_for_sorting(dtype):
    return pd.array([1, 2, 0], dtype=dtype)


@pytest.fixture
def data_missing_for_sorting(dtype):

            

Reported by Pylint.

Redefining name 'dtype' from outer scope (line 52)
Error

Line: 79 Column: 30

              

@pytest.fixture
def data_missing_for_sorting(dtype):
    return pd.array([1, pd.NA, 0], dtype=dtype)


@pytest.fixture
def na_cmp():

            

Reported by Pylint.

Redefining name 'dtype' from outer scope (line 52)
Error

Line: 95 Column: 23

              

@pytest.fixture
def data_for_grouping(dtype):
    b = 1
    a = 0
    c = 2
    na = pd.NA
    return pd.array([b, b, na, na, a, a, b, c], dtype=dtype)

            

Reported by Pylint.

Parameters differ from overridden 'test_is_dtype_unboxes_dtype' method
Error

Line: 105 Column: 5

              
class TestDtype(base.BaseDtypeTests):
    @pytest.mark.skip(reason="using multiple dtypes")
    def test_is_dtype_unboxes_dtype(self):
        # we have multiple dtypes, so skip
        pass


class TestArithmeticOps(base.BaseArithmeticOpsTests):

            

Reported by Pylint.

TODO see https://github.com/pandas-dev/pandas/issues/22023
Error

Line: 119 Column: 3

                      if exc is None:
            sdtype = tm.get_dtype(s)
            if sdtype.is_unsigned_integer and (op_name == "__rsub__"):
                # TODO see https://github.com/pandas-dev/pandas/issues/22023
                pytest.skip("unsigned subtraction gives negative values")

            if (
                hasattr(other, "dtype")
                and not is_extension_array_dtype(other.dtype)

            

Reported by Pylint.

TODO reverse operators result in object dtype
Error

Line: 137 Column: 3

                          if op_name in ("__rtruediv__", "__truediv__", "__div__"):
                expected = expected.fillna(np.nan).astype("Float64")
            elif op_name.startswith("__r"):
                # TODO reverse operators result in object dtype
                # see https://github.com/pandas-dev/pandas/issues/22024
                expected = expected.astype(sdtype)
                result = result.astype(sdtype)
            else:
                # combine method result in 'biggest' (int64) dtype

            

Reported by Pylint.

pandas/tests/io/pytables/test_put.py
47 issues
Unable to import 'pytest'
Error

Line: 9 Column: 1

              )

import numpy as np
import pytest

from pandas._libs.tslibs import Timestamp

import pandas as pd
from pandas import (

            

Reported by Pylint.

Access to a protected member _consolidate of a client class
Error

Line: 208 Column: 10

                  df["datetime1"] = datetime.datetime(2001, 1, 2, 0, 0)
    df["datetime2"] = datetime.datetime(2001, 1, 3, 0, 0)
    df.loc[df.index[3:6], ["obj1"]] = np.nan
    df = df._consolidate()._convert(datetime=True)

    with ensure_clean_store(setup_path) as store:
        _maybe_remove(store, "df")

        # PerformanceWarning

            

Reported by Pylint.

Access to a protected member _convert of a client class
Error

Line: 208 Column: 10

                  df["datetime1"] = datetime.datetime(2001, 1, 2, 0, 0)
    df["datetime2"] = datetime.datetime(2001, 1, 3, 0, 0)
    df.loc[df.index[3:6], ["obj1"]] = np.nan
    df = df._consolidate()._convert(datetime=True)

    with ensure_clean_store(setup_path) as store:
        _maybe_remove(store, "df")

        # PerformanceWarning

            

Reported by Pylint.

Redefining built-in 'format'
Error

Line: 228 Column: 19

              
    with ensure_clean_store(setup_path) as store:

        def check(format, index):
            df = DataFrame(np.random.randn(10, 2), columns=list("AB"))
            df.index = index(len(df))

            _maybe_remove(store, "df")
            store.put("df", df, format=format)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import datetime
import re
from warnings import (
    catch_warnings,
    simplefilter,
)

import numpy as np
import pytest

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 35 Column: 1

              pytestmark = pytest.mark.single


def test_format_type(setup_path):
    df = DataFrame({"A": [1, 2]})
    with ensure_clean_path(setup_path) as path:
        with HDFStore(path) as store:
            store.put("a", df, format="fixed")
            store.put("b", df, format="table")

            

Reported by Pylint.

Variable name "df" doesn't conform to snake_case naming style
Error

Line: 36 Column: 5

              

def test_format_type(setup_path):
    df = DataFrame({"A": [1, 2]})
    with ensure_clean_path(setup_path) as path:
        with HDFStore(path) as store:
            store.put("a", df, format="fixed")
            store.put("b", df, format="table")


            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 42
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                          store.put("a", df, format="fixed")
            store.put("b", df, format="table")

            assert store.get_storer("a").format_type == "fixed"
            assert store.get_storer("b").format_type == "table"


def test_format_kwarg_in_constructor(setup_path):
    # GH 13291

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 43
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                          store.put("b", df, format="table")

            assert store.get_storer("a").format_type == "fixed"
            assert store.get_storer("b").format_type == "table"


def test_format_kwarg_in_constructor(setup_path):
    # GH 13291


            

Reported by Bandit.

Missing function or method docstring
Error

Line: 46 Column: 1

                          assert store.get_storer("b").format_type == "table"


def test_format_kwarg_in_constructor(setup_path):
    # GH 13291

    msg = "format is not a defined argument for HDFStore"

    with tm.ensure_clean(setup_path) as path:

            

Reported by Pylint.

pandas/tests/io/json/test_readlines.py
47 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              from io import StringIO
from pathlib import Path

import pytest

import pandas as pd
from pandas import (
    DataFrame,
    read_json,

            

Reported by Pylint.

Redefining name 'lines_json_df' from outer scope (line 17)
Error

Line: 92 Column: 26

              

@pytest.mark.parametrize("chunksize", [1, 1.0])
def test_readjson_chunks(lines_json_df, chunksize):
    # Basic test that read_json(chunks=True) gives the same result as
    # read_json(chunks=False)
    # GH17048: memory usage when lines=True

    unchunked = read_json(StringIO(lines_json_df), lines=True)

            

Reported by Pylint.

Redefining name 'lines_json_df' from outer scope (line 17)
Error

Line: 104 Column: 44

                  tm.assert_frame_equal(chunked, unchunked)


def test_readjson_chunksize_requires_lines(lines_json_df):
    msg = "chunksize can only be passed if lines=True"
    with pytest.raises(ValueError, match=msg):
        with read_json(StringIO(lines_json_df), lines=False, chunksize=2) as _:
            pass


            

Reported by Pylint.

Redefining name 'lines_json_df' from outer scope (line 17)
Error

Line: 125 Column: 30

                  tm.assert_series_equal(chunked, unchunked)


def test_readjson_each_chunk(lines_json_df):
    # Other tests check that the final result of read_json(chunksize=True)
    # is correct. This checks the intermediate chunks.
    with read_json(StringIO(lines_json_df), lines=True, chunksize=2) as reader:
        chunks = list(reader)
    assert chunks[0].shape == (2, 2)

            

Reported by Pylint.

Redefining name 'lines_json_df' from outer scope (line 17)
Error

Line: 174 Column: 37

              

@pytest.mark.parametrize("chunksize", [0, -1, 2.2, "foo"])
def test_readjson_invalid_chunksize(lines_json_df, chunksize):
    msg = r"'chunksize' must be an integer >=1"

    with pytest.raises(ValueError, match=msg):
        with read_json(StringIO(lines_json_df), lines=True, chunksize=chunksize) as _:
            pass

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from io import StringIO
from pathlib import Path

import pytest

import pandas as pd
from pandas import (
    DataFrame,
    read_json,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 1

              

@pytest.fixture
def lines_json_df():
    df = DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
    return df.to_json(lines=True, orient="records")


def test_read_jsonl():

            

Reported by Pylint.

Variable name "df" doesn't conform to snake_case naming style
Error

Line: 18 Column: 5

              
@pytest.fixture
def lines_json_df():
    df = DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
    return df.to_json(lines=True, orient="records")


def test_read_jsonl():
    # GH9180

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 1

                  return df.to_json(lines=True, orient="records")


def test_read_jsonl():
    # GH9180
    result = read_json('{"a": 1, "b": 2}\n{"b":2, "a" :1}\n', lines=True)
    expected = DataFrame([[1, 2], [1, 2]], columns=["a", "b"])
    tm.assert_frame_equal(result, expected)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 29 Column: 1

                  tm.assert_frame_equal(result, expected)


def test_read_datetime():
    # GH33787
    df = DataFrame(
        [([1, 2], ["2020-03-05", "2020-04-08T09:58:49+00:00"], "hector")],
        columns=["accounts", "date", "name"],
    )

            

Reported by Pylint.

pandas/tests/arrays/sparse/test_dtype.py
47 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import re

import numpy as np
import pytest

import pandas as pd
from pandas.core.arrays.sparse import SparseDtype



            

Reported by Pylint.

Access to a protected member _is_numeric of a client class
Error

Line: 102 Column: 12

                  ],
)
def test_is_numeric(dtype, expected):
    assert dtype._is_numeric is expected


def test_str_uses_object():
    result = SparseDtype(str).subtype
    assert result == np.dtype("object")

            

Reported by Pylint.

Access to a protected member _parse_subtype of a client class
Error

Line: 155 Column: 18

                  ],
)
def test_parse_subtype(string, expected):
    subtype, _ = SparseDtype._parse_subtype(string)
    assert subtype == expected


@pytest.mark.parametrize(
    "string", ["Sparse[int, 1]", "Sparse[float, 0.0]", "Sparse[bool, True]"]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import re

import numpy as np
import pytest

import pandas as pd
from pandas.core.arrays.sparse import SparseDtype



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 1

                      ("object", np.nan),
        ("datetime64[ns]", np.datetime64("NaT", "ns")),
        ("timedelta64[ns]", np.timedelta64("NaT", "ns")),
    ],
)
def test_inferred_dtype(dtype, fill_value):
    sparse_dtype = SparseDtype(dtype)
    result = sparse_dtype.fill_value
    if pd.isna(fill_value):

            

Reported by Pylint.

Using type() instead of isinstance() for a typecheck.
Error

Line: 25 Column: 36

                  sparse_dtype = SparseDtype(dtype)
    result = sparse_dtype.fill_value
    if pd.isna(fill_value):
        assert pd.isna(result) and type(result) == type(fill_value)
    else:
        assert result == fill_value


def test_from_sparse_dtype():

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 25
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  sparse_dtype = SparseDtype(dtype)
    result = sparse_dtype.fill_value
    if pd.isna(fill_value):
        assert pd.isna(result) and type(result) == type(fill_value)
    else:
        assert result == fill_value


def test_from_sparse_dtype():

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 27
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  if pd.isna(fill_value):
        assert pd.isna(result) and type(result) == type(fill_value)
    else:
        assert result == fill_value


def test_from_sparse_dtype():
    dtype = SparseDtype("float", 0)
    result = SparseDtype(dtype)

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 30 Column: 1

                      assert result == fill_value


def test_from_sparse_dtype():
    dtype = SparseDtype("float", 0)
    result = SparseDtype(dtype)
    assert result.fill_value == 0



            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 33
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              def test_from_sparse_dtype():
    dtype = SparseDtype("float", 0)
    result = SparseDtype(dtype)
    assert result.fill_value == 0


def test_from_sparse_dtype_fill_value():
    dtype = SparseDtype("int", 1)
    result = SparseDtype(dtype, fill_value=2)

            

Reported by Bandit.