The following issues were found
pandas/tests/frame/methods/test_droplevel.py
9 issues
Line: 1
Column: 1
import pytest
from pandas import (
DataFrame,
Index,
MultiIndex,
)
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas import (
DataFrame,
Index,
MultiIndex,
)
import pandas._testing as tm
Reported by Pylint.
Line: 11
Column: 1
import pandas._testing as tm
class TestDropLevel:
def test_droplevel(self, frame_or_series):
# GH#20342
cols = MultiIndex.from_tuples(
[("c", "e"), ("d", "f")], names=["level_1", "level_2"]
)
Reported by Pylint.
Line: 11
Column: 1
import pandas._testing as tm
class TestDropLevel:
def test_droplevel(self, frame_or_series):
# GH#20342
cols = MultiIndex.from_tuples(
[("c", "e"), ("d", "f")], names=["level_1", "level_2"]
)
Reported by Pylint.
Line: 12
Column: 5
class TestDropLevel:
def test_droplevel(self, frame_or_series):
# GH#20342
cols = MultiIndex.from_tuples(
[("c", "e"), ("d", "f")], names=["level_1", "level_2"]
)
mi = MultiIndex.from_tuples([(1, 2), (5, 6), (9, 10)], names=["a", "b"])
Reported by Pylint.
Line: 12
Column: 5
class TestDropLevel:
def test_droplevel(self, frame_or_series):
# GH#20342
cols = MultiIndex.from_tuples(
[("c", "e"), ("d", "f")], names=["level_1", "level_2"]
)
mi = MultiIndex.from_tuples([(1, 2), (5, 6), (9, 10)], names=["a", "b"])
Reported by Pylint.
Line: 17
Column: 9
cols = MultiIndex.from_tuples(
[("c", "e"), ("d", "f")], names=["level_1", "level_2"]
)
mi = MultiIndex.from_tuples([(1, 2), (5, 6), (9, 10)], names=["a", "b"])
df = DataFrame([[3, 4], [7, 8], [11, 12]], index=mi, columns=cols)
if frame_or_series is not DataFrame:
df = df.iloc[:, 0]
# test that dropping of a level in index works
Reported by Pylint.
Line: 18
Column: 9
[("c", "e"), ("d", "f")], names=["level_1", "level_2"]
)
mi = MultiIndex.from_tuples([(1, 2), (5, 6), (9, 10)], names=["a", "b"])
df = DataFrame([[3, 4], [7, 8], [11, 12]], index=mi, columns=cols)
if frame_or_series is not DataFrame:
df = df.iloc[:, 0]
# test that dropping of a level in index works
expected = df.reset_index("a", drop=True)
Reported by Pylint.
Line: 20
Column: 13
mi = MultiIndex.from_tuples([(1, 2), (5, 6), (9, 10)], names=["a", "b"])
df = DataFrame([[3, 4], [7, 8], [11, 12]], index=mi, columns=cols)
if frame_or_series is not DataFrame:
df = df.iloc[:, 0]
# test that dropping of a level in index works
expected = df.reset_index("a", drop=True)
result = df.droplevel("a", axis="index")
tm.assert_equal(result, expected)
Reported by Pylint.
pandas/io/excel/_xlrd.py
9 issues
Line: 29
Column: 9
@property
def _workbook_class(self):
from xlrd import Book
return Book
def load_workbook(self, filepath_or_buffer):
from xlrd import open_workbook
Reported by Pylint.
Line: 34
Column: 9
return Book
def load_workbook(self, filepath_or_buffer):
from xlrd import open_workbook
if hasattr(filepath_or_buffer, "read"):
data = filepath_or_buffer.read()
return open_workbook(file_contents=data)
else:
Reported by Pylint.
Line: 55
Column: 9
return self.book.sheet_by_index(index)
def get_sheet_data(self, sheet, convert_float):
from xlrd import (
XL_CELL_BOOLEAN,
XL_CELL_DATE,
XL_CELL_ERROR,
XL_CELL_NUMBER,
xldate,
Reported by Pylint.
Line: 1
Column: 1
from datetime import time
import numpy as np
from pandas._typing import StorageOptions
from pandas.compat._optional import import_optional_dependency
from pandas.io.excel._base import BaseExcelReader
Reported by Pylint.
Line: 11
Column: 1
from pandas.io.excel._base import BaseExcelReader
class XlrdReader(BaseExcelReader):
def __init__(self, filepath_or_buffer, storage_options: StorageOptions = None):
"""
Reader using xlrd engine.
Parameters
Reported by Pylint.
Line: 29
Column: 9
@property
def _workbook_class(self):
from xlrd import Book
return Book
def load_workbook(self, filepath_or_buffer):
from xlrd import open_workbook
Reported by Pylint.
Line: 34
Column: 9
return Book
def load_workbook(self, filepath_or_buffer):
from xlrd import open_workbook
if hasattr(filepath_or_buffer, "read"):
data = filepath_or_buffer.read()
return open_workbook(file_contents=data)
else:
Reported by Pylint.
Line: 36
Column: 9
def load_workbook(self, filepath_or_buffer):
from xlrd import open_workbook
if hasattr(filepath_or_buffer, "read"):
data = filepath_or_buffer.read()
return open_workbook(file_contents=data)
else:
return open_workbook(filepath_or_buffer)
Reported by Pylint.
Line: 55
Column: 9
return self.book.sheet_by_index(index)
def get_sheet_data(self, sheet, convert_float):
from xlrd import (
XL_CELL_BOOLEAN,
XL_CELL_DATE,
XL_CELL_ERROR,
XL_CELL_NUMBER,
xldate,
Reported by Pylint.
pandas/tests/frame/methods/test_swaplevel.py
9 issues
Line: 1
Column: 1
import pytest
from pandas import DataFrame
import pandas._testing as tm
class TestSwaplevel:
def test_swaplevel(self, multiindex_dataframe_random_data):
frame = multiindex_dataframe_random_data
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas import DataFrame
import pandas._testing as tm
class TestSwaplevel:
def test_swaplevel(self, multiindex_dataframe_random_data):
frame = multiindex_dataframe_random_data
Reported by Pylint.
Line: 7
Column: 1
import pandas._testing as tm
class TestSwaplevel:
def test_swaplevel(self, multiindex_dataframe_random_data):
frame = multiindex_dataframe_random_data
swapped = frame["A"].swaplevel()
swapped2 = frame["A"].swaplevel(0)
Reported by Pylint.
Line: 7
Column: 1
import pandas._testing as tm
class TestSwaplevel:
def test_swaplevel(self, multiindex_dataframe_random_data):
frame = multiindex_dataframe_random_data
swapped = frame["A"].swaplevel()
swapped2 = frame["A"].swaplevel(0)
Reported by Pylint.
Line: 8
Column: 5
class TestSwaplevel:
def test_swaplevel(self, multiindex_dataframe_random_data):
frame = multiindex_dataframe_random_data
swapped = frame["A"].swaplevel()
swapped2 = frame["A"].swaplevel(0)
swapped3 = frame["A"].swaplevel(0, 1)
Reported by Pylint.
Line: 8
Column: 5
class TestSwaplevel:
def test_swaplevel(self, multiindex_dataframe_random_data):
frame = multiindex_dataframe_random_data
swapped = frame["A"].swaplevel()
swapped2 = frame["A"].swaplevel(0)
swapped3 = frame["A"].swaplevel(0, 1)
Reported by Pylint.
Line: 15
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
swapped2 = frame["A"].swaplevel(0)
swapped3 = frame["A"].swaplevel(0, 1)
swapped4 = frame["A"].swaplevel("first", "second")
assert not swapped.index.equals(frame.index)
tm.assert_series_equal(swapped, swapped2)
tm.assert_series_equal(swapped, swapped3)
tm.assert_series_equal(swapped, swapped4)
back = swapped.swaplevel()
Reported by Bandit.
Line: 24
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
back2 = swapped.swaplevel(0)
back3 = swapped.swaplevel(0, 1)
back4 = swapped.swaplevel("second", "first")
assert back.index.equals(frame.index)
tm.assert_series_equal(back, back2)
tm.assert_series_equal(back, back3)
tm.assert_series_equal(back, back4)
ft = frame.T
Reported by Bandit.
Line: 29
Column: 9
tm.assert_series_equal(back, back3)
tm.assert_series_equal(back, back4)
ft = frame.T
swapped = ft.swaplevel("first", "second", axis=1)
exp = frame.swaplevel("first", "second").T
tm.assert_frame_equal(swapped, exp)
msg = "Can only swap levels on a hierarchical axis."
Reported by Pylint.
pandas/tests/frame/test_alter_axes.py
9 issues
Line: 3
Column: 1
from datetime import datetime
import pytz
from pandas import DataFrame
import pandas._testing as tm
class TestDataFrameAlterAxes:
Reported by Pylint.
Line: 1
Column: 1
from datetime import datetime
import pytz
from pandas import DataFrame
import pandas._testing as tm
class TestDataFrameAlterAxes:
Reported by Pylint.
Line: 9
Column: 1
import pandas._testing as tm
class TestDataFrameAlterAxes:
# Tests for setting index/columns attributes directly (i.e. __setattr__)
def test_set_axis_setattr_index(self):
# GH 6785
# set the index manually
Reported by Pylint.
Line: 12
Column: 5
class TestDataFrameAlterAxes:
# Tests for setting index/columns attributes directly (i.e. __setattr__)
def test_set_axis_setattr_index(self):
# GH 6785
# set the index manually
df = DataFrame([{"ts": datetime(2014, 4, 1, tzinfo=pytz.utc), "foo": 1}])
expected = df.set_index("ts")
Reported by Pylint.
Line: 12
Column: 5
class TestDataFrameAlterAxes:
# Tests for setting index/columns attributes directly (i.e. __setattr__)
def test_set_axis_setattr_index(self):
# GH 6785
# set the index manually
df = DataFrame([{"ts": datetime(2014, 4, 1, tzinfo=pytz.utc), "foo": 1}])
expected = df.set_index("ts")
Reported by Pylint.
Line: 16
Column: 9
# GH 6785
# set the index manually
df = DataFrame([{"ts": datetime(2014, 4, 1, tzinfo=pytz.utc), "foo": 1}])
expected = df.set_index("ts")
df.index = df["ts"]
df.pop("ts")
tm.assert_frame_equal(df, expected)
Reported by Pylint.
Line: 24
Column: 5
# Renaming
def test_assign_columns(self, float_frame):
float_frame["hi"] = "there"
df = float_frame.copy()
df.columns = ["foo", "bar", "baz", "quux", "foo2"]
tm.assert_series_equal(float_frame["C"], df["baz"], check_names=False)
Reported by Pylint.
Line: 24
Column: 5
# Renaming
def test_assign_columns(self, float_frame):
float_frame["hi"] = "there"
df = float_frame.copy()
df.columns = ["foo", "bar", "baz", "quux", "foo2"]
tm.assert_series_equal(float_frame["C"], df["baz"], check_names=False)
Reported by Pylint.
Line: 27
Column: 9
def test_assign_columns(self, float_frame):
float_frame["hi"] = "there"
df = float_frame.copy()
df.columns = ["foo", "bar", "baz", "quux", "foo2"]
tm.assert_series_equal(float_frame["C"], df["baz"], check_names=False)
tm.assert_series_equal(float_frame["hi"], df["foo2"], check_names=False)
Reported by Pylint.
pandas/tests/frame/test_npfuncs.py
9 issues
Line: 13
Column: 1
import pandas._testing as tm
class TestAsArray:
def test_asarray_homogenous(self):
df = DataFrame({"A": Categorical([1, 2]), "B": Categorical([1, 2])})
result = np.asarray(df)
# may change from object in the future
expected = np.array([[1, 1], [2, 2]], dtype="object")
Reported by Pylint.
Line: 14
Column: 5
class TestAsArray:
def test_asarray_homogenous(self):
df = DataFrame({"A": Categorical([1, 2]), "B": Categorical([1, 2])})
result = np.asarray(df)
# may change from object in the future
expected = np.array([[1, 1], [2, 2]], dtype="object")
tm.assert_numpy_array_equal(result, expected)
Reported by Pylint.
Line: 14
Column: 5
class TestAsArray:
def test_asarray_homogenous(self):
df = DataFrame({"A": Categorical([1, 2]), "B": Categorical([1, 2])})
result = np.asarray(df)
# may change from object in the future
expected = np.array([[1, 1], [2, 2]], dtype="object")
tm.assert_numpy_array_equal(result, expected)
Reported by Pylint.
Line: 15
Column: 9
class TestAsArray:
def test_asarray_homogenous(self):
df = DataFrame({"A": Categorical([1, 2]), "B": Categorical([1, 2])})
result = np.asarray(df)
# may change from object in the future
expected = np.array([[1, 1], [2, 2]], dtype="object")
tm.assert_numpy_array_equal(result, expected)
Reported by Pylint.
Line: 21
Column: 5
expected = np.array([[1, 1], [2, 2]], dtype="object")
tm.assert_numpy_array_equal(result, expected)
def test_np_sqrt(self, float_frame):
with np.errstate(all="ignore"):
result = np.sqrt(float_frame)
assert isinstance(result, type(float_frame))
assert result.index is float_frame.index
assert result.columns is float_frame.columns
Reported by Pylint.
Line: 21
Column: 5
expected = np.array([[1, 1], [2, 2]], dtype="object")
tm.assert_numpy_array_equal(result, expected)
def test_np_sqrt(self, float_frame):
with np.errstate(all="ignore"):
result = np.sqrt(float_frame)
assert isinstance(result, type(float_frame))
assert result.index is float_frame.index
assert result.columns is float_frame.columns
Reported by Pylint.
Line: 24
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_np_sqrt(self, float_frame):
with np.errstate(all="ignore"):
result = np.sqrt(float_frame)
assert isinstance(result, type(float_frame))
assert result.index is float_frame.index
assert result.columns is float_frame.columns
tm.assert_frame_equal(result, float_frame.apply(np.sqrt))
Reported by Bandit.
Line: 25
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
with np.errstate(all="ignore"):
result = np.sqrt(float_frame)
assert isinstance(result, type(float_frame))
assert result.index is float_frame.index
assert result.columns is float_frame.columns
tm.assert_frame_equal(result, float_frame.apply(np.sqrt))
Reported by Bandit.
Line: 26
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
result = np.sqrt(float_frame)
assert isinstance(result, type(float_frame))
assert result.index is float_frame.index
assert result.columns is float_frame.columns
tm.assert_frame_equal(result, float_frame.apply(np.sqrt))
Reported by Bandit.
pandas/core/indexers/utils.py
9 issues
Line: 366
Column: 37
raise AssertionError("cannot find the length of the indexer")
def deprecate_ndim_indexing(result, stacklevel: int = 3):
"""
Helper function to raise the deprecation warning for multi-dimensional
indexing on 1D Series/Index.
GH#27125 indexer like idx[:, None] expands dim, but we cannot do that
Reported by Pylint.
Line: 82
Column: 66
bool
"""
# allow a list_like, but exclude NamedTuples which can be indexers
return is_list_like(key) and not (isinstance(key, tuple) and type(key) is not tuple)
def is_scalar_indexer(indexer, ndim: int) -> bool:
"""
Return True if we are all scalar indexers.
Reported by Pylint.
Line: 123
Column: 34
-------
bool
"""
if is_list_like(indexer) and not len(indexer):
return True
if arr_value.ndim == 1:
if not isinstance(indexer, tuple):
indexer = (indexer,)
return any(isinstance(idx, np.ndarray) and len(idx) == 0 for idx in indexer)
Reported by Pylint.
Line: 183
Column: 16
"cannot set using a list-like indexer "
"with a different length than the value"
)
if not len(indexer):
no_op = True
elif isinstance(indexer, slice):
if is_list_like(value):
if len(value) != length_of_indexer(indexer, values) and values.ndim == 1:
Reported by Pylint.
Line: 194
Column: 16
"cannot set using a slice indexer with a "
"different length than the value"
)
if not len(value):
no_op = True
return no_op
Reported by Pylint.
Line: 200
Column: 1
return no_op
def validate_indices(indices: np.ndarray, n: int) -> None:
"""
Perform bounds-checking for an indexer.
-1 is allowed for indicating missing values.
Reported by Pylint.
Line: 252
Column: 1
# Indexer Conversion
def maybe_convert_indices(indices, n: int, verify: bool = True):
"""
Attempt to convert indices into valid, positive indices.
If we have negative indices, translate to positive here.
If we have indices that are out-of-bounds, raise an IndexError.
Reported by Pylint.
Line: 332
Column: 5
-------
int
"""
if target is not None and isinstance(indexer, slice):
target_len = len(target)
start = indexer.start
stop = indexer.stop
step = indexer.step
if start is None:
Reported by Pylint.
Line: 536
Column: 5
...
IndexError: arrays used as indices must be of integer or boolean type
"""
from pandas.core.construction import array as pd_array
# whatever is not an array-like is returned as-is (possible valid array
# indexers that are not array-like: integer, slice, Ellipsis, None)
# In this context, tuples are not considered as array-like, as they have
# a specific meaning in indexing (multi-dimensional indexing)
Reported by Pylint.
pandas/core/computation/scope.py
9 issues
Line: 21
Column: 1
def ensure_scope(
level: int, global_dict=None, local_dict=None, resolvers=(), target=None, **kwargs
) -> Scope:
"""Ensure that we are grabbing the correct scope."""
return Scope(
level + 1,
global_dict=global_dict,
Reported by Pylint.
Line: 33
Column: 1
)
def _replacer(x) -> str:
"""
Replace a number with its hexadecimal representation. Used to tag
temporary variables with their calling scope's id.
"""
# get the hex repr of the binary char and remove 0x and pad by pad_size
Reported by Pylint.
Line: 114
Column: 5
resolvers: DeepChainMap
temps: dict
def __init__(
self, level: int, global_dict=None, local_dict=None, resolvers=(), target=None
):
self.level = level + 1
# shallow copy because we don't want to keep filling this up with what
Reported by Pylint.
Line: 204
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# if we're here that means that we have no locals and we also have
# no resolvers
assert not is_local and not self.has_resolvers
return self.scope[key]
except KeyError:
try:
# last ditch effort we look in temporaries
# these are created when parsing indexing expressions
Reported by Bandit.
Line: 214
Column: 17
return self.temps[key]
except KeyError as err:
# runtime import because ops imports from scope
from pandas.core.computation.ops import UndefinedVariableError
raise UndefinedVariableError(key, is_local) from err
def swapkey(self, old_key: str, new_key: str, new_value=None) -> None:
"""
Reported by Pylint.
Line: 259
Column: 17
variables = itertools.product(scopes, stack)
for scope, (frame, _, _, _, _, _) in variables:
try:
d = getattr(frame, "f_" + scope)
# error: Incompatible types in assignment (expression has type
# "ChainMap[str, Any]", variable has type "DeepChainMap[str, Any]")
self.scope = self.scope.new_child(d) # type: ignore[assignment]
finally:
# won't remove it, but DECREF it
Reported by Pylint.
Line: 277
Column: 9
----------
level : int
"""
sl = level + 1
# add sl frames to the scope starting with the
# most distant and overwriting with more current
# makes sure that we can capture variable scope
stack = inspect.stack()
Reported by Pylint.
Line: 306
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
name = f"{type(value).__name__}_{self.ntemps}_{_raw_hex_id(self)}"
# add to inner most scope
assert name not in self.temps
self.temps[name] = value
assert name in self.temps
# only increment if the variable gets put in the scope
return name
Reported by Bandit.
Line: 308
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# add to inner most scope
assert name not in self.temps
self.temps[name] = value
assert name in self.temps
# only increment if the variable gets put in the scope
return name
@property
Reported by Bandit.
pandas/_libs/src/parser/tokenizer.c
9 issues
Line: 409
CWE codes:
401
snprintf(self->warn_msg + ex_length, length + 1, "%s", msg);
}
}
}
static int end_line(parser_t *self) {
char *msg;
int64_t fields;
int ex_fields = self->expected_fields;
Reported by Cppcheck.
Line: 603
Column: 9
CWE codes:
134
Suggestion:
Use a constant for the format specification
self->stream_cap)) \
int64_t bufsize = 100; \
self->error_msg = malloc(bufsize); \
snprintf(self->error_msg, bufsize, \
"Buffer overflow caught - possible malformed input file.\n");\
return PARSER_OUT_OF_MEMORY; \
} \
*stream++ = c; \
slen++;
Reported by FlawFinder.
Line: 1145
Column: 13
CWE codes:
134
Suggestion:
Use a constant for the format specification
case ESCAPE_IN_QUOTED_FIELD:
case IN_QUOTED_FIELD:
self->error_msg = (char *)malloc(bufsize);
snprintf(self->error_msg, bufsize,
"EOF inside string starting at row %" PRIu64,
self->file_lines);
return -1;
case ESCAPED_CHAR:
Reported by FlawFinder.
Line: 395
Column: 22
CWE codes:
126
static void append_warning(parser_t *self, const char *msg) {
int64_t ex_length;
int64_t length = strlen(msg);
void *newptr;
if (self->warn_msg == NULL) {
self->warn_msg = malloc(length + 1);
snprintf(self->warn_msg, length + 1, "%s", msg);
Reported by FlawFinder.
Line: 402
Column: 21
CWE codes:
126
self->warn_msg = malloc(length + 1);
snprintf(self->warn_msg, length + 1, "%s", msg);
} else {
ex_length = strlen(self->warn_msg);
newptr = realloc(self->warn_msg, ex_length + length + 1);
if (newptr != NULL) {
self->warn_msg = (char *)newptr;
snprintf(self->warn_msg + ex_length, length + 1, "%s", msg);
}
Reported by FlawFinder.
Line: 1187
Column: 23
CWE codes:
126
word_deletions = self->line_start[nrows - 1] + self->line_fields[nrows - 1];
if (word_deletions >= 1) {
char_count = (self->word_starts[word_deletions - 1] +
strlen(self->words[word_deletions - 1]) + 1);
} else {
/* if word_deletions == 0 (i.e. this case) then char_count must
* be 0 too, as no data needs to be skipped */
char_count = 0;
}
Reported by FlawFinder.
Line: 1784
Column: 21
CWE codes:
126
char* _str_copy_decimal_str_c(const char *s, char **endpos, char decimal,
char tsep) {
const char *p = s;
size_t length = strlen(s);
char *s_copy = malloc(length + 1);
char *dst = s_copy;
// Copy Leading sign
if (*p == '+' || *p == '-') {
*dst++ = *p++;
Reported by FlawFinder.
Line: 1802
Column: 5
CWE codes:
120
p++;
}
// Copy the remainder of the string as is.
strncpy(dst, p, length + 1 - (p - s));
if (endpos != NULL)
*endpos = (char *)(s + length);
return s_copy;
}
Reported by FlawFinder.
Line: 1822
Column: 23
CWE codes:
126
char *endpc;
double r = PyOS_string_to_double(pc, &endpc, 0);
// PyOS_string_to_double needs to consume the whole string
if (endpc == pc + strlen(pc)) {
if (q != NULL) {
// report endptr from source string (p)
*q = endptr;
}
} else {
Reported by FlawFinder.
pandas/tests/indexes/datetimes/test_datetimelike.py
9 issues
Line: 2
Column: 1
""" generic tests from the Datetimelike class """
import pytest
from pandas import (
DatetimeIndex,
date_range,
)
import pandas._testing as tm
from pandas.tests.indexes.datetimelike import DatetimeLike
Reported by Pylint.
Line: 12
Column: 1
from pandas.tests.indexes.datetimelike import DatetimeLike
class TestDatetimeIndex(DatetimeLike):
_index_cls = DatetimeIndex
@pytest.fixture
def simple_index(self) -> DatetimeIndex:
return date_range("20130101", periods=5)
Reported by Pylint.
Line: 32
Column: 5
expected = [f"{x:%Y-%m-%d}" for x in idx]
assert idx.format() == expected
def test_shift(self):
pass # handled in test_ops
def test_intersection(self):
pass # handled in test_setops
Reported by Pylint.
Line: 12
Column: 1
from pandas.tests.indexes.datetimelike import DatetimeLike
class TestDatetimeIndex(DatetimeLike):
_index_cls = DatetimeIndex
@pytest.fixture
def simple_index(self) -> DatetimeIndex:
return date_range("20130101", periods=5)
Reported by Pylint.
Line: 22
Column: 5
@pytest.fixture(
params=[tm.makeDateIndex(10), date_range("20130110", periods=10, freq="-1D")],
ids=["index_inc", "index_dec"],
)
def index(self, request):
return request.param
def test_format(self, simple_index):
# GH35439
Reported by Pylint.
Line: 22
Column: 5
@pytest.fixture(
params=[tm.makeDateIndex(10), date_range("20130110", periods=10, freq="-1D")],
ids=["index_inc", "index_dec"],
)
def index(self, request):
return request.param
def test_format(self, simple_index):
# GH35439
Reported by Pylint.
Line: 30
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# GH35439
idx = simple_index
expected = [f"{x:%Y-%m-%d}" for x in idx]
assert idx.format() == expected
def test_shift(self):
pass # handled in test_ops
def test_intersection(self):
Reported by Bandit.
Line: 35
Column: 5
def test_shift(self):
pass # handled in test_ops
def test_intersection(self):
pass # handled in test_setops
def test_union(self):
pass # handled in test_setops
Reported by Pylint.
Line: 38
Column: 5
def test_intersection(self):
pass # handled in test_setops
def test_union(self):
pass # handled in test_setops
Reported by Pylint.
doc/sphinxext/contributors.py
9 issues
Line: 18
Column: 1
branch as the end of the revision range.
"""
from announce import build_components
from docutils import nodes
from docutils.parsers.rst import Directive
import git
class ContributorsDirective(Directive):
Reported by Pylint.
Line: 19
Column: 1
"""
from announce import build_components
from docutils import nodes
from docutils.parsers.rst import Directive
import git
class ContributorsDirective(Directive):
required_arguments = 1
Reported by Pylint.
Line: 18
Column: 1
branch as the end of the revision range.
"""
from announce import build_components
from docutils import nodes
from docutils.parsers.rst import Directive
import git
class ContributorsDirective(Directive):
Reported by Pylint.
Line: 19
Column: 1
"""
from announce import build_components
from docutils import nodes
from docutils.parsers.rst import Directive
import git
class ContributorsDirective(Directive):
required_arguments = 1
Reported by Pylint.
Line: 20
Column: 1
from announce import build_components
from docutils import nodes
from docutils.parsers.rst import Directive
import git
class ContributorsDirective(Directive):
required_arguments = 1
name = "contributors"
Reported by Pylint.
Line: 23
Column: 1
import git
class ContributorsDirective(Directive):
required_arguments = 1
name = "contributors"
def run(self):
range_ = self.arguments[0]
Reported by Pylint.
Line: 23
Column: 1
import git
class ContributorsDirective(Directive):
required_arguments = 1
name = "contributors"
def run(self):
range_ = self.arguments[0]
Reported by Pylint.
Line: 27
Column: 5
required_arguments = 1
name = "contributors"
def run(self):
range_ = self.arguments[0]
if range_.endswith("x..HEAD"):
return [nodes.paragraph(), nodes.bullet_list()]
try:
components = build_components(range_)
Reported by Pylint.
Line: 54
Column: 1
return [message, listnode]
def setup(app):
app.add_directive("contributors", ContributorsDirective)
return {"version": "0.1", "parallel_read_safe": True, "parallel_write_safe": True}
Reported by Pylint.