Skip to content

Commit 02627df

Browse files
committed
Translate more banned import config to ruff
1 parent 17aa2ba commit 02627df

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

doc/make.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def html(self):
233233
ret_code = self._sphinx_build("html")
234234
zip_fname = os.path.join(BUILD_PATH, "html", "pandas.zip")
235235
if os.path.exists(zip_fname):
236-
os.remove(zip_fname)
236+
os.remove(zip_fname) # noqa: TID251
237237

238238
if ret_code == 0:
239239
if self.single_doc_html is not None:
@@ -285,7 +285,7 @@ def zip_html(self) -> None:
285285
"""
286286
zip_fname = os.path.join(BUILD_PATH, "html", "pandas.zip")
287287
if os.path.exists(zip_fname):
288-
os.remove(zip_fname)
288+
os.remove(zip_fname) # noqa: TID251
289289
dirname = os.path.join(BUILD_PATH, "html")
290290
fnames = os.listdir(dirname)
291291
os.chdir(dirname)

pandas/tests/copy_view/test_chained_assignment_deprecation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_series_setitem(indexer, using_copy_on_write):
3737

3838
# using custom check instead of tm.assert_produces_warning because that doesn't
3939
# fail if multiple warnings are raised
40-
with pytest.warns() as record:
40+
with pytest.warns() as record: # noqa: TID251
4141
df["a"][indexer] = 0
4242
assert len(record) == 1
4343
if using_copy_on_write:

pyproject.toml

+11
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,17 @@ exclude = [
332332

333333
[tool.ruff.lint.flake8-tidy-imports.banned-api]
334334
"urllib.request.urlopen".msg = "Use pandas.io.common.urlopen instead of urllib.request.urlopen"
335+
# numpy.random is banned but np.random is not. Is this intentional?
336+
# "numpy.random".msg = "Do not use numpy.random"
337+
"pytest.warns".msg = "Use tm.assert_produces_warning instead of pytest.warns"
338+
"pytest.xfail".msg = "Use pytest.mark.xfail instead of pytest.xfail"
339+
"conftest".msg = "No direct imports from conftest"
340+
"numpy.testing".msg = "Do not use numpy.testing"
341+
# "numpy.array_equal".msg = "Do not use numpy.array_equal" # Used in pandas/core
342+
"unittest.mock".msg = "use pytest builtin monkeypatch fixture instead"
343+
"os.remove".msg = "Do not use os.remove"
344+
345+
335346

336347
[tool.ruff.per-file-ignores]
337348
# relative imports allowed for asv_bench

web/tests/test_pandas_web.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from unittest.mock import (
1+
from unittest.mock import ( # noqa: TID251
22
mock_open,
33
patch,
44
)

0 commit comments

Comments
 (0)