The following issues were found

pandas/tests/arrays/integer/test_repr.py
15 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas as pd
from pandas.core.arrays.integer import (
    Int8Dtype,
    Int16Dtype,
    Int32Dtype,
    Int64Dtype,

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

import pandas as pd
from pandas.core.arrays.integer import (
    Int8Dtype,
    Int16Dtype,
    Int32Dtype,
    Int64Dtype,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 1

              )


def test_dtypes(dtype):
    # smoke tests on auto dtype construction

    if dtype.is_signed_integer:
        assert np.dtype(dtype.type).kind == "i"
    else:

            

Reported by Pylint.

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

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

                  # smoke tests on auto dtype construction

    if dtype.is_signed_integer:
        assert np.dtype(dtype.type).kind == "i"
    else:
        assert np.dtype(dtype.type).kind == "u"
    assert dtype.name is not None



            

Reported by Bandit.

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

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

                  if dtype.is_signed_integer:
        assert np.dtype(dtype.type).kind == "i"
    else:
        assert np.dtype(dtype.type).kind == "u"
    assert dtype.name is not None


@pytest.mark.parametrize(
    "dtype, expected",

            

Reported by Bandit.

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

                      assert np.dtype(dtype.type).kind == "i"
    else:
        assert np.dtype(dtype.type).kind == "u"
    assert dtype.name is not None


@pytest.mark.parametrize(
    "dtype, expected",
    [

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 38 Column: 1

                      (UInt16Dtype(), "UInt16Dtype()"),
        (UInt32Dtype(), "UInt32Dtype()"),
        (UInt64Dtype(), "UInt64Dtype()"),
    ],
)
def test_repr_dtype(dtype, expected):
    assert repr(dtype) == expected



            

Reported by Pylint.

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

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

                  ],
)
def test_repr_dtype(dtype, expected):
    assert repr(dtype) == expected


def test_repr_array():
    result = repr(pd.array([1, None, 3]))
    expected = "<IntegerArray>\n[1, <NA>, 3]\nLength: 3, dtype: Int64"

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 44 Column: 1

                  assert repr(dtype) == expected


def test_repr_array():
    result = repr(pd.array([1, None, 3]))
    expected = "<IntegerArray>\n[1, <NA>, 3]\nLength: 3, dtype: Int64"
    assert result == expected



            

Reported by Pylint.

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

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

              def test_repr_array():
    result = repr(pd.array([1, None, 3]))
    expected = "<IntegerArray>\n[1, <NA>, 3]\nLength: 3, dtype: Int64"
    assert result == expected


def test_repr_array_long():
    data = pd.array([1, 2, None] * 1000)
    expected = (

            

Reported by Bandit.

pandas/tests/indexes/datetimes/methods/test_repeat.py
15 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import (
    DatetimeIndex,
    Timestamp,
    date_range,
)
import pandas._testing as tm

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas import (
    DatetimeIndex,
    Timestamp,
    date_range,
)
import pandas._testing as tm

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              import pandas._testing as tm


class TestRepeat:
    def test_repeat_range(self, tz_naive_fixture):
        tz = tz_naive_fixture
        rng = date_range("1/1/2000", "1/1/2001")

        result = rng.repeat(5)

            

Reported by Pylint.

Method could be a function
Error

Line: 13 Column: 5

              

class TestRepeat:
    def test_repeat_range(self, tz_naive_fixture):
        tz = tz_naive_fixture
        rng = date_range("1/1/2000", "1/1/2001")

        result = rng.repeat(5)
        assert result.freq is None

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 5

              

class TestRepeat:
    def test_repeat_range(self, tz_naive_fixture):
        tz = tz_naive_fixture
        rng = date_range("1/1/2000", "1/1/2001")

        result = rng.repeat(5)
        assert result.freq is None

            

Reported by Pylint.

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

Line: 14 Column: 9

              
class TestRepeat:
    def test_repeat_range(self, tz_naive_fixture):
        tz = tz_naive_fixture
        rng = date_range("1/1/2000", "1/1/2001")

        result = rng.repeat(5)
        assert result.freq is None
        assert len(result) == 5 * len(rng)

            

Reported by Pylint.

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

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

                      rng = date_range("1/1/2000", "1/1/2001")

        result = rng.repeat(5)
        assert result.freq is None
        assert len(result) == 5 * len(rng)

        index = date_range("2001-01-01", periods=2, freq="D", tz=tz)
        exp = DatetimeIndex(
            ["2001-01-01", "2001-01-01", "2001-01-02", "2001-01-02"], tz=tz

            

Reported by Bandit.

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

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

              
        result = rng.repeat(5)
        assert result.freq is None
        assert len(result) == 5 * len(rng)

        index = date_range("2001-01-01", periods=2, freq="D", tz=tz)
        exp = DatetimeIndex(
            ["2001-01-01", "2001-01-01", "2001-01-02", "2001-01-02"], tz=tz
        )

            

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

                      )
        for res in [index.repeat(2), np.repeat(index, 2)]:
            tm.assert_index_equal(res, exp)
            assert res.freq is None

        index = date_range("2001-01-01", periods=2, freq="2D", tz=tz)
        exp = DatetimeIndex(
            ["2001-01-01", "2001-01-01", "2001-01-03", "2001-01-03"], tz=tz
        )

            

Reported by Bandit.

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

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

                      )
        for res in [index.repeat(2), np.repeat(index, 2)]:
            tm.assert_index_equal(res, exp)
            assert res.freq is None

        index = DatetimeIndex(["2001-01-01", "NaT", "2003-01-01"], tz=tz)
        exp = DatetimeIndex(
            [
                "2001-01-01",

            

Reported by Bandit.

pandas/core/computation/eval.py
15 issues
No name 'lib' in module 'pandas._libs'
Error

Line: 9 Column: 1

              import tokenize
import warnings

from pandas._libs.lib import no_default
from pandas.util._validators import validate_bool_kwarg

from pandas.core.computation.engines import ENGINES
from pandas.core.computation.expr import (
    PARSERS,

            

Reported by Pylint.

Unable to import 'pandas._libs.lib'
Error

Line: 9 Column: 1

              import tokenize
import warnings

from pandas._libs.lib import no_default
from pandas.util._validators import validate_bool_kwarg

from pandas.core.computation.engines import ENGINES
from pandas.core.computation.expr import (
    PARSERS,

            

Reported by Pylint.

TODO: validate this in a more general way (thinking of future engines
Error

Line: 57 Column: 3

                          f"Invalid engine '{engine}' passed, valid engines are {valid_engines}"
        )

    # TODO: validate this in a more general way (thinking of future engines
    # that won't necessarily be import-able)
    # Could potentially be done on engine instantiation
    if engine == "numexpr" and not NUMEXPR_INSTALLED:
        raise ImportError(
            "'numexpr' is not installed or an unsupported version. Cannot use "

            

Reported by Pylint.

Redefining built-in 'eval'
Error

Line: 165 Column: 1

                              raise SyntaxError(msg)


def eval(
    expr: str | BinOp,  # we leave BinOp out of the docstr bc it isn't for users
    parser: str = "pandas",
    engine: str | None = None,
    truediv=no_default,
    local_dict=None,

            

Reported by Pylint.

TODO: Filter the warnings we actually care about here.
Error

Line: 385 Column: 3

                          # to use a non-numeric indexer
            try:
                with warnings.catch_warnings(record=True):
                    # TODO: Filter the warnings we actually care about here.
                    target[assigner] = ret
            except (TypeError, IndexError) as err:
                raise ValueError("Cannot assign expression output to target") from err

            if not resolvers:

            

Reported by Pylint.

Import outside toplevel (pandas.core.computation.check.NUMEXPR_INSTALLED)
Error

Line: 45 Column: 5

                  str
        Engine name.
    """
    from pandas.core.computation.check import NUMEXPR_INSTALLED
    from pandas.core.computation.expressions import USE_NUMEXPR

    if engine is None:
        engine = "numexpr" if USE_NUMEXPR else "python"


            

Reported by Pylint.

Import outside toplevel (pandas.core.computation.expressions.USE_NUMEXPR)
Error

Line: 46 Column: 5

                      Engine name.
    """
    from pandas.core.computation.check import NUMEXPR_INSTALLED
    from pandas.core.computation.expressions import USE_NUMEXPR

    if engine is None:
        engine = "numexpr" if USE_NUMEXPR else "python"

    if engine not in ENGINES:

            

Reported by Pylint.

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

Line: 141 Column: 5

                  ValueError
      * If the expression is empty.
    """
    s = pprint_thing(expr)
    _check_expression(s)
    return s


def _check_for_locals(expr: str, stack_level: int, parser: str):

            

Reported by Pylint.

Too many branches (19/12)
Error

Line: 165 Column: 1

                              raise SyntaxError(msg)


def eval(
    expr: str | BinOp,  # we leave BinOp out of the docstr bc it isn't for users
    parser: str = "pandas",
    engine: str | None = None,
    truediv=no_default,
    local_dict=None,

            

Reported by Pylint.

Either all return statements in a function should return an expression, or none of them should.
Error

Line: 165 Column: 1

                              raise SyntaxError(msg)


def eval(
    expr: str | BinOp,  # we leave BinOp out of the docstr bc it isn't for users
    parser: str = "pandas",
    engine: str | None = None,
    truediv=no_default,
    local_dict=None,

            

Reported by Pylint.

pandas/core/indexes/timedeltas.py
15 issues
No name 'lib' in module 'pandas._libs'
Error

Line: 4 Column: 1

              """ implement the TimedeltaIndex """
from __future__ import annotations

from pandas._libs import (
    index as libindex,
    lib,
)
from pandas._libs.tslibs import (
    Timedelta,

            

Reported by Pylint.

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

Line: 4 Column: 1

              """ implement the TimedeltaIndex """
from __future__ import annotations

from pandas._libs import (
    index as libindex,
    lib,
)
from pandas._libs.tslibs import (
    Timedelta,

            

Reported by Pylint.

Access to a protected member _field_ops of a client class
Error

Line: 33 Column: 7

              
@inherit_names(
    ["__neg__", "__pos__", "__abs__", "total_seconds", "round", "floor", "ceil"]
    + TimedeltaArray._field_ops,
    TimedeltaArray,
    wrap=True,
)
@inherit_names(
    [

            

Reported by Pylint.

Method '_can_partial_date_slice' is abstract in class 'DatetimeIndexOpsMixin' but is not overridden
Error

Line: 48 Column: 1

                  ],
    TimedeltaArray,
)
class TimedeltaIndex(DatetimeTimedeltaMixin):
    """
    Immutable ndarray of timedelta64 data, represented internally as int64, and
    which can be boxed to timedelta objects.

    Parameters

            

Reported by Pylint.

Access to a protected member _get_string_slice of a client class
Error

Line: 109 Column: 25

                  _data: TimedeltaArray

    # Use base class method instead of DatetimeTimedeltaMixin._get_string_slice
    _get_string_slice = Index._get_string_slice

    # -------------------------------------------------------------------
    # Constructors

    def __new__(

            

Reported by Pylint.

Parameters differ from overridden '__new__' method
Error

Line: 114 Column: 5

                  # -------------------------------------------------------------------
    # Constructors

    def __new__(
        cls,
        data=None,
        unit=None,
        freq=lib.no_default,
        closed=None,

            

Reported by Pylint.

Unused argument 'closed'
Error

Line: 119 Column: 9

                      data=None,
        unit=None,
        freq=lib.no_default,
        closed=None,
        dtype=TD64NS_DTYPE,
        copy=False,
        name=None,
    ):
        name = maybe_extract_name(name, data, cls)

            

Reported by Pylint.

Access to a protected member _validate_scalar of a client class
Error

Line: 175 Column: 19

                      self._check_indexing_error(key)

        try:
            key = self._data._validate_scalar(key, unbox=False)
        except TypeError as err:
            raise KeyError(key) from err

        return Index.get_loc(self, key, method, tolerance)


            

Reported by Pylint.

Method 'inferred_type' was expected to be 'method', found it instead as 'property'
Error

Line: 195 Column: 5

                  # -------------------------------------------------------------------

    @property
    def inferred_type(self) -> str:
        return "timedelta64"


def timedelta_range(
    start=None,

            

Reported by Pylint.

Access to a protected member _generate_range of a client class
Error

Line: 275 Column: 13

                      freq = "D"

    freq, _ = dtl.maybe_infer_freq(freq)
    tdarr = TimedeltaArray._generate_range(start, end, periods, freq, closed=closed)
    return TimedeltaIndex._simple_new(tdarr, name=name)

            

Reported by Pylint.

pandas/tests/io/test_orc.py
15 issues
Unable to import 'pytest'
Error

Line: 6 Column: 1

              import os

import numpy as np
import pytest

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


            

Reported by Pylint.

Redefining name 'dirpath' from outer scope (line 20)
Error

Line: 24 Column: 27

                  return datapath("io", "data", "orc")


def test_orc_reader_empty(dirpath):
    columns = [
        "boolean1",
        "byte1",
        "short1",
        "int1",

            

Reported by Pylint.

Redefining name 'dirpath' from outer scope (line 20)
Error

Line: 57 Column: 27

                  tm.assert_equal(expected, got)


def test_orc_reader_basic(dirpath):
    data = {
        "boolean1": np.array([False, True], dtype="bool"),
        "byte1": np.array([1, 100], dtype="int8"),
        "short1": np.array([1024, 2048], dtype="int16"),
        "int1": np.array([65536, 65536], dtype="int32"),

            

Reported by Pylint.

Redefining name 'dirpath' from outer scope (line 20)
Error

Line: 77 Column: 29

                  tm.assert_equal(expected, got)


def test_orc_reader_decimal(dirpath):
    from decimal import Decimal

    # Only testing the first 10 rows of data
    data = {
        "_col0": np.array(

            

Reported by Pylint.

Redefining name 'dirpath' from outer scope (line 20)
Error

Line: 106 Column: 30

                  tm.assert_equal(expected, got)


def test_orc_reader_date_low(dirpath):
    data = {
        "time": np.array(
            [
                "1900-05-05 12:34:56.100000",
                "1900-05-05 12:34:56.100100",

            

Reported by Pylint.

Redefining name 'dirpath' from outer scope (line 20)
Error

Line: 147 Column: 31

                  tm.assert_equal(expected, got)


def test_orc_reader_date_high(dirpath):
    data = {
        "time": np.array(
            [
                "2038-05-05 12:34:56.100000",
                "2038-05-05 12:34:56.100100",

            

Reported by Pylint.

Redefining name 'dirpath' from outer scope (line 20)
Error

Line: 188 Column: 39

                  tm.assert_equal(expected, got)


def test_orc_reader_snappy_compressed(dirpath):
    data = {
        "int1": np.array(
            [
                -1160101563,
                1181413113,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 1

              

@pytest.fixture
def dirpath(datapath):
    return datapath("io", "data", "orc")


def test_orc_reader_empty(dirpath):
    columns = [

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 1

                  return datapath("io", "data", "orc")


def test_orc_reader_empty(dirpath):
    columns = [
        "boolean1",
        "byte1",
        "short1",
        "int1",

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 57 Column: 1

                  tm.assert_equal(expected, got)


def test_orc_reader_basic(dirpath):
    data = {
        "boolean1": np.array([False, True], dtype="bool"),
        "byte1": np.array([1, 100], dtype="int8"),
        "short1": np.array([1024, 2048], dtype="int16"),
        "int1": np.array([65536, 65536], dtype="int32"),

            

Reported by Pylint.

pandas/tests/indexes/period/test_searchsorted.py
15 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas._libs.tslibs import IncompatibleFrequency

from pandas import (
    NaT,
    Period,
    PeriodIndex,

            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 50 Column: 18

                      expected = np.arange(len(pidx), dtype=result.dtype)
        tm.assert_numpy_array_equal(result, expected)

        result = pidx._data.searchsorted(klass(pidx))
        tm.assert_numpy_array_equal(result, expected)

    def test_searchsorted_invalid(self):
        pidx = PeriodIndex(
            ["2014-01-01", "2014-01-02", "2014-01-03", "2014-01-04", "2014-01-05"],

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas._libs.tslibs import IncompatibleFrequency

from pandas import (
    NaT,
    Period,
    PeriodIndex,

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              import pandas._testing as tm


class TestSearchsorted:
    @pytest.mark.parametrize("freq", ["D", "2D"])
    def test_searchsorted(self, freq):
        pidx = PeriodIndex(
            ["2014-01-01", "2014-01-02", "2014-01-03", "2014-01-04", "2014-01-05"],
            freq=freq,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 5

              
class TestSearchsorted:
    @pytest.mark.parametrize("freq", ["D", "2D"])
    def test_searchsorted(self, freq):
        pidx = PeriodIndex(
            ["2014-01-01", "2014-01-02", "2014-01-03", "2014-01-04", "2014-01-05"],
            freq=freq,
        )


            

Reported by Pylint.

Method could be a function
Error

Line: 18 Column: 5

              
class TestSearchsorted:
    @pytest.mark.parametrize("freq", ["D", "2D"])
    def test_searchsorted(self, freq):
        pidx = PeriodIndex(
            ["2014-01-01", "2014-01-02", "2014-01-03", "2014-01-04", "2014-01-05"],
            freq=freq,
        )


            

Reported by Pylint.

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

Line: 24 Column: 9

                          freq=freq,
        )

        p1 = Period("2014-01-01", freq=freq)
        assert pidx.searchsorted(p1) == 0

        p2 = Period("2014-01-04", freq=freq)
        assert pidx.searchsorted(p2) == 3


            

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

                      )

        p1 = Period("2014-01-01", freq=freq)
        assert pidx.searchsorted(p1) == 0

        p2 = Period("2014-01-04", freq=freq)
        assert pidx.searchsorted(p2) == 3

        assert pidx.searchsorted(NaT) == 5

            

Reported by Bandit.

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

Line: 27 Column: 9

                      p1 = Period("2014-01-01", freq=freq)
        assert pidx.searchsorted(p1) == 0

        p2 = Period("2014-01-04", freq=freq)
        assert pidx.searchsorted(p2) == 3

        assert pidx.searchsorted(NaT) == 5

        msg = "Input has different freq=H from PeriodArray"

            

Reported by Pylint.

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

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

                      assert pidx.searchsorted(p1) == 0

        p2 = Period("2014-01-04", freq=freq)
        assert pidx.searchsorted(p2) == 3

        assert pidx.searchsorted(NaT) == 5

        msg = "Input has different freq=H from PeriodArray"
        with pytest.raises(IncompatibleFrequency, match=msg):

            

Reported by Bandit.

pandas/tests/io/test_spss.py
15 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              from pathlib import Path

import numpy as np
import pytest

import pandas as pd
import pandas._testing as tm

pyreadstat = pytest.importorskip("pyreadstat")

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from pathlib import Path

import numpy as np
import pytest

import pandas as pd
import pandas._testing as tm

pyreadstat = pytest.importorskip("pyreadstat")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              

@pytest.mark.parametrize("path_klass", [lambda p: p, Path])
def test_spss_labelled_num(path_klass, datapath):
    # test file from the Haven project (https://haven.tidyverse.org/)
    fname = path_klass(datapath("io", "data", "spss", "labelled-num.sav"))

    df = pd.read_spss(fname, convert_categoricals=True)
    expected = pd.DataFrame({"VAR00002": "This is one"}, index=[0])

            

Reported by Pylint.

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

Line: 17 Column: 5

                  # test file from the Haven project (https://haven.tidyverse.org/)
    fname = path_klass(datapath("io", "data", "spss", "labelled-num.sav"))

    df = pd.read_spss(fname, convert_categoricals=True)
    expected = pd.DataFrame({"VAR00002": "This is one"}, index=[0])
    expected["VAR00002"] = pd.Categorical(expected["VAR00002"])
    tm.assert_frame_equal(df, expected)

    df = pd.read_spss(fname, convert_categoricals=False)

            

Reported by Pylint.

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

Line: 22 Column: 5

                  expected["VAR00002"] = pd.Categorical(expected["VAR00002"])
    tm.assert_frame_equal(df, expected)

    df = pd.read_spss(fname, convert_categoricals=False)
    expected = pd.DataFrame({"VAR00002": 1.0}, index=[0])
    tm.assert_frame_equal(df, expected)


def test_spss_labelled_num_na(datapath):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 1

                  tm.assert_frame_equal(df, expected)


def test_spss_labelled_num_na(datapath):
    # test file from the Haven project (https://haven.tidyverse.org/)
    fname = datapath("io", "data", "spss", "labelled-num-na.sav")

    df = pd.read_spss(fname, convert_categoricals=True)
    expected = pd.DataFrame({"VAR00002": ["This is one", None]})

            

Reported by Pylint.

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

Line: 31 Column: 5

                  # test file from the Haven project (https://haven.tidyverse.org/)
    fname = datapath("io", "data", "spss", "labelled-num-na.sav")

    df = pd.read_spss(fname, convert_categoricals=True)
    expected = pd.DataFrame({"VAR00002": ["This is one", None]})
    expected["VAR00002"] = pd.Categorical(expected["VAR00002"])
    tm.assert_frame_equal(df, expected)

    df = pd.read_spss(fname, convert_categoricals=False)

            

Reported by Pylint.

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

Line: 36 Column: 5

                  expected["VAR00002"] = pd.Categorical(expected["VAR00002"])
    tm.assert_frame_equal(df, expected)

    df = pd.read_spss(fname, convert_categoricals=False)
    expected = pd.DataFrame({"VAR00002": [1.0, np.nan]})
    tm.assert_frame_equal(df, expected)


def test_spss_labelled_str(datapath):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 41 Column: 1

                  tm.assert_frame_equal(df, expected)


def test_spss_labelled_str(datapath):
    # test file from the Haven project (https://haven.tidyverse.org/)
    fname = datapath("io", "data", "spss", "labelled-str.sav")

    df = pd.read_spss(fname, convert_categoricals=True)
    expected = pd.DataFrame({"gender": ["Male", "Female"]})

            

Reported by Pylint.

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

Line: 45 Column: 5

                  # test file from the Haven project (https://haven.tidyverse.org/)
    fname = datapath("io", "data", "spss", "labelled-str.sav")

    df = pd.read_spss(fname, convert_categoricals=True)
    expected = pd.DataFrame({"gender": ["Male", "Female"]})
    expected["gender"] = pd.Categorical(expected["gender"])
    tm.assert_frame_equal(df, expected)

    df = pd.read_spss(fname, convert_categoricals=False)

            

Reported by Pylint.

pandas/tests/tslibs/test_ccalendar.py
15 issues
Unable to import 'hypothesis'
Error

Line: 6 Column: 1

                  datetime,
)

from hypothesis import (
    given,
    strategies as st,
)
import numpy as np
import pytest

            

Reported by Pylint.

Unable to import 'pytest'
Error

Line: 11 Column: 1

                  strategies as st,
)
import numpy as np
import pytest

from pandas._libs.tslibs import ccalendar

import pandas as pd


            

Reported by Pylint.

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

Line: 13 Column: 1

              import numpy as np
import pytest

from pandas._libs.tslibs import ccalendar

import pandas as pd


@pytest.mark.parametrize(

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from datetime import (
    date,
    datetime,
)

from hypothesis import (
    given,
    strategies as st,
)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 25 Column: 1

                      ((2004, 3, 1), 61),
        ((1907, 12, 31), 365),  # End-of-year, non-leap year.
        ((2004, 12, 31), 366),  # End-of-year, leap year.
    ],
)
def test_get_day_of_year_numeric(date_tuple, expected):
    assert ccalendar.get_day_of_year(*date_tuple) == expected



            

Reported by Pylint.

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

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

                  ],
)
def test_get_day_of_year_numeric(date_tuple, expected):
    assert ccalendar.get_day_of_year(*date_tuple) == expected


def test_get_day_of_year_dt():
    dt = datetime.fromordinal(1 + np.random.randint(365 * 4000))
    result = ccalendar.get_day_of_year(dt.year, dt.month, dt.day)

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 31 Column: 1

                  assert ccalendar.get_day_of_year(*date_tuple) == expected


def test_get_day_of_year_dt():
    dt = datetime.fromordinal(1 + np.random.randint(365 * 4000))
    result = ccalendar.get_day_of_year(dt.year, dt.month, dt.day)

    expected = (dt - dt.replace(month=1, day=1)).days + 1
    assert result == expected

            

Reported by Pylint.

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

Line: 32 Column: 5

              

def test_get_day_of_year_dt():
    dt = datetime.fromordinal(1 + np.random.randint(365 * 4000))
    result = ccalendar.get_day_of_year(dt.year, dt.month, dt.day)

    expected = (dt - dt.replace(month=1, day=1)).days + 1
    assert result == expected


            

Reported by Pylint.

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

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

                  result = ccalendar.get_day_of_year(dt.year, dt.month, dt.day)

    expected = (dt - dt.replace(month=1, day=1)).days + 1
    assert result == expected


@pytest.mark.parametrize(
    "input_date_tuple, expected_iso_tuple",
    [

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 53 Column: 1

                      [(2005, 12, 31), (2005, 52, 6)],
        [(2008, 12, 28), (2008, 52, 7)],
        [(2008, 12, 29), (2009, 1, 1)],
    ],
)
def test_dt_correct_iso_8601_year_week_and_day(input_date_tuple, expected_iso_tuple):
    result = ccalendar.get_iso_calendar(*input_date_tuple)
    expected_from_date_isocalendar = date(*input_date_tuple).isocalendar()
    assert result == expected_from_date_isocalendar

            

Reported by Pylint.

pandas/tests/series/methods/test_item.py
15 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              Series.item method, mainly testing that we get python scalars as opposed to
numpy scalars.
"""
import pytest

from pandas import (
    Series,
    Timedelta,
    Timestamp,

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 15 Column: 1

              )


class TestItem:
    def test_item(self):
        # We are testing that we get python scalars as opposed to numpy scalars
        ser = Series([1])
        result = ser.item()
        assert result == 1

            

Reported by Pylint.

Missing class docstring
Error

Line: 15 Column: 1

              )


class TestItem:
    def test_item(self):
        # We are testing that we get python scalars as opposed to numpy scalars
        ser = Series([1])
        result = ser.item()
        assert result == 1

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 5

              

class TestItem:
    def test_item(self):
        # We are testing that we get python scalars as opposed to numpy scalars
        ser = Series([1])
        result = ser.item()
        assert result == 1
        assert result == ser.iloc[0]

            

Reported by Pylint.

Method could be a function
Error

Line: 16 Column: 5

              

class TestItem:
    def test_item(self):
        # We are testing that we get python scalars as opposed to numpy scalars
        ser = Series([1])
        result = ser.item()
        assert result == 1
        assert result == ser.iloc[0]

            

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

                      # We are testing that we get python scalars as opposed to numpy scalars
        ser = Series([1])
        result = ser.item()
        assert result == 1
        assert result == ser.iloc[0]
        assert isinstance(result, int)  # i.e. not np.int64

        ser = Series([0.5], index=[3])
        result = ser.item()

            

Reported by Bandit.

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

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

                      ser = Series([1])
        result = ser.item()
        assert result == 1
        assert result == ser.iloc[0]
        assert isinstance(result, int)  # i.e. not np.int64

        ser = Series([0.5], index=[3])
        result = ser.item()
        assert isinstance(result, float)

            

Reported by Bandit.

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

                      result = ser.item()
        assert result == 1
        assert result == ser.iloc[0]
        assert isinstance(result, int)  # i.e. not np.int64

        ser = Series([0.5], index=[3])
        result = ser.item()
        assert isinstance(result, float)
        assert result == 0.5

            

Reported by Bandit.

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

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

              
        ser = Series([0.5], index=[3])
        result = ser.item()
        assert isinstance(result, float)
        assert result == 0.5

        ser = Series([1, 2])
        msg = "can only convert an array of size 1"
        with pytest.raises(ValueError, match=msg):

            

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

                      ser = Series([0.5], index=[3])
        result = ser.item()
        assert isinstance(result, float)
        assert result == 0.5

        ser = Series([1, 2])
        msg = "can only convert an array of size 1"
        with pytest.raises(ValueError, match=msg):
            ser.item()

            

Reported by Bandit.

pandas/tests/io/formats/test_css.py
15 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

import pandas._testing as tm

from pandas.io.formats.css import (
    CSSResolver,
    CSSWarning,
)


            

Reported by Pylint.

Unused argument 'name'
Error

Line: 37 Column: 34

                      ("empty-list", "", ";"),
    ],
)
def test_css_parse_normalisation(name, norm, abnorm):
    assert_same_resolution(norm, abnorm)


@pytest.mark.parametrize(
    "invalid_css,remainder",

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

import pandas._testing as tm

from pandas.io.formats.css import (
    CSSResolver,
    CSSWarning,
)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 1

              )


def assert_resolves(css, props, inherited=None):
    resolve = CSSResolver()
    actual = resolve(css, inherited=inherited)
    assert props == actual



            

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

              def assert_resolves(css, props, inherited=None):
    resolve = CSSResolver()
    actual = resolve(css, inherited=inherited)
    assert props == actual


def assert_same_resolution(css1, css2, inherited=None):
    resolve = CSSResolver()
    resolved1 = resolve(css1, inherited=inherited)

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 17 Column: 1

                  assert props == actual


def assert_same_resolution(css1, css2, inherited=None):
    resolve = CSSResolver()
    resolved1 = resolve(css1, inherited=inherited)
    resolved2 = resolve(css2, inherited=inherited)
    assert resolved1 == resolved2


            

Reported by Pylint.

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

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

                  resolve = CSSResolver()
    resolved1 = resolve(css1, inherited=inherited)
    resolved2 = resolve(css2, inherited=inherited)
    assert resolved1 == resolved2


@pytest.mark.parametrize(
    "name,norm,abnorm",
    [

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 35 Column: 1

                      ("case", "hello: world; foo: bar", "Hello: WORLD; foO: bar"),
        ("empty-decl", "hello: world; foo: bar", "; hello: world;; foo: bar;\n; ;"),
        ("empty-list", "", ";"),
    ],
)
def test_css_parse_normalisation(name, norm, abnorm):
    assert_same_resolution(norm, abnorm)



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 60 Column: 1

                      ("font-size: 1unknownunit", "font-size: 1em"),
        ("font-size: 10", "font-size: 1em"),
        ("font-size: 10 pt", "font-size: 1em"),
    ],
)
def test_css_parse_invalid(invalid_css, remainder):
    with tm.assert_produces_warning(CSSWarning):
        assert_same_resolution(invalid_css, remainder)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 97 Column: 1

                              "border-right-style",
                "border-bottom-style",
                "border-left-style",
            ],
        ),
    ],
)
def test_css_side_shorthands(shorthand, expansions):
    top, right, bottom, left = expansions

            

Reported by Pylint.