The following issues were found
pandas/tests/util/conftest.py
7 issues
Line: 1
Column: 1
import pytest
@pytest.fixture(params=[True, False])
def check_dtype(request):
return request.param
@pytest.fixture(params=[True, False])
Reported by Pylint.
Line: 1
Column: 1
import pytest
@pytest.fixture(params=[True, False])
def check_dtype(request):
return request.param
@pytest.fixture(params=[True, False])
Reported by Pylint.
Line: 5
Column: 1
@pytest.fixture(params=[True, False])
def check_dtype(request):
return request.param
@pytest.fixture(params=[True, False])
def check_exact(request):
Reported by Pylint.
Line: 10
Column: 1
@pytest.fixture(params=[True, False])
def check_exact(request):
return request.param
@pytest.fixture(params=[True, False])
def check_index_type(request):
Reported by Pylint.
Line: 15
Column: 1
@pytest.fixture(params=[True, False])
def check_index_type(request):
return request.param
@pytest.fixture(params=[0.5e-3, 0.5e-5])
def rtol(request):
Reported by Pylint.
Line: 20
Column: 1
@pytest.fixture(params=[0.5e-3, 0.5e-5])
def rtol(request):
return request.param
@pytest.fixture(params=[True, False])
def check_categorical(request):
Reported by Pylint.
Line: 25
Column: 1
@pytest.fixture(params=[True, False])
def check_categorical(request):
return request.param
Reported by Pylint.
pandas/tests/series/methods/test_values.py
7 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
IntervalIndex,
Series,
period_range,
)
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
IntervalIndex,
Series,
period_range,
)
import pandas._testing as tm
Reported by Pylint.
Line: 12
Column: 1
import pandas._testing as tm
class TestValues:
@pytest.mark.parametrize(
"data",
[
period_range("2000", periods=4),
IntervalIndex.from_breaks([1, 2, 3, 4]),
Reported by Pylint.
Line: 18
Column: 5
[
period_range("2000", periods=4),
IntervalIndex.from_breaks([1, 2, 3, 4]),
],
)
def test_values_object_extension_dtypes(self, data):
# https://github.com/pandas-dev/pandas/issues/23995
result = Series(data).values
expected = np.array(data.astype(object))
Reported by Pylint.
Line: 18
Column: 5
[
period_range("2000", periods=4),
IntervalIndex.from_breaks([1, 2, 3, 4]),
],
)
def test_values_object_extension_dtypes(self, data):
# https://github.com/pandas-dev/pandas/issues/23995
result = Series(data).values
expected = np.array(data.astype(object))
Reported by Pylint.
Line: 26
Column: 5
expected = np.array(data.astype(object))
tm.assert_numpy_array_equal(result, expected)
def test_values(self, datetime_series):
tm.assert_almost_equal(
datetime_series.values, datetime_series, check_dtype=False
)
Reported by Pylint.
Line: 26
Column: 5
expected = np.array(data.astype(object))
tm.assert_numpy_array_equal(result, expected)
def test_values(self, datetime_series):
tm.assert_almost_equal(
datetime_series.values, datetime_series, check_dtype=False
)
Reported by Pylint.
pandas/tests/indexes/timedeltas/methods/test_repeat.py
7 issues
Line: 1
Column: 1
import numpy as np
from pandas import (
TimedeltaIndex,
timedelta_range,
)
import pandas._testing as tm
Reported by Pylint.
Line: 10
Column: 1
import pandas._testing as tm
class TestRepeat:
def test_repeat(self):
index = timedelta_range("1 days", periods=2, freq="D")
exp = TimedeltaIndex(["1 days", "1 days", "2 days", "2 days"])
for res in [index.repeat(2), np.repeat(index, 2)]:
tm.assert_index_equal(res, exp)
Reported by Pylint.
Line: 10
Column: 1
import pandas._testing as tm
class TestRepeat:
def test_repeat(self):
index = timedelta_range("1 days", periods=2, freq="D")
exp = TimedeltaIndex(["1 days", "1 days", "2 days", "2 days"])
for res in [index.repeat(2), np.repeat(index, 2)]:
tm.assert_index_equal(res, exp)
Reported by Pylint.
Line: 11
Column: 5
class TestRepeat:
def test_repeat(self):
index = timedelta_range("1 days", periods=2, freq="D")
exp = TimedeltaIndex(["1 days", "1 days", "2 days", "2 days"])
for res in [index.repeat(2), np.repeat(index, 2)]:
tm.assert_index_equal(res, exp)
assert res.freq is None
Reported by Pylint.
Line: 11
Column: 5
class TestRepeat:
def test_repeat(self):
index = timedelta_range("1 days", periods=2, freq="D")
exp = TimedeltaIndex(["1 days", "1 days", "2 days", "2 days"])
for res in [index.repeat(2), np.repeat(index, 2)]:
tm.assert_index_equal(res, exp)
assert res.freq is None
Reported by Pylint.
Line: 16
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
exp = TimedeltaIndex(["1 days", "1 days", "2 days", "2 days"])
for res in [index.repeat(2), np.repeat(index, 2)]:
tm.assert_index_equal(res, exp)
assert res.freq is None
index = TimedeltaIndex(["1 days", "NaT", "3 days"])
exp = TimedeltaIndex(
[
"1 days",
Reported by Bandit.
Line: 34
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
)
for res in [index.repeat(3), np.repeat(index, 3)]:
tm.assert_index_equal(res, exp)
assert res.freq is None
Reported by Bandit.
scripts/sync_flake8_versions.py
7 issues
Line: 58
Column: 5
for hook in repo["hooks"]:
if hook["id"] == hook_name:
return repo, hook
else: # pragma: no cover
raise RuntimeError(f"Repo with hook {hook_name} not found")
def _conda_to_pip_compat(dep):
if dep.compare == "=":
Reported by Pylint.
Line: 118
Column: 5
def get_revisions(
precommit_config: YamlMapping, environment: YamlMapping
) -> tuple[Revisions, Revisions]:
flake8_revisions = Revisions(name="flake8")
pandas_dev_flaker_revisions = Revisions(name="pandas-dev-flaker")
repos = precommit_config["repos"]
Reported by Pylint.
Line: 118
Column: 36
def get_revisions(
precommit_config: YamlMapping, environment: YamlMapping
) -> tuple[Revisions, Revisions]:
flake8_revisions = Revisions(name="flake8")
pandas_dev_flaker_revisions = Revisions(name="pandas-dev-flaker")
repos = precommit_config["repos"]
Reported by Pylint.
Line: 33
Column: 1
@dataclass
class Revision:
name: str
compare: str
version: str
Reported by Pylint.
Line: 40
Column: 1
@dataclass
class Revisions:
name: str
pre_commit: Revision | None = None
yesqa: Revision | None = None
environment: Revision | None = None
Reported by Pylint.
Line: 63
Column: 5
def _conda_to_pip_compat(dep):
if dep.compare == "=":
return replace(dep, compare="==")
else:
return dep
Reported by Pylint.
Line: 117
Column: 1
yield from _process_dependencies(dep["pip"])
def get_revisions(
precommit_config: YamlMapping, environment: YamlMapping
) -> tuple[Revisions, Revisions]:
flake8_revisions = Revisions(name="flake8")
pandas_dev_flaker_revisions = Revisions(name="pandas-dev-flaker")
Reported by Pylint.
pandas/tests/indexes/period/methods/test_insert.py
7 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
NaT,
PeriodIndex,
period_range,
)
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
NaT,
PeriodIndex,
period_range,
)
import pandas._testing as tm
Reported by Pylint.
Line: 12
Column: 1
import pandas._testing as tm
class TestInsert:
@pytest.mark.parametrize("na", [np.nan, NaT, None])
def test_insert(self, na):
# GH#18295 (test missing)
expected = PeriodIndex(["2017Q1", NaT, "2017Q2", "2017Q3", "2017Q4"], freq="Q")
result = period_range("2017Q1", periods=4, freq="Q").insert(1, na)
Reported by Pylint.
Line: 12
Column: 1
import pandas._testing as tm
class TestInsert:
@pytest.mark.parametrize("na", [np.nan, NaT, None])
def test_insert(self, na):
# GH#18295 (test missing)
expected = PeriodIndex(["2017Q1", NaT, "2017Q2", "2017Q3", "2017Q4"], freq="Q")
result = period_range("2017Q1", periods=4, freq="Q").insert(1, na)
Reported by Pylint.
Line: 14
Column: 5
class TestInsert:
@pytest.mark.parametrize("na", [np.nan, NaT, None])
def test_insert(self, na):
# GH#18295 (test missing)
expected = PeriodIndex(["2017Q1", NaT, "2017Q2", "2017Q3", "2017Q4"], freq="Q")
result = period_range("2017Q1", periods=4, freq="Q").insert(1, na)
tm.assert_index_equal(result, expected)
Reported by Pylint.
Line: 14
Column: 5
class TestInsert:
@pytest.mark.parametrize("na", [np.nan, NaT, None])
def test_insert(self, na):
# GH#18295 (test missing)
expected = PeriodIndex(["2017Q1", NaT, "2017Q2", "2017Q3", "2017Q4"], freq="Q")
result = period_range("2017Q1", periods=4, freq="Q").insert(1, na)
tm.assert_index_equal(result, expected)
Reported by Pylint.
Line: 14
Column: 5
class TestInsert:
@pytest.mark.parametrize("na", [np.nan, NaT, None])
def test_insert(self, na):
# GH#18295 (test missing)
expected = PeriodIndex(["2017Q1", NaT, "2017Q2", "2017Q3", "2017Q4"], freq="Q")
result = period_range("2017Q1", periods=4, freq="Q").insert(1, na)
tm.assert_index_equal(result, expected)
Reported by Pylint.
pandas/tests/series/accessors/test_sparse_accessor.py
7 issues
Line: 1
Column: 1
from pandas import Series
class TestSparseAccessor:
def test_sparse_accessor_updates_on_inplace(self):
ser = Series([1, 1, 2, 3], dtype="Sparse[int]")
return_value = ser.drop([0, 1], inplace=True)
assert return_value is None
assert ser.sparse.density == 1.0
Reported by Pylint.
Line: 4
Column: 1
from pandas import Series
class TestSparseAccessor:
def test_sparse_accessor_updates_on_inplace(self):
ser = Series([1, 1, 2, 3], dtype="Sparse[int]")
return_value = ser.drop([0, 1], inplace=True)
assert return_value is None
assert ser.sparse.density == 1.0
Reported by Pylint.
Line: 4
Column: 1
from pandas import Series
class TestSparseAccessor:
def test_sparse_accessor_updates_on_inplace(self):
ser = Series([1, 1, 2, 3], dtype="Sparse[int]")
return_value = ser.drop([0, 1], inplace=True)
assert return_value is None
assert ser.sparse.density == 1.0
Reported by Pylint.
Line: 5
Column: 5
class TestSparseAccessor:
def test_sparse_accessor_updates_on_inplace(self):
ser = Series([1, 1, 2, 3], dtype="Sparse[int]")
return_value = ser.drop([0, 1], inplace=True)
assert return_value is None
assert ser.sparse.density == 1.0
Reported by Pylint.
Line: 5
Column: 5
class TestSparseAccessor:
def test_sparse_accessor_updates_on_inplace(self):
ser = Series([1, 1, 2, 3], dtype="Sparse[int]")
return_value = ser.drop([0, 1], inplace=True)
assert return_value is None
assert ser.sparse.density == 1.0
Reported by Pylint.
Line: 8
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_sparse_accessor_updates_on_inplace(self):
ser = Series([1, 1, 2, 3], dtype="Sparse[int]")
return_value = ser.drop([0, 1], inplace=True)
assert return_value is None
assert ser.sparse.density == 1.0
Reported by Bandit.
Line: 9
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
ser = Series([1, 1, 2, 3], dtype="Sparse[int]")
return_value = ser.drop([0, 1], inplace=True)
assert return_value is None
assert ser.sparse.density == 1.0
Reported by Bandit.
pandas/tests/io/parser/usecols/test_strings.py
7 issues
Line: 7
Column: 1
"""
from io import StringIO
import pytest
from pandas import DataFrame
import pandas._testing as tm
_msg_validate_usecols_arg = (
Reported by Pylint.
Line: 12
Column: 1
from pandas import DataFrame
import pandas._testing as tm
_msg_validate_usecols_arg = (
"'usecols' must either be list-like "
"of all strings, all unicode, all "
"integers or a callable."
)
_msg_validate_usecols_names = (
Reported by Pylint.
Line: 17
Column: 1
"of all strings, all unicode, all "
"integers or a callable."
)
_msg_validate_usecols_names = (
"Usecols do not match columns, columns expected but not found: {0}"
)
def test_usecols_with_unicode_strings(all_parsers):
Reported by Pylint.
Line: 22
Column: 1
)
def test_usecols_with_unicode_strings(all_parsers):
# see gh-13219
data = """AAA,BBB,CCC,DDD
0.056674973,8,True,a
2.613230982,2,False,b
3.568935038,7,False,a"""
Reported by Pylint.
Line: 44
Column: 1
tm.assert_frame_equal(result, expected)
def test_usecols_with_single_byte_unicode_strings(all_parsers):
# see gh-13219
data = """A,B,C,D
0.056674973,8,True,a
2.613230982,2,False,b
3.568935038,7,False,a"""
Reported by Pylint.
Line: 67
Column: 1
@pytest.mark.parametrize("usecols", [["AAA", b"BBB"], [b"AAA", "BBB"]])
def test_usecols_with_mixed_encoding_strings(all_parsers, usecols):
data = """AAA,BBB,CCC,DDD
0.056674973,8,True,a
2.613230982,2,False,b
3.568935038,7,False,a"""
parser = all_parsers
Reported by Pylint.
Line: 79
Column: 1
@pytest.mark.parametrize("usecols", [["あああ", "いい"], ["あああ", "いい"]])
def test_usecols_with_multi_byte_characters(all_parsers, usecols):
data = """あああ,いい,ううう,ええええ
0.056674973,8,True,a
2.613230982,2,False,b
3.568935038,7,False,a"""
parser = all_parsers
Reported by Pylint.
pandas/tests/util/test_assert_interval_array_equal.py
7 issues
Line: 1
Column: 1
import pytest
from pandas import interval_range
import pandas._testing as tm
@pytest.mark.parametrize(
"kwargs",
[
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas import interval_range
import pandas._testing as tm
@pytest.mark.parametrize(
"kwargs",
[
Reported by Pylint.
Line: 13
Column: 1
{"start": 0, "periods": 4},
{"start": 1, "periods": 5},
{"start": 5, "end": 10, "closed": "left"},
],
)
def test_interval_array_equal(kwargs):
arr = interval_range(**kwargs).values
tm.assert_interval_array_equal(arr, arr)
Reported by Pylint.
Line: 20
Column: 1
tm.assert_interval_array_equal(arr, arr)
def test_interval_array_equal_closed_mismatch():
kwargs = {"start": 0, "periods": 5}
arr1 = interval_range(closed="left", **kwargs).values
arr2 = interval_range(closed="right", **kwargs).values
msg = """\
Reported by Pylint.
Line: 36
Column: 1
tm.assert_interval_array_equal(arr1, arr2)
def test_interval_array_equal_periods_mismatch():
kwargs = {"start": 0}
arr1 = interval_range(periods=5, **kwargs).values
arr2 = interval_range(periods=6, **kwargs).values
msg = """\
Reported by Pylint.
Line: 52
Column: 1
tm.assert_interval_array_equal(arr1, arr2)
def test_interval_array_equal_end_mismatch():
kwargs = {"start": 0, "periods": 5}
arr1 = interval_range(end=10, **kwargs).values
arr2 = interval_range(end=20, **kwargs).values
msg = """\
Reported by Pylint.
Line: 68
Column: 1
tm.assert_interval_array_equal(arr1, arr2)
def test_interval_array_equal_start_mismatch():
kwargs = {"periods": 4}
arr1 = interval_range(start=0, **kwargs).values
arr2 = interval_range(start=1, **kwargs).values
msg = """\
Reported by Pylint.
pandas/tests/internals/test_api.py
7 issues
Line: 11
Column: 1
from pandas.core.internals import api
def test_internals_api():
assert internals.make_block is api.make_block
def test_namespace():
# SUBJECT TO CHANGE
Reported by Pylint.
Line: 12
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_internals_api():
assert internals.make_block is api.make_block
def test_namespace():
# SUBJECT TO CHANGE
Reported by Bandit.
Line: 15
Column: 1
assert internals.make_block is api.make_block
def test_namespace():
# SUBJECT TO CHANGE
modules = [
"blocks",
"concat",
Reported by Pylint.
Line: 46
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
]
result = [x for x in dir(internals) if not x.startswith("__")]
assert set(result) == set(expected + modules)
def test_make_block_2d_with_dti():
# GH#41168
dti = pd.date_range("2012", periods=3, tz="UTC")
Reported by Bandit.
Line: 49
Column: 1
assert set(result) == set(expected + modules)
def test_make_block_2d_with_dti():
# GH#41168
dti = pd.date_range("2012", periods=3, tz="UTC")
blk = api.make_block(dti, placement=[0])
assert blk.shape == (1, 3)
Reported by Pylint.
Line: 54
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
dti = pd.date_range("2012", periods=3, tz="UTC")
blk = api.make_block(dti, placement=[0])
assert blk.shape == (1, 3)
assert blk.values.shape == (1, 3)
Reported by Bandit.
Line: 55
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
blk = api.make_block(dti, placement=[0])
assert blk.shape == (1, 3)
assert blk.values.shape == (1, 3)
Reported by Bandit.
pandas/tests/series/methods/test_nunique.py
6 issues
Line: 1
Column: 1
import numpy as np
from pandas import (
Categorical,
Series,
)
def test_nunique():
Reported by Pylint.
Line: 9
Column: 1
)
def test_nunique():
# basics.rst doc example
series = Series(np.random.randn(500))
series[20:500] = np.nan
series[10:20] = 5000
result = series.nunique()
Reported by Pylint.
Line: 15
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
series[20:500] = np.nan
series[10:20] = 5000
result = series.nunique()
assert result == 11
def test_nunique_categorical():
# GH#18051
ser = Series(Categorical([]))
Reported by Bandit.
Line: 18
Column: 1
assert result == 11
def test_nunique_categorical():
# GH#18051
ser = Series(Categorical([]))
assert ser.nunique() == 0
ser = Series(Categorical([np.nan]))
Reported by Pylint.
Line: 21
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_nunique_categorical():
# GH#18051
ser = Series(Categorical([]))
assert ser.nunique() == 0
ser = Series(Categorical([np.nan]))
assert ser.nunique() == 0
Reported by Bandit.
Line: 24
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert ser.nunique() == 0
ser = Series(Categorical([np.nan]))
assert ser.nunique() == 0
Reported by Bandit.