Skip to content

CLN: tighten noqas #44529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/user_guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3023,6 +3023,7 @@ Read in the content of the "books.xml" as instance of ``StringIO`` or
Even read XML from AWS S3 buckets such as Python Software Foundation's IRS 990 Form:

.. ipython:: python
:okwarning:

df = pd.read_xml(
"s3://irs-form-990/201923199349319487_public.xml",
Expand Down
2 changes: 1 addition & 1 deletion pandas/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
""" public toolkit API """
from pandas.api import ( # noqa
from pandas.api import ( # noqa:F401
extensions,
indexers,
types,
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1849,5 +1849,5 @@ def union_with_duplicates(lvals: ArrayLike, rvals: ArrayLike) -> ArrayLike:
unique_array = ensure_wrapped_if_datetimelike(unique_array)

for i, value in enumerate(unique_array):
indexer += [i] * int(max(l_count[value], r_count[value]))
indexer += [i] * int(max(l_count.at[value], r_count.at[value]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as in the other PR: what's the reason for this change? It shouldn't influence behaviour, but just being more explicit about label-based?

return unique_array.take(indexer)
4 changes: 1 addition & 3 deletions pandas/core/arrays/floating.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ def coerce_to_array(
if mask.any():
values = values.copy()
values[mask] = np.nan
values = values.astype(dtype, copy=False) # , casting="safe")
else:
values = values.astype(dtype, copy=False) # , casting="safe")
values = values.astype(dtype, copy=False) # , casting="safe")

return values, mask

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/arrays/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ def coerce_to_array(
else:
assert len(mask) == len(values)

if not values.ndim == 1:
if values.ndim != 1:
raise TypeError("values must be a 1D list-like")
if not mask.ndim == 1:
if mask.ndim != 1:
raise TypeError("mask must be a 1D list-like")

# infer dtype if needed
Expand Down
1 change: 0 additions & 1 deletion pandas/core/dtypes/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ def _isna(obj, inf_as_na: bool = False):
return libmissing.checknull_old(obj)
else:
return libmissing.checknull(obj)
# hack (for now) because MI registers as ndarray
elif isinstance(obj, ABCMultiIndex):
raise NotImplementedError("isna is not defined for MultiIndex")
elif isinstance(obj, type):
Expand Down
6 changes: 4 additions & 2 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def _slice(self, slicer) -> ArrayLike:
return self.values[slicer]

@final
def getitem_block(self, slicer) -> Block:
def getitem_block(self, slicer: slice | npt.NDArray[np.intp]) -> Block:
"""
Perform __getitem__-like, return result as block.

Expand All @@ -326,7 +326,9 @@ def getitem_block(self, slicer) -> Block:
return type(self)(new_values, new_mgr_locs, self.ndim)

@final
def getitem_block_columns(self, slicer, new_mgr_locs: BlockPlacement) -> Block:
def getitem_block_columns(
self, slicer: slice, new_mgr_locs: BlockPlacement
) -> Block:
"""
Perform __getitem__-like, return result as block.

Expand Down
3 changes: 2 additions & 1 deletion pandas/core/reshape/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ def _bins_to_cuts(
)
elif ordered and len(set(labels)) != len(labels):
raise ValueError(
"labels must be unique if ordered=True; pass ordered=False for duplicate labels" # noqa
"labels must be unique if ordered=True; pass ordered=False "
"for duplicate labels"
)
else:
if len(labels) != len(bins) - 1:
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/sas/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from pandas.io.sas.sasreader import read_sas # noqa
from pandas.io.sas.sasreader import read_sas # noqa:F401
12 changes: 6 additions & 6 deletions pandas/tests/arrays/boolean/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def test_ufuncs_unary(ufunc):
expected[a._mask] = np.nan
tm.assert_extension_array_equal(result, expected)

s = pd.Series(a)
result = ufunc(s)
ser = pd.Series(a)
result = ufunc(ser)
expected = pd.Series(ufunc(a._data), dtype="boolean")
expected[a._mask] = np.nan
tm.assert_series_equal(result, expected)
Expand All @@ -86,8 +86,8 @@ def test_value_counts_na():


def test_value_counts_with_normalize():
s = pd.Series([True, False, pd.NA], dtype="boolean")
result = s.value_counts(normalize=True)
ser = pd.Series([True, False, pd.NA], dtype="boolean")
result = ser.value_counts(normalize=True)
expected = pd.Series([1, 1], index=[True, False], dtype="Float64") / 2
tm.assert_series_equal(result, expected)

Expand All @@ -102,7 +102,7 @@ def test_diff():
)
tm.assert_extension_array_equal(result, expected)

s = pd.Series(a)
result = s.diff()
ser = pd.Series(a)
result = ser.diff()
expected = pd.Series(expected)
tm.assert_series_equal(result, expected)
4 changes: 1 addition & 3 deletions pandas/tests/arrays/categorical/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,7 @@ def test_constructor(self):

# this is a legitimate constructor
with tm.assert_produces_warning(None):
c = Categorical( # noqa
np.array([], dtype="int64"), categories=[3, 2, 1], ordered=True
)
Categorical(np.array([], dtype="int64"), categories=[3, 2, 1], ordered=True)

def test_constructor_with_existing_categories(self):
# GH25318: constructing with pd.Series used to bogusly skip recoding
Expand Down
Loading