The following issues were found

pandas/tests/groupby/test_libgroupby.py
28 issues
No name 'groupby' in module 'pandas._libs'
Error

Line: 3 Column: 1

              import numpy as np

from pandas._libs import groupby as libgroupby
from pandas._libs.groupby import (
    group_cumprod_float64,
    group_cumsum,
    group_var,
)


            

Reported by Pylint.

Unable to import 'pandas._libs.groupby'
Error

Line: 4 Column: 1

              import numpy as np

from pandas._libs import groupby as libgroupby
from pandas._libs.groupby import (
    group_cumprod_float64,
    group_cumsum,
    group_var,
)


            

Reported by Pylint.

No name 'groupby' in module 'pandas._libs'
Error

Line: 4 Column: 1

              import numpy as np

from pandas._libs import groupby as libgroupby
from pandas._libs.groupby import (
    group_cumprod_float64,
    group_cumsum,
    group_var,
)


            

Reported by Pylint.

Module 'numpy.random' has no 'RandomState' member
Error

Line: 18 Column: 16

              
class GroupVarTestMixin:
    def test_group_var_generic_1d(self):
        prng = np.random.RandomState(1234)

        out = (np.nan * np.ones((5, 1))).astype(self.dtype)
        counts = np.zeros(5, dtype="int64")
        values = 10 * prng.rand(15, 1).astype(self.dtype)
        labels = np.tile(np.arange(5), (3,)).astype("intp")

            

Reported by Pylint.

Module 'numpy.random' has no 'RandomState' member
Error

Line: 35 Column: 16

                      tm.assert_numpy_array_equal(counts, expected_counts)

    def test_group_var_generic_1d_flat_labels(self):
        prng = np.random.RandomState(1234)

        out = (np.nan * np.ones((1, 1))).astype(self.dtype)
        counts = np.zeros(1, dtype="int64")
        values = 10 * prng.rand(5, 1).astype(self.dtype)
        labels = np.zeros(5, dtype="intp")

            

Reported by Pylint.

Module 'numpy.random' has no 'RandomState' member
Error

Line: 51 Column: 16

                      tm.assert_numpy_array_equal(counts, expected_counts)

    def test_group_var_generic_2d_all_finite(self):
        prng = np.random.RandomState(1234)

        out = (np.nan * np.ones((5, 2))).astype(self.dtype)
        counts = np.zeros(5, dtype="int64")
        values = 10 * prng.rand(10, 2).astype(self.dtype)
        labels = np.tile(np.arange(5), (2,)).astype("intp")

            

Reported by Pylint.

Module 'numpy.random' has no 'RandomState' member
Error

Line: 66 Column: 16

                      tm.assert_numpy_array_equal(counts, expected_counts)

    def test_group_var_generic_2d_some_nan(self):
        prng = np.random.RandomState(1234)

        out = (np.nan * np.ones((5, 2))).astype(self.dtype)
        counts = np.zeros(5, dtype="int64")
        values = 10 * prng.rand(10, 2).astype(self.dtype)
        values[:, 1] = np.nan

            

Reported by Pylint.

Module 'numpy.random' has no 'RandomState' member
Error

Line: 109 Column: 16

                  rtol = 1e-5

    def test_group_var_large_inputs(self):
        prng = np.random.RandomState(1234)

        out = np.array([[np.nan]], dtype=self.dtype)
        counts = np.array([0], dtype="int64")
        values = (prng.rand(10 ** 6) + 10 ** 12).astype(self.dtype)
        values.shape = (10 ** 6, 1)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np

from pandas._libs import groupby as libgroupby
from pandas._libs.groupby import (
    group_cumprod_float64,
    group_cumsum,
    group_var,
)


            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              import pandas._testing as tm


class GroupVarTestMixin:
    def test_group_var_generic_1d(self):
        prng = np.random.RandomState(1234)

        out = (np.nan * np.ones((5, 1))).astype(self.dtype)
        counts = np.zeros(5, dtype="int64")

            

Reported by Pylint.

pandas/tests/io/formats/test_eng_formatting.py
28 issues
Redefining built-in 'input'
Error

Line: 36 Column: 34

              
        tm.reset_display_options()

    def compare(self, formatter, input, output):
        formatted_input = formatter(input)
        assert formatted_input == output

    def compare_all(self, formatter, in_out):
        """

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 51 Column: 13

                      *number* should be >= 0 because formatter(-number) == fmt is also
        tested. *fmt* is derived from *expected_formatting*
        """
        for input, output in in_out:
            self.compare(formatter, input, output)
            self.compare(formatter, -input, "-" + output[1:])

    def test_exponents_with_eng_prefix(self):
        formatter = fmt.EngFormatter(accuracy=3, use_eng_prefix=True)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np

from pandas import DataFrame
import pandas._testing as tm

import pandas.io.formats.format as fmt


class TestEngFormatter:

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              import pandas.io.formats.format as fmt


class TestEngFormatter:
    def test_eng_float_formatter(self):
        df = DataFrame({"A": [1.41, 141.0, 14100, 1410000.0]})

        fmt.set_eng_float_format()
        result = df.to_string()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 5

              

class TestEngFormatter:
    def test_eng_float_formatter(self):
        df = DataFrame({"A": [1.41, 141.0, 14100, 1410000.0]})

        fmt.set_eng_float_format()
        result = df.to_string()
        expected = (

            

Reported by Pylint.

Method could be a function
Error

Line: 10 Column: 5

              

class TestEngFormatter:
    def test_eng_float_formatter(self):
        df = DataFrame({"A": [1.41, 141.0, 14100, 1410000.0]})

        fmt.set_eng_float_format()
        result = df.to_string()
        expected = (

            

Reported by Pylint.

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

Line: 11 Column: 9

              
class TestEngFormatter:
    def test_eng_float_formatter(self):
        df = DataFrame({"A": [1.41, 141.0, 14100, 1410000.0]})

        fmt.set_eng_float_format()
        result = df.to_string()
        expected = (
            "             A\n"

            

Reported by Pylint.

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

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

                          "2   14.100E+03\n"
            "3    1.410E+06"
        )
        assert result == expected

        fmt.set_eng_float_format(use_eng_prefix=True)
        result = df.to_string()
        expected = "         A\n0    1.410\n1  141.000\n2  14.100k\n3   1.410M"
        assert result == expected

            

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

                      fmt.set_eng_float_format(use_eng_prefix=True)
        result = df.to_string()
        expected = "         A\n0    1.410\n1  141.000\n2  14.100k\n3   1.410M"
        assert result == expected

        fmt.set_eng_float_format(accuracy=0)
        result = df.to_string()
        expected = "         A\n0    1E+00\n1  141E+00\n2   14E+03\n3    1E+06"
        assert result == expected

            

Reported by Bandit.

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

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

                      fmt.set_eng_float_format(accuracy=0)
        result = df.to_string()
        expected = "         A\n0    1E+00\n1  141E+00\n2   14E+03\n3    1E+06"
        assert result == expected

        tm.reset_display_options()

    def compare(self, formatter, input, output):
        formatted_input = formatter(input)

            

Reported by Bandit.

pandas/tests/frame/methods/test_equals.py
28 issues
Access to a protected member _mgr of a client class
Error

Line: 24 Column: 20

                      if not using_array_manager:
            # this assert verifies that the above operations have
            # induced a block rearrangement
            assert df0._mgr.blocks[0].dtype != df1._mgr.blocks[0].dtype

        # do the real tests
        tm.assert_frame_equal(df0, df1)
        assert df0.equals(df1)
        assert df1.equals(df0)

            

Reported by Pylint.

Access to a protected member _mgr of a client class
Error

Line: 24 Column: 48

                      if not using_array_manager:
            # this assert verifies that the above operations have
            # induced a block rearrangement
            assert df0._mgr.blocks[0].dtype != df1._mgr.blocks[0].dtype

        # do the real tests
        tm.assert_frame_equal(df0, df1)
        assert df0.equals(df1)
        assert df1.equals(df0)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np

from pandas import (
    DataFrame,
    date_range,
)
import pandas._testing as tm



            

Reported by Pylint.

Missing class docstring
Error

Line: 10 Column: 1

              import pandas._testing as tm


class TestEquals:
    def test_dataframe_not_equal(self):
        # see GH#28839
        df1 = DataFrame({"a": [1, 2], "b": ["s", "d"]})
        df2 = DataFrame({"a": ["s", "d"], "b": [1, 2]})
        assert df1.equals(df2) is False

            

Reported by Pylint.

Method could be a function
Error

Line: 11 Column: 5

              

class TestEquals:
    def test_dataframe_not_equal(self):
        # see GH#28839
        df1 = DataFrame({"a": [1, 2], "b": ["s", "d"]})
        df2 = DataFrame({"a": ["s", "d"], "b": [1, 2]})
        assert df1.equals(df2) is False


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 5

              

class TestEquals:
    def test_dataframe_not_equal(self):
        # see GH#28839
        df1 = DataFrame({"a": [1, 2], "b": ["s", "d"]})
        df2 = DataFrame({"a": ["s", "d"], "b": [1, 2]})
        assert df1.equals(df2) is False


            

Reported by Pylint.

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

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

                      # see GH#28839
        df1 = DataFrame({"a": [1, 2], "b": ["s", "d"]})
        df2 = DataFrame({"a": ["s", "d"], "b": [1, 2]})
        assert df1.equals(df2) is False

    def test_equals_different_blocks(self, using_array_manager):
        # GH#9330
        df0 = DataFrame({"A": ["x", "y"], "B": [1, 2], "C": ["w", "z"]})
        df1 = df0.reset_index()[["A", "B", "C"]]

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 17 Column: 5

                      df2 = DataFrame({"a": ["s", "d"], "b": [1, 2]})
        assert df1.equals(df2) is False

    def test_equals_different_blocks(self, using_array_manager):
        # GH#9330
        df0 = DataFrame({"A": ["x", "y"], "B": [1, 2], "C": ["w", "z"]})
        df1 = df0.reset_index()[["A", "B", "C"]]
        if not using_array_manager:
            # this assert verifies that the above operations have

            

Reported by Pylint.

Method could be a function
Error

Line: 17 Column: 5

                      df2 = DataFrame({"a": ["s", "d"], "b": [1, 2]})
        assert df1.equals(df2) is False

    def test_equals_different_blocks(self, using_array_manager):
        # GH#9330
        df0 = DataFrame({"A": ["x", "y"], "B": [1, 2], "C": ["w", "z"]})
        df1 = df0.reset_index()[["A", "B", "C"]]
        if not using_array_manager:
            # this assert verifies that the above operations have

            

Reported by Pylint.

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

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

                      if not using_array_manager:
            # this assert verifies that the above operations have
            # induced a block rearrangement
            assert df0._mgr.blocks[0].dtype != df1._mgr.blocks[0].dtype

        # do the real tests
        tm.assert_frame_equal(df0, df1)
        assert df0.equals(df1)
        assert df1.equals(df0)

            

Reported by Bandit.

pandas/core/arrays/numpy_.py
27 issues
No name 'lib' in module 'pandas._libs'
Error

Line: 8 Column: 1

              import numpy as np
from numpy.lib.mixins import NDArrayOperatorsMixin

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

            

Reported by Pylint.

Access to a protected member _ndarray of a client class
Error

Line: 160 Column: 24

                              return result

        # Defer to the implementation of the ufunc on unwrapped values.
        inputs = tuple(x._ndarray if isinstance(x, PandasArray) else x for x in inputs)
        if out:
            kwargs["out"] = tuple(
                x._ndarray if isinstance(x, PandasArray) else x for x in out
            )
        result = getattr(ufunc, method)(*inputs, **kwargs)

            

Reported by Pylint.

Access to a protected member _ndarray of a client class
Error

Line: 163 Column: 17

                      inputs = tuple(x._ndarray if isinstance(x, PandasArray) else x for x in inputs)
        if out:
            kwargs["out"] = tuple(
                x._ndarray if isinstance(x, PandasArray) else x for x in out
            )
        result = getattr(ufunc, method)(*inputs, **kwargs)

        if type(result) is tuple and len(result):
            # multiple return values

            

Reported by Pylint.

Parameters differ from overridden '_validate_scalar' method
Error

Line: 191 Column: 5

                  def isna(self) -> np.ndarray:
        return isna(self._ndarray)

    def _validate_scalar(self, fill_value):
        if fill_value is None:
            # Primarily for subclasses
            fill_value = self.dtype.na_value
        return fill_value


            

Reported by Pylint.

Access to a protected member _ndarray of a client class
Error

Line: 395 Column: 21

              
    def _cmp_method(self, other, op):
        if isinstance(other, PandasArray):
            other = other._ndarray

        other = ops.maybe_prepare_scalar_for_op(other, (len(self),))
        pd_op = ops.get_array_op(op)
        other = ensure_wrapped_if_datetimelike(other)
        with np.errstate(all="ignore"):

            

Reported by Pylint.

Access to a protected member _simple_new of a client class
Error

Line: 425 Column: 20

                      if result.dtype == "timedelta64[ns]":
            from pandas.core.arrays import TimedeltaArray

            return TimedeltaArray._simple_new(result)
        return type(self)(result)

    # ------------------------------------------------------------------------
    # String methods interface
    _str_na_value = np.nan

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import annotations

import numbers

import numpy as np
from numpy.lib.mixins import NDArrayOperatorsMixin

from pandas._libs import lib
from pandas._typing import (

            

Reported by Pylint.

Too many ancestors (8/7)
Error

Line: 30 Column: 1

              from pandas.core.strings.object_array import ObjectStringArrayMixin


class PandasArray(
    OpsMixin,
    NDArrayBackedExtensionArray,
    NDArrayOperatorsMixin,
    ObjectStringArrayMixin,
):

            

Reported by Pylint.

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

Line: 141 Column: 13

                      # The primary modification is not boxing scalar return values
        # in PandasArray, since pandas' ExtensionArrays are 1-d.
        out = kwargs.get("out", ())
        for x in inputs + out:
            # Only support operations with instances of _HANDLED_TYPES.
            # Use PandasArray instead of type(self) for isinstance to
            # allow subclasses that don't override __array_ufunc__ to
            # handle PandasArray objects.
            if not isinstance(x, self._HANDLED_TYPES + (PandasArray,)):

            

Reported by Pylint.

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

Line: 167 Column: 12

                          )
        result = getattr(ufunc, method)(*inputs, **kwargs)

        if type(result) is tuple and len(result):
            # multiple return values
            if not lib.is_scalar(result[0]):
                # re-box array-like results
                return tuple(type(self)(x) for x in result)
            else:

            

Reported by Pylint.

pandas/tests/dtypes/test_generic.py
27 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              from warnings import catch_warnings

import numpy as np
import pytest

from pandas.core.dtypes import generic as gt

import pandas as pd
import pandas._testing as tm

            

Reported by Pylint.

Instance of 'DataFrame' has no 'one' member
Error

Line: 104 Column: 9

                  with catch_warnings(record=True) as w:
        #  successfully modify column in place
        #  this should not raise a warning
        df.one += 1
        assert len(w) == 0
        assert df.one.iloc[0] == 2

    with catch_warnings(record=True) as w:
        #  successfully add an attribute to a series

            

Reported by Pylint.

Instance of 'DataFrame' has no 'one' member
Error

Line: 106 Column: 16

                      #  this should not raise a warning
        df.one += 1
        assert len(w) == 0
        assert df.one.iloc[0] == 2

    with catch_warnings(record=True) as w:
        #  successfully add an attribute to a series
        #  this should not raise a warning
        df.two.not_an_index = [1, 2]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from warnings import catch_warnings

import numpy as np
import pytest

from pandas.core.dtypes import generic as gt

import pandas as pd
import pandas._testing as tm

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              import pandas._testing as tm


class TestABCClasses:
    tuples = [[1, 2, 2], ["red", "blue", "red"]]
    multi_index = pd.MultiIndex.from_arrays(tuples, names=("number", "color"))
    datetime_index = pd.to_datetime(["2000/1/1", "2010/1/1"])
    timedelta_index = pd.to_timedelta(np.arange(5), unit="s")
    period_index = pd.period_range("2000/1/1", "2010/1/1/", freq="M")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 47 Column: 5

              
    @pytest.mark.parametrize("abctype1, inst", abc_pairs)
    @pytest.mark.parametrize("abctype2, _", abc_pairs)
    def test_abc_pairs(self, abctype1, abctype2, inst, _):
        # GH 38588
        if abctype1 == abctype2:
            assert isinstance(inst, getattr(gt, abctype2))
        else:
            assert not isinstance(inst, getattr(gt, abctype2))

            

Reported by Pylint.

Method could be a function
Error

Line: 47 Column: 5

              
    @pytest.mark.parametrize("abctype1, inst", abc_pairs)
    @pytest.mark.parametrize("abctype2, _", abc_pairs)
    def test_abc_pairs(self, abctype1, abctype2, inst, _):
        # GH 38588
        if abctype1 == abctype2:
            assert isinstance(inst, getattr(gt, abctype2))
        else:
            assert not isinstance(inst, getattr(gt, abctype2))

            

Reported by Pylint.

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

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

                  def test_abc_pairs(self, abctype1, abctype2, inst, _):
        # GH 38588
        if abctype1 == abctype2:
            assert isinstance(inst, getattr(gt, abctype2))
        else:
            assert not isinstance(inst, getattr(gt, abctype2))

    abc_subclasses = {
        "ABCIndex": [

            

Reported by Bandit.

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

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

                      if abctype1 == abctype2:
            assert isinstance(inst, getattr(gt, abctype2))
        else:
            assert not isinstance(inst, getattr(gt, abctype2))

    abc_subclasses = {
        "ABCIndex": [
            abctype
            for abctype, _ in abc_pairs

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 71 Column: 5

              
    @pytest.mark.parametrize("parent, subs", abc_subclasses.items())
    @pytest.mark.parametrize("abctype, inst", abc_pairs)
    def test_abc_hierarchy(self, parent, subs, abctype, inst):
        # GH 38588
        if abctype in subs:
            assert isinstance(inst, getattr(gt, parent))
        else:
            assert not isinstance(inst, getattr(gt, parent))

            

Reported by Pylint.

asv_bench/benchmarks/tslibs/fields.py
27 issues
Unable to import 'pandas._libs.tslibs.fields'
Error

Line: 3 Column: 1

              import numpy as np

from pandas._libs.tslibs.fields import (
    get_date_field,
    get_start_end_field,
    get_timedelta_field,
)

from .tslib import _sizes

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 9 Column: 1

                  get_timedelta_field,
)

from .tslib import _sizes


class TimeGetTimedeltaField:
    params = [
        _sizes,

            

Reported by Pylint.

Unused argument 'field'
Error

Line: 19 Column: 27

                  ]
    param_names = ["size", "field"]

    def setup(self, size, field):
        arr = np.random.randint(0, 10, size=size, dtype="i8")
        self.i8data = arr

    def time_get_timedelta_field(self, size, field):
        get_timedelta_field(self.i8data, field)

            

Reported by Pylint.

Attribute 'i8data' defined outside __init__
Error

Line: 21 Column: 9

              
    def setup(self, size, field):
        arr = np.random.randint(0, 10, size=size, dtype="i8")
        self.i8data = arr

    def time_get_timedelta_field(self, size, field):
        get_timedelta_field(self.i8data, field)



            

Reported by Pylint.

Unused argument 'size'
Error

Line: 23 Column: 40

                      arr = np.random.randint(0, 10, size=size, dtype="i8")
        self.i8data = arr

    def time_get_timedelta_field(self, size, field):
        get_timedelta_field(self.i8data, field)


class TimeGetDateField:
    params = [

            

Reported by Pylint.

Unused argument 'field'
Error

Line: 49 Column: 27

                  ]
    param_names = ["size", "field"]

    def setup(self, size, field):
        arr = np.random.randint(0, 10, size=size, dtype="i8")
        self.i8data = arr

    def time_get_date_field(self, size, field):
        get_date_field(self.i8data, field)

            

Reported by Pylint.

Attribute 'i8data' defined outside __init__
Error

Line: 51 Column: 9

              
    def setup(self, size, field):
        arr = np.random.randint(0, 10, size=size, dtype="i8")
        self.i8data = arr

    def time_get_date_field(self, size, field):
        get_date_field(self.i8data, field)



            

Reported by Pylint.

Unused argument 'size'
Error

Line: 53 Column: 35

                      arr = np.random.randint(0, 10, size=size, dtype="i8")
        self.i8data = arr

    def time_get_date_field(self, size, field):
        get_date_field(self.i8data, field)


class TimeGetStartEndField:
    params = [

            

Reported by Pylint.

Unused argument 'month_kw'
Error

Line: 67 Column: 50

                  ]
    param_names = ["size", "side", "period", "freqstr", "month_kw"]

    def setup(self, size, side, period, freqstr, month_kw):
        arr = np.random.randint(0, 10, size=size, dtype="i8")
        self.i8data = arr

        self.attrname = f"is_{period}_{side}"


            

Reported by Pylint.

Unused argument 'freqstr'
Error

Line: 67 Column: 41

                  ]
    param_names = ["size", "side", "period", "freqstr", "month_kw"]

    def setup(self, size, side, period, freqstr, month_kw):
        arr = np.random.randint(0, 10, size=size, dtype="i8")
        self.i8data = arr

        self.attrname = f"is_{period}_{side}"


            

Reported by Pylint.

pandas/compat/pickle_compat.py
27 issues
Unable to import 'pandas._libs.arrays'
Error

Line: 15 Column: 1

              
import numpy as np

from pandas._libs.arrays import NDArrayBacked
from pandas._libs.tslibs import BaseOffset

from pandas import Index
from pandas.core.arrays import (
    DatetimeArray,

            

Reported by Pylint.

No name 'arrays' in module 'pandas._libs'
Error

Line: 15 Column: 1

              
import numpy as np

from pandas._libs.arrays import NDArrayBacked
from pandas._libs.tslibs import BaseOffset

from pandas import Index
from pandas.core.arrays import (
    DatetimeArray,

            

Reported by Pylint.

Unused variable 'n'
Error

Line: 39 Column: 9

                  func = stack[-1]

    if len(args) and type(args[0]) is type:
        n = args[0].__name__  # noqa

    try:
        stack[-1] = func(*args)
        return
    except TypeError as err:

            

Reported by Pylint.

Access to a protected member _Unpickler of a client class
Error

Line: 201 Column: 17

              # functions for compat and uses a non-public class of the pickle module.

# error: Name 'pkl._Unpickler' is not defined
class Unpickler(pkl._Unpickler):  # type: ignore[name-defined]
    def find_class(self, module, name):
        # override superclass
        key = (module, name)
        module, name = _class_locations_map.get(key, key)
        return super().find_class(module, name)

            

Reported by Pylint.

Attribute 'is_verbose' defined outside __init__
Error

Line: 272 Column: 9

                          up = Unpickler(fh, encoding=encoding)
        else:
            up = Unpickler(fh)
        up.is_verbose = is_verbose

        return up.load()
    except (ValueError, TypeError):
        raise


            

Reported by Pylint.

The except handler raises immediately
Error

Line: 275 Column: 5

                      up.is_verbose = is_verbose

        return up.load()
    except (ValueError, TypeError):
        raise


def loads(
    bytes_object: bytes,

            

Reported by Pylint.

Consider possible security implications associated with pickle module.
Security blacklist

Line: 9
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b403-import-pickle

              import contextlib
import copy
import io
import pickle as pkl
from typing import TYPE_CHECKING
import warnings

import numpy as np


            

Reported by Bandit.

third party import "from pandas._libs.arrays import NDArrayBacked" should be placed before "import numpy as np"
Error

Line: 15 Column: 1

              
import numpy as np

from pandas._libs.arrays import NDArrayBacked
from pandas._libs.tslibs import BaseOffset

from pandas import Index
from pandas.core.arrays import (
    DatetimeArray,

            

Reported by Pylint.

third party import "from pandas._libs.tslibs import BaseOffset" should be placed before "import numpy as np"
Error

Line: 16 Column: 1

              import numpy as np

from pandas._libs.arrays import NDArrayBacked
from pandas._libs.tslibs import BaseOffset

from pandas import Index
from pandas.core.arrays import (
    DatetimeArray,
    PeriodArray,

            

Reported by Pylint.

third party import "from pandas import Index" should be placed before "import numpy as np"
Error

Line: 18 Column: 1

              from pandas._libs.arrays import NDArrayBacked
from pandas._libs.tslibs import BaseOffset

from pandas import Index
from pandas.core.arrays import (
    DatetimeArray,
    PeriodArray,
    TimedeltaArray,
)

            

Reported by Pylint.

pandas/tests/window/test_pairwise.py
27 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import warnings

import numpy as np
import pytest

from pandas import (
    DataFrame,
    MultiIndex,
    Series,

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import warnings

import numpy as np
import pytest

from pandas import (
    DataFrame,
    MultiIndex,
    Series,

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              from pandas.core.algorithms import safe_sort


class TestPairwise:

    # GH 7738
    @pytest.mark.parametrize("f", [lambda x: x.cov(), lambda x: x.corr()])
    def test_no_flex(self, pairwise_frames, pairwise_target_frame, f):


            

Reported by Pylint.

Argument name "f" doesn't conform to snake_case naming style
Error

Line: 20 Column: 5

              
    # GH 7738
    @pytest.mark.parametrize("f", [lambda x: x.cov(), lambda x: x.corr()])
    def test_no_flex(self, pairwise_frames, pairwise_target_frame, f):

        # DataFrame methods (which do not call flex_binary_moment())

        result = f(pairwise_frames)
        tm.assert_index_equal(result.index, pairwise_frames.columns)

            

Reported by Pylint.

Method could be a function
Error

Line: 20 Column: 5

              
    # GH 7738
    @pytest.mark.parametrize("f", [lambda x: x.cov(), lambda x: x.corr()])
    def test_no_flex(self, pairwise_frames, pairwise_target_frame, f):

        # DataFrame methods (which do not call flex_binary_moment())

        result = f(pairwise_frames)
        tm.assert_index_equal(result.index, pairwise_frames.columns)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 5

              
    # GH 7738
    @pytest.mark.parametrize("f", [lambda x: x.cov(), lambda x: x.corr()])
    def test_no_flex(self, pairwise_frames, pairwise_target_frame, f):

        # DataFrame methods (which do not call flex_binary_moment())

        result = f(pairwise_frames)
        tm.assert_index_equal(result.index, pairwise_frames.columns)

            

Reported by Pylint.

Method could be a function
Error

Line: 44 Column: 5

                          lambda x: x.rolling(window=3).corr(pairwise=True),
            lambda x: x.ewm(com=3).cov(pairwise=True),
            lambda x: x.ewm(com=3).corr(pairwise=True),
        ],
    )
    def test_pairwise_with_self(self, pairwise_frames, pairwise_target_frame, f):

        # DataFrame with itself, pairwise=True
        # note that we may construct the 1st level of the MI

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 44 Column: 5

                          lambda x: x.rolling(window=3).corr(pairwise=True),
            lambda x: x.ewm(com=3).cov(pairwise=True),
            lambda x: x.ewm(com=3).corr(pairwise=True),
        ],
    )
    def test_pairwise_with_self(self, pairwise_frames, pairwise_target_frame, f):

        # DataFrame with itself, pairwise=True
        # note that we may construct the 1st level of the MI

            

Reported by Pylint.

Argument name "f" doesn't conform to snake_case naming style
Error

Line: 44 Column: 5

                          lambda x: x.rolling(window=3).corr(pairwise=True),
            lambda x: x.ewm(com=3).cov(pairwise=True),
            lambda x: x.ewm(com=3).corr(pairwise=True),
        ],
    )
    def test_pairwise_with_self(self, pairwise_frames, pairwise_target_frame, f):

        # DataFrame with itself, pairwise=True
        # note that we may construct the 1st level of the MI

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 77 Column: 5

                          lambda x: x.rolling(window=3).corr(pairwise=False),
            lambda x: x.ewm(com=3).cov(pairwise=False),
            lambda x: x.ewm(com=3).corr(pairwise=False),
        ],
    )
    def test_no_pairwise_with_self(self, pairwise_frames, pairwise_target_frame, f):

        # DataFrame with itself, pairwise=False
        result = f(pairwise_frames)

            

Reported by Pylint.

pandas/tests/indexes/categorical/test_formats.py
27 issues
Missing class docstring
Error

Line: 9 Column: 1

              from pandas import CategoricalIndex


class TestCategoricalIndexRepr:
    def test_format_different_scalar_lengths(self):
        # GH#35439
        idx = CategoricalIndex(["aaaaaaaaa", "b"])
        expected = ["aaaaaaaaa", "b"]
        assert idx.format() == expected

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 5

              

class TestCategoricalIndexRepr:
    def test_format_different_scalar_lengths(self):
        # GH#35439
        idx = CategoricalIndex(["aaaaaaaaa", "b"])
        expected = ["aaaaaaaaa", "b"]
        assert idx.format() == expected


            

Reported by Pylint.

Method could be a function
Error

Line: 10 Column: 5

              

class TestCategoricalIndexRepr:
    def test_format_different_scalar_lengths(self):
        # GH#35439
        idx = CategoricalIndex(["aaaaaaaaa", "b"])
        expected = ["aaaaaaaaa", "b"]
        assert idx.format() == expected


            

Reported by Pylint.

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

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

                      # GH#35439
        idx = CategoricalIndex(["aaaaaaaaa", "b"])
        expected = ["aaaaaaaaa", "b"]
        assert idx.format() == expected

    def test_string_categorical_index_repr(self):
        # short
        idx = CategoricalIndex(["a", "bb", "ccc"])
        expected = """CategoricalIndex(['a', 'bb', 'ccc'], categories=['a', 'bb', 'ccc'], ordered=False, dtype='category')"""  # noqa

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 16 Column: 5

                      expected = ["aaaaaaaaa", "b"]
        assert idx.format() == expected

    def test_string_categorical_index_repr(self):
        # short
        idx = CategoricalIndex(["a", "bb", "ccc"])
        expected = """CategoricalIndex(['a', 'bb', 'ccc'], categories=['a', 'bb', 'ccc'], ordered=False, dtype='category')"""  # noqa
        assert repr(idx) == expected


            

Reported by Pylint.

Method could be a function
Error

Line: 16 Column: 5

                      expected = ["aaaaaaaaa", "b"]
        assert idx.format() == expected

    def test_string_categorical_index_repr(self):
        # short
        idx = CategoricalIndex(["a", "bb", "ccc"])
        expected = """CategoricalIndex(['a', 'bb', 'ccc'], categories=['a', 'bb', 'ccc'], ordered=False, dtype='category')"""  # noqa
        assert repr(idx) == expected


            

Reported by Pylint.

Line too long (133/100)
Error

Line: 19 Column: 1

                  def test_string_categorical_index_repr(self):
        # short
        idx = CategoricalIndex(["a", "bb", "ccc"])
        expected = """CategoricalIndex(['a', 'bb', 'ccc'], categories=['a', 'bb', 'ccc'], ordered=False, dtype='category')"""  # noqa
        assert repr(idx) == expected

        # multiple lines
        idx = CategoricalIndex(["a", "bb", "ccc"] * 10)
        expected = """CategoricalIndex(['a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a',

            

Reported by Pylint.

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

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

                      # short
        idx = CategoricalIndex(["a", "bb", "ccc"])
        expected = """CategoricalIndex(['a', 'bb', 'ccc'], categories=['a', 'bb', 'ccc'], ordered=False, dtype='category')"""  # noqa
        assert repr(idx) == expected

        # multiple lines
        idx = CategoricalIndex(["a", "bb", "ccc"] * 10)
        expected = """CategoricalIndex(['a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a',
                  'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb',

            

Reported by Bandit.

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

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

                                'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc'],
                 categories=['a', 'bb', 'ccc'], ordered=False, dtype='category')"""

        assert repr(idx) == expected

        # truncated
        idx = CategoricalIndex(["a", "bb", "ccc"] * 100)
        expected = """CategoricalIndex(['a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a',
                  ...

            

Reported by Bandit.

Line too long (103/100)
Error

Line: 36 Column: 1

                      expected = """CategoricalIndex(['a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a',
                  ...
                  'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc'],
                 categories=['a', 'bb', 'ccc'], ordered=False, dtype='category', length=300)"""  # noqa

        assert repr(idx) == expected

        # larger categories
        idx = CategoricalIndex(list("abcdefghijklmmo"))

            

Reported by Pylint.

pandas/tests/tslibs/test_conversion.py
27 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              from datetime import datetime

import numpy as np
import pytest
from pytz import UTC

from pandas._libs.tslibs import (
    OutOfBoundsTimedelta,
    conversion,

            

Reported by Pylint.

Unable to import 'pytz'
Error

Line: 5 Column: 1

              
import numpy as np
import pytest
from pytz import UTC

from pandas._libs.tslibs import (
    OutOfBoundsTimedelta,
    conversion,
    iNaT,

            

Reported by Pylint.

No name 'conversion' in module 'pandas._libs.tslibs'
Error

Line: 7 Column: 1

              import pytest
from pytz import UTC

from pandas._libs.tslibs import (
    OutOfBoundsTimedelta,
    conversion,
    iNaT,
    timezones,
    tzconversion,

            

Reported by Pylint.

No name 'timezones' in module 'pandas._libs.tslibs'
Error

Line: 7 Column: 1

              import pytest
from pytz import UTC

from pandas._libs.tslibs import (
    OutOfBoundsTimedelta,
    conversion,
    iNaT,
    timezones,
    tzconversion,

            

Reported by Pylint.

No name 'tzconversion' in module 'pandas._libs.tslibs'
Error

Line: 7 Column: 1

              import pytest
from pytz import UTC

from pandas._libs.tslibs import (
    OutOfBoundsTimedelta,
    conversion,
    iNaT,
    timezones,
    tzconversion,

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 38 Column: 12

                  try:
        result = tzconversion.tz_localize_to_utc(naive_didx.asi8, tz_didx.tz)
        err1 = None
    except Exception as err:
        err1 = err

    try:
        expected = naive_didx.map(lambda x: x.tz_localize(tz_didx.tz)).asi8
    except Exception as err:

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 43 Column: 12

              
    try:
        expected = naive_didx.map(lambda x: x.tz_localize(tz_didx.tz)).asi8
    except Exception as err:
        err2 = err

    if err1 is not None:
        assert type(err1) == type(err2)
    else:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from datetime import datetime

import numpy as np
import pytest
from pytz import UTC

from pandas._libs.tslibs import (
    OutOfBoundsTimedelta,
    conversion,

            

Reported by Pylint.

Function name "f" doesn't conform to snake_case naming style
Error

Line: 23 Column: 5

              

def _compare_utc_to_local(tz_didx):
    def f(x):
        return tzconversion.tz_convert_from_utc_single(x, tz_didx.tz)

    result = tzconversion.tz_convert_from_utc(tz_didx.asi8, tz_didx.tz)
    expected = np.vectorize(f)(tz_didx.asi8)


            

Reported by Pylint.

Argument name "x" doesn't conform to snake_case naming style
Error

Line: 23 Column: 5

              

def _compare_utc_to_local(tz_didx):
    def f(x):
        return tzconversion.tz_convert_from_utc_single(x, tz_didx.tz)

    result = tzconversion.tz_convert_from_utc(tz_didx.asi8, tz_didx.tz)
    expected = np.vectorize(f)(tz_didx.asi8)


            

Reported by Pylint.