The following issues were found
pandas/tests/scalar/interval/test_arithmetic.py
10 issues
Line: 4
Column: 1
from datetime import timedelta
import numpy as np
import pytest
from pandas import (
Interval,
Timedelta,
Timestamp,
Reported by Pylint.
Line: 48
Column: 9
]
)
with pytest.raises((TypeError, ValueError), match=msg):
interval + delta
with pytest.raises((TypeError, ValueError), match=msg):
delta + interval
Reported by Pylint.
Line: 51
Column: 9
interval + delta
with pytest.raises((TypeError, ValueError), match=msg):
delta + interval
@pytest.mark.parametrize("klass", [timedelta, np.timedelta64, Timedelta])
def test_timdelta_add_timestamp_interval(klass):
delta = klass(0)
Reported by Pylint.
Line: 1
Column: 1
from datetime import timedelta
import numpy as np
import pytest
from pandas import (
Interval,
Timedelta,
Timestamp,
Reported by Pylint.
Line: 21
Column: 1
Interval(Timedelta(days=7), Timedelta(days=14)),
],
)
@pytest.mark.parametrize(
"delta", [Timedelta(days=7), timedelta(7), np.timedelta64(7, "D")]
)
def test_time_interval_add_subtract_timedelta(interval, delta, method):
# https://github.com/pandas-dev/pandas/issues/32023
result = getattr(interval, method)(delta)
Reported by Pylint.
Line: 31
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
right = getattr(interval.right, method)(delta)
expected = Interval(left, right)
assert result == expected
@pytest.mark.parametrize("interval", [Interval(1, 2), Interval(1.0, 2.0)])
@pytest.mark.parametrize(
"delta", [Timedelta(days=7), timedelta(7), np.timedelta64(7, "D")]
Reported by Bandit.
Line: 37
Column: 1
@pytest.mark.parametrize("interval", [Interval(1, 2), Interval(1.0, 2.0)])
@pytest.mark.parametrize(
"delta", [Timedelta(days=7), timedelta(7), np.timedelta64(7, "D")]
)
def test_numeric_interval_add_timedelta_raises(interval, delta):
# https://github.com/pandas-dev/pandas/issues/32023
msg = "|".join(
[
"unsupported operand",
Reported by Pylint.
Line: 55
Column: 1
@pytest.mark.parametrize("klass", [timedelta, np.timedelta64, Timedelta])
def test_timdelta_add_timestamp_interval(klass):
delta = klass(0)
expected = Interval(Timestamp("2020-01-01"), Timestamp("2020-02-01"))
result = delta + expected
assert result == expected
Reported by Pylint.
Line: 60
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
expected = Interval(Timestamp("2020-01-01"), Timestamp("2020-02-01"))
result = delta + expected
assert result == expected
result = expected + delta
assert result == expected
Reported by Bandit.
Line: 63
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert result == expected
result = expected + delta
assert result == expected
Reported by Bandit.
pandas/tests/io/parser/dtypes/test_empty.py
10 issues
Line: 8
Column: 1
from io import StringIO
import numpy as np
import pytest
from pandas import (
Categorical,
DataFrame,
Index,
Reported by Pylint.
Line: 21
Column: 1
import pandas._testing as tm
def test_dtype_all_columns_empty(all_parsers):
# see gh-12048
parser = all_parsers
result = parser.read_csv(StringIO("A,B"), dtype=str)
expected = DataFrame({"A": [], "B": []}, index=[], dtype=str)
Reported by Pylint.
Line: 30
Column: 1
tm.assert_frame_equal(result, expected)
def test_empty_pass_dtype(all_parsers):
parser = all_parsers
data = "one,two"
result = parser.read_csv(StringIO(data), dtype={"one": "u1"})
Reported by Pylint.
Line: 43
Column: 1
tm.assert_frame_equal(result, expected)
def test_empty_with_index_pass_dtype(all_parsers):
parser = all_parsers
data = "one,two"
result = parser.read_csv(
StringIO(data), index_col=["one"], dtype={"one": "u1", 1: "f"}
Reported by Pylint.
Line: 57
Column: 1
tm.assert_frame_equal(result, expected)
def test_empty_with_multi_index_pass_dtype(all_parsers):
parser = all_parsers
data = "one,two,three"
result = parser.read_csv(
StringIO(data), index_col=["one", "two"], dtype={"one": "u1", 1: "f8"}
Reported by Pylint.
Line: 73
Column: 1
tm.assert_frame_equal(result, expected)
def test_empty_with_mangled_column_pass_dtype_by_names(all_parsers):
parser = all_parsers
data = "one,one"
result = parser.read_csv(StringIO(data), dtype={"one": "u1", "one.1": "f"})
Reported by Pylint.
Line: 86
Column: 1
tm.assert_frame_equal(result, expected)
def test_empty_with_mangled_column_pass_dtype_by_indexes(all_parsers):
parser = all_parsers
data = "one,one"
result = parser.read_csv(StringIO(data), dtype={0: "u1", 1: "f"})
Reported by Pylint.
Line: 99
Column: 1
tm.assert_frame_equal(result, expected)
def test_empty_with_dup_column_pass_dtype_by_indexes(all_parsers):
# see gh-9424
parser = all_parsers
expected = concat(
[Series([], name="one", dtype="u1"), Series([], name="one.1", dtype="f")],
axis=1,
Reported by Pylint.
Line: 113
Column: 1
tm.assert_frame_equal(result, expected)
def test_empty_with_dup_column_pass_dtype_by_indexes_raises(all_parsers):
# see gh-9424
parser = all_parsers
expected = concat(
[Series([], name="one", dtype="u1"), Series([], name="one.1", dtype="f")],
axis=1,
Reported by Pylint.
Line: 169
Column: 1
DataFrame(
{"a": Series([], dtype=np.int64), "b": Series([], dtype=np.int32)},
index=[],
),
),
],
)
def test_empty_dtype(all_parsers, dtype, expected):
# see gh-14712
Reported by Pylint.
pandas/tests/io/parser/conftest.py
10 issues
Line: 5
Column: 1
import os
import pytest
from pandas import (
read_csv,
read_table,
)
Reported by Pylint.
Line: 1
Column: 1
from __future__ import annotations
import os
import pytest
from pandas import (
read_csv,
read_table,
Reported by Pylint.
Line: 13
Column: 1
)
class BaseParser:
engine: str | None = None
low_memory = True
float_precision_choices: list[str | None] = []
def update_kwargs(self, kwargs):
Reported by Pylint.
Line: 18
Column: 5
low_memory = True
float_precision_choices: list[str | None] = []
def update_kwargs(self, kwargs):
kwargs = kwargs.copy()
kwargs.update({"engine": self.engine, "low_memory": self.low_memory})
return kwargs
Reported by Pylint.
Line: 24
Column: 5
return kwargs
def read_csv(self, *args, **kwargs):
kwargs = self.update_kwargs(kwargs)
return read_csv(*args, **kwargs)
def read_table(self, *args, **kwargs):
kwargs = self.update_kwargs(kwargs)
Reported by Pylint.
Line: 28
Column: 5
kwargs = self.update_kwargs(kwargs)
return read_csv(*args, **kwargs)
def read_table(self, *args, **kwargs):
kwargs = self.update_kwargs(kwargs)
return read_table(*args, **kwargs)
class CParser(BaseParser):
Reported by Pylint.
Line: 33
Column: 1
return read_table(*args, **kwargs)
class CParser(BaseParser):
engine = "c"
float_precision_choices = [None, "high", "round_trip"]
class CParserHighMemory(CParser):
Reported by Pylint.
Line: 38
Column: 1
float_precision_choices = [None, "high", "round_trip"]
class CParserHighMemory(CParser):
low_memory = False
class CParserLowMemory(CParser):
low_memory = True
Reported by Pylint.
Line: 42
Column: 1
low_memory = False
class CParserLowMemory(CParser):
low_memory = True
class PythonParser(BaseParser):
engine = "python"
Reported by Pylint.
Line: 46
Column: 1
low_memory = True
class PythonParser(BaseParser):
engine = "python"
float_precision_choices = [None]
@pytest.fixture
Reported by Pylint.
pandas/tests/series/methods/test_is_unique.py
10 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import Series
from pandas.core.construction import create_series_with_explicit_dtype
@pytest.mark.parametrize(
"data, expected",
Reported by Pylint.
Line: 39
Column: 5
li = [Foo(i) for i in range(5)]
ser = Series(li, index=list(range(5)))
ser.is_unique
captured = capsys.readouterr()
assert len(captured.err) == 0
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import Series
from pandas.core.construction import create_series_with_explicit_dtype
@pytest.mark.parametrize(
"data, expected",
Reported by Pylint.
Line: 18
Column: 1
(["foo", "bar", np.nan], True),
(["foo", "foo", np.nan], False),
(["foo", "bar", np.nan, np.nan], False),
],
)
def test_is_unique(data, expected):
# GH#11946 / GH#25180
ser = create_series_with_explicit_dtype(data, dtype_if_empty=object)
assert ser.is_unique is expected
Reported by Pylint.
Line: 23
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_is_unique(data, expected):
# GH#11946 / GH#25180
ser = create_series_with_explicit_dtype(data, dtype_if_empty=object)
assert ser.is_unique is expected
def test_is_unique_class_ne(capsys):
# GH#20661
class Foo:
Reported by Bandit.
Line: 26
Column: 1
assert ser.is_unique is expected
def test_is_unique_class_ne(capsys):
# GH#20661
class Foo:
def __init__(self, val):
self._value = val
Reported by Pylint.
Line: 28
Column: 5
def test_is_unique_class_ne(capsys):
# GH#20661
class Foo:
def __init__(self, val):
self._value = val
def __ne__(self, other):
raise Exception("NEQ not supported")
Reported by Pylint.
Line: 28
Column: 5
def test_is_unique_class_ne(capsys):
# GH#20661
class Foo:
def __init__(self, val):
self._value = val
def __ne__(self, other):
raise Exception("NEQ not supported")
Reported by Pylint.
Line: 36
Column: 9
raise Exception("NEQ not supported")
with capsys.disabled():
li = [Foo(i) for i in range(5)]
ser = Series(li, index=list(range(5)))
ser.is_unique
captured = capsys.readouterr()
assert len(captured.err) == 0
Reported by Pylint.
Line: 41
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
ser.is_unique
captured = capsys.readouterr()
assert len(captured.err) == 0
Reported by Bandit.
pandas/tests/series/methods/test_repeat.py
10 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
MultiIndex,
Series,
)
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
MultiIndex,
Series,
)
import pandas._testing as tm
Reported by Pylint.
Line: 11
Column: 1
import pandas._testing as tm
class TestRepeat:
def test_repeat(self):
ser = Series(np.random.randn(3), index=["a", "b", "c"])
reps = ser.repeat(5)
exp = Series(ser.values.repeat(5), index=ser.index.values.repeat(5))
Reported by Pylint.
Line: 12
Column: 5
class TestRepeat:
def test_repeat(self):
ser = Series(np.random.randn(3), index=["a", "b", "c"])
reps = ser.repeat(5)
exp = Series(ser.values.repeat(5), index=ser.index.values.repeat(5))
tm.assert_series_equal(reps, exp)
Reported by Pylint.
Line: 12
Column: 5
class TestRepeat:
def test_repeat(self):
ser = Series(np.random.randn(3), index=["a", "b", "c"])
reps = ser.repeat(5)
exp = Series(ser.values.repeat(5), index=ser.index.values.repeat(5))
tm.assert_series_equal(reps, exp)
Reported by Pylint.
Line: 24
Column: 5
exp = Series(ser.values.repeat(to_rep), index=ser.index.values.repeat(to_rep))
tm.assert_series_equal(reps, exp)
def test_numpy_repeat(self):
ser = Series(np.arange(3), name="x")
expected = Series(
ser.values.repeat(2), name="x", index=ser.index.values.repeat(2)
)
tm.assert_series_equal(np.repeat(ser, 2), expected)
Reported by Pylint.
Line: 24
Column: 5
exp = Series(ser.values.repeat(to_rep), index=ser.index.values.repeat(to_rep))
tm.assert_series_equal(reps, exp)
def test_numpy_repeat(self):
ser = Series(np.arange(3), name="x")
expected = Series(
ser.values.repeat(2), name="x", index=ser.index.values.repeat(2)
)
tm.assert_series_equal(np.repeat(ser, 2), expected)
Reported by Pylint.
Line: 35
Column: 5
with pytest.raises(ValueError, match=msg):
np.repeat(ser, 2, axis=0)
def test_repeat_with_multiindex(self):
# GH#9361, fixed by GH#7891
m_idx = MultiIndex.from_tuples([(1, 2), (3, 4), (5, 6), (7, 8)])
data = ["a", "b", "c", "d"]
m_df = Series(data, index=m_idx)
assert m_df.repeat(3).shape == (3 * len(data),)
Reported by Pylint.
Line: 35
Column: 5
with pytest.raises(ValueError, match=msg):
np.repeat(ser, 2, axis=0)
def test_repeat_with_multiindex(self):
# GH#9361, fixed by GH#7891
m_idx = MultiIndex.from_tuples([(1, 2), (3, 4), (5, 6), (7, 8)])
data = ["a", "b", "c", "d"]
m_df = Series(data, index=m_idx)
assert m_df.repeat(3).shape == (3 * len(data),)
Reported by Pylint.
Line: 40
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
m_idx = MultiIndex.from_tuples([(1, 2), (3, 4), (5, 6), (7, 8)])
data = ["a", "b", "c", "d"]
m_df = Series(data, index=m_idx)
assert m_df.repeat(3).shape == (3 * len(data),)
Reported by Bandit.
pandas/tests/indexing/test_check_indexer.py
10 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.api.indexers import check_array_indexer
@pytest.mark.parametrize(
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.api.indexers import check_array_indexer
@pytest.mark.parametrize(
Reported by Pylint.
Line: 26
Column: 1
),
# other
([], np.array([], dtype=np.intp)),
],
)
def test_valid_input(indexer, expected):
arr = np.array([1, 2, 3])
result = check_array_indexer(arr, indexer)
tm.assert_numpy_array_equal(result, expected)
Reported by Pylint.
Line: 36
Column: 1
@pytest.mark.parametrize(
"indexer", [[True, False, None], pd.array([True, False, None], dtype="boolean")]
)
def test_boolean_na_returns_indexer(indexer):
# https://github.com/pandas-dev/pandas/issues/31503
arr = np.array([1, 2, 3])
result = check_array_indexer(arr, indexer)
Reported by Pylint.
Line: 53
Column: 1
[True, False],
pd.array([True, False], dtype="boolean"),
np.array([True, False], dtype=np.bool_),
],
)
def test_bool_raise_length(indexer):
arr = np.array([1, 2, 3])
msg = "Boolean index has wrong length"
Reported by Pylint.
Line: 65
Column: 1
@pytest.mark.parametrize(
"indexer", [[0, 1, None], pd.array([0, 1, pd.NA], dtype="Int64")]
)
def test_int_raise_missing_values(indexer):
arr = np.array([1, 2, 3])
msg = "Cannot index with an integer indexer containing NA values"
with pytest.raises(ValueError, match=msg):
Reported by Pylint.
Line: 81
Column: 1
np.array([1.0, 2.0], dtype="float64"),
np.array([True, False], dtype=object),
pd.Index([True, False], dtype=object),
],
)
def test_raise_invalid_array_dtypes(indexer):
arr = np.array([1, 2, 3])
msg = "arrays used as indices must be of integer or boolean type"
Reported by Pylint.
Line: 91
Column: 1
check_array_indexer(arr, indexer)
def test_raise_nullable_string_dtype(nullable_string_dtype):
indexer = pd.array(["a", "b"], dtype=nullable_string_dtype)
arr = np.array([1, 2, 3])
msg = "arrays used as indices must be of integer or boolean type"
with pytest.raises(IndexError, match=msg):
Reported by Pylint.
Line: 101
Column: 1
@pytest.mark.parametrize("indexer", [None, Ellipsis, slice(0, 3), (None,)])
def test_pass_through_non_array_likes(indexer):
arr = np.array([1, 2, 3])
result = check_array_indexer(arr, indexer)
assert result == indexer
Reported by Pylint.
Line: 105
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
arr = np.array([1, 2, 3])
result = check_array_indexer(arr, indexer)
assert result == indexer
Reported by Bandit.
pandas/tests/indexes/period/test_ops.py
10 issues
Line: 1
Column: 1
import pytest
import pandas as pd
import pandas._testing as tm
class TestPeriodIndexOps:
@pytest.mark.parametrize(
"freq,expected",
Reported by Pylint.
Line: 24
Column: 16
)
def test_resolution(self, freq, expected):
idx = pd.period_range(start="2013-04-01", periods=30, freq=freq)
assert idx.resolution == expected
def test_freq_setter_deprecated(self):
# GH 20678
idx = pd.period_range("2018Q1", periods=4, freq="Q")
Reported by Pylint.
Line: 32
Column: 13
# no warning for getter
with tm.assert_produces_warning(None):
idx.freq
# warning for setter
with pytest.raises(AttributeError, match="can't set attribute"):
idx.freq = pd.offsets.Day()
Reported by Pylint.
Line: 1
Column: 1
import pytest
import pandas as pd
import pandas._testing as tm
class TestPeriodIndexOps:
@pytest.mark.parametrize(
"freq,expected",
Reported by Pylint.
Line: 7
Column: 1
import pandas._testing as tm
class TestPeriodIndexOps:
@pytest.mark.parametrize(
"freq,expected",
[
("A", "year"),
("Q", "quarter"),
Reported by Pylint.
Line: 20
Column: 5
("S", "second"),
("L", "millisecond"),
("U", "microsecond"),
],
)
def test_resolution(self, freq, expected):
idx = pd.period_range(start="2013-04-01", periods=30, freq=freq)
assert idx.resolution == expected
Reported by Pylint.
Line: 20
Column: 5
("S", "second"),
("L", "millisecond"),
("U", "microsecond"),
],
)
def test_resolution(self, freq, expected):
idx = pd.period_range(start="2013-04-01", periods=30, freq=freq)
assert idx.resolution == expected
Reported by Pylint.
Line: 24
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
)
def test_resolution(self, freq, expected):
idx = pd.period_range(start="2013-04-01", periods=30, freq=freq)
assert idx.resolution == expected
def test_freq_setter_deprecated(self):
# GH 20678
idx = pd.period_range("2018Q1", periods=4, freq="Q")
Reported by Bandit.
Line: 26
Column: 5
idx = pd.period_range(start="2013-04-01", periods=30, freq=freq)
assert idx.resolution == expected
def test_freq_setter_deprecated(self):
# GH 20678
idx = pd.period_range("2018Q1", periods=4, freq="Q")
# no warning for getter
with tm.assert_produces_warning(None):
Reported by Pylint.
Line: 26
Column: 5
idx = pd.period_range(start="2013-04-01", periods=30, freq=freq)
assert idx.resolution == expected
def test_freq_setter_deprecated(self):
# GH 20678
idx = pd.period_range("2018Q1", periods=4, freq="Q")
# no warning for getter
with tm.assert_produces_warning(None):
Reported by Pylint.
pandas/tests/tslibs/test_timedeltas.py
10 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs.timedeltas import delta_to_nanoseconds
from pandas import (
Timedelta,
offsets,
)
Reported by Pylint.
Line: 4
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs.timedeltas import delta_to_nanoseconds
from pandas import (
Timedelta,
offsets,
)
Reported by Pylint.
Line: 4
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs.timedeltas import delta_to_nanoseconds
from pandas import (
Timedelta,
offsets,
)
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs.timedeltas import delta_to_nanoseconds
from pandas import (
Timedelta,
offsets,
)
Reported by Pylint.
Line: 22
Column: 1
(1, 1),
(np.int64(2), 2),
(np.int32(3), 3),
],
)
def test_delta_to_nanoseconds(obj, expected):
result = delta_to_nanoseconds(obj)
assert result == expected
Reported by Pylint.
Line: 26
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
)
def test_delta_to_nanoseconds(obj, expected):
result = delta_to_nanoseconds(obj)
assert result == expected
def test_delta_to_nanoseconds_error():
obj = np.array([123456789], dtype="m8[ns]")
Reported by Bandit.
Line: 29
Column: 1
assert result == expected
def test_delta_to_nanoseconds_error():
obj = np.array([123456789], dtype="m8[ns]")
with pytest.raises(TypeError, match="<class 'numpy.ndarray'>"):
delta_to_nanoseconds(obj)
Reported by Pylint.
Line: 36
Column: 1
delta_to_nanoseconds(obj)
def test_huge_nanoseconds_overflow():
# GH 32402
assert delta_to_nanoseconds(Timedelta(1e10)) == 1e10
assert delta_to_nanoseconds(Timedelta(nanoseconds=1e10)) == 1e10
Reported by Pylint.
Line: 38
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_huge_nanoseconds_overflow():
# GH 32402
assert delta_to_nanoseconds(Timedelta(1e10)) == 1e10
assert delta_to_nanoseconds(Timedelta(nanoseconds=1e10)) == 1e10
Reported by Bandit.
Line: 39
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_huge_nanoseconds_overflow():
# GH 32402
assert delta_to_nanoseconds(Timedelta(1e10)) == 1e10
assert delta_to_nanoseconds(Timedelta(nanoseconds=1e10)) == 1e10
Reported by Bandit.
pandas/tests/util/test_deprecate.py
10 issues
Line: 3
Column: 1
from textwrap import dedent
import pytest
from pandas.util._decorators import deprecate
import pandas._testing as tm
Reported by Pylint.
Line: 37
Column: 5
This is the extended summary. The deprecate directive goes before this.
"""
pass
def test_deprecate_ok():
depr_func = deprecate("depr_func", new_func, "1.0", msg="Use new_func instead.")
Reported by Pylint.
Line: 1
Column: 1
from textwrap import dedent
import pytest
from pandas.util._decorators import deprecate
import pandas._testing as tm
Reported by Pylint.
Line: 19
Column: 1
return "new_func called"
def new_func_no_docstring():
return "new_func_no_docstring called"
def new_func_wrong_docstring():
"""Summary should be in the next line."""
Reported by Pylint.
Line: 40
Column: 1
pass
def test_deprecate_ok():
depr_func = deprecate("depr_func", new_func, "1.0", msg="Use new_func instead.")
with tm.assert_produces_warning(FutureWarning):
result = depr_func()
Reported by Pylint.
Line: 46
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
with tm.assert_produces_warning(FutureWarning):
result = depr_func()
assert result == "new_func called"
assert depr_func.__doc__ == dedent(new_func_with_deprecation.__doc__)
def test_deprecate_no_docstring():
depr_func = deprecate(
Reported by Bandit.
Line: 47
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
result = depr_func()
assert result == "new_func called"
assert depr_func.__doc__ == dedent(new_func_with_deprecation.__doc__)
def test_deprecate_no_docstring():
depr_func = deprecate(
"depr_func", new_func_no_docstring, "1.0", msg="Use new_func instead."
Reported by Bandit.
Line: 50
Column: 1
assert depr_func.__doc__ == dedent(new_func_with_deprecation.__doc__)
def test_deprecate_no_docstring():
depr_func = deprecate(
"depr_func", new_func_no_docstring, "1.0", msg="Use new_func instead."
)
with tm.assert_produces_warning(FutureWarning):
result = depr_func()
Reported by Pylint.
Line: 56
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
)
with tm.assert_produces_warning(FutureWarning):
result = depr_func()
assert result == "new_func_no_docstring called"
def test_deprecate_wrong_docstring():
msg = "deprecate needs a correctly formatted docstring"
with pytest.raises(AssertionError, match=msg):
Reported by Bandit.
Line: 59
Column: 1
assert result == "new_func_no_docstring called"
def test_deprecate_wrong_docstring():
msg = "deprecate needs a correctly formatted docstring"
with pytest.raises(AssertionError, match=msg):
deprecate(
"depr_func", new_func_wrong_docstring, "1.0", msg="Use new_func instead."
)
Reported by Pylint.
pandas/tests/util/test_safe_import.py
10 issues
Line: 4
Column: 1
import sys
import types
import pytest
import pandas.util._test_decorators as td
@pytest.mark.parametrize("name", ["foo", "hello123"])
Reported by Pylint.
Line: 1
Column: 1
import sys
import types
import pytest
import pandas.util._test_decorators as td
@pytest.mark.parametrize("name", ["foo", "hello123"])
Reported by Pylint.
Line: 10
Column: 1
@pytest.mark.parametrize("name", ["foo", "hello123"])
def test_safe_import_non_existent(name):
assert not td.safe_import(name)
def test_safe_import_exists():
assert td.safe_import("pandas")
Reported by Pylint.
Line: 11
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
@pytest.mark.parametrize("name", ["foo", "hello123"])
def test_safe_import_non_existent(name):
assert not td.safe_import(name)
def test_safe_import_exists():
assert td.safe_import("pandas")
Reported by Bandit.
Line: 14
Column: 1
assert not td.safe_import(name)
def test_safe_import_exists():
assert td.safe_import("pandas")
@pytest.mark.parametrize("min_version,valid", [("0.0.0", True), ("99.99.99", False)])
def test_safe_import_versions(min_version, valid):
Reported by Pylint.
Line: 15
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_safe_import_exists():
assert td.safe_import("pandas")
@pytest.mark.parametrize("min_version,valid", [("0.0.0", True), ("99.99.99", False)])
def test_safe_import_versions(min_version, valid):
result = td.safe_import("pandas", min_version=min_version)
Reported by Bandit.
Line: 19
Column: 1
@pytest.mark.parametrize("min_version,valid", [("0.0.0", True), ("99.99.99", False)])
def test_safe_import_versions(min_version, valid):
result = td.safe_import("pandas", min_version=min_version)
result = result if valid else not result
assert result
Reported by Pylint.
Line: 22
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_safe_import_versions(min_version, valid):
result = td.safe_import("pandas", min_version=min_version)
result = result if valid else not result
assert result
@pytest.mark.parametrize(
"min_version,valid", [(None, False), ("1.0", True), ("2.0", False)]
)
Reported by Bandit.
Line: 27
Column: 1
@pytest.mark.parametrize(
"min_version,valid", [(None, False), ("1.0", True), ("2.0", False)]
)
def test_safe_import_dummy(monkeypatch, min_version, valid):
mod_name = "hello123"
mod = types.ModuleType(mod_name)
mod.__version__ = "1.5"
Reported by Pylint.
Line: 39
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
result = td.safe_import(mod_name, min_version=min_version)
result = result if valid else not result
assert result
Reported by Bandit.