File tree 5 files changed +18
-24
lines changed
5 files changed +18
-24
lines changed Original file line number Diff line number Diff line change @@ -208,39 +208,22 @@ repos:
208
208
language : pygrep
209
209
entry : |
210
210
(?x)
211
- # pytest.xfail instead of pytest.mark.xfail
212
- pytest\.xfail
213
-
214
211
# imports from pandas._testing instead of `import pandas._testing as tm`
215
- | from\ pandas\._testing\ import
212
+ from\ pandas\._testing\ import
216
213
|from\ pandas\ import\ _testing\ as\ tm
217
214
218
- # No direct imports from conftest
219
- |conftest\ import
220
- |import\ conftest
221
-
222
215
# pandas.testing instead of tm
223
216
|pd\.testing\.
224
217
225
218
# pd.api.types instead of from pandas.api.types import ...
226
219
|(pd|pandas)\.api\.types\.
227
220
228
- # np.testing, np.array_equal
229
- |(numpy|np)(\.testing|\.array_equal)
230
-
231
- # unittest.mock (use pytest builtin monkeypatch fixture instead)
232
- |(unittest(\.| import )mock|mock\.Mock\(\)|mock\.patch)
221
+ # np.array_equal
222
+ |(numpy|np)\.array_equal
233
223
234
224
# pytest raises without context
235
225
|\s\ pytest.raises
236
226
237
- # TODO
238
- # pytest.warns (use tm.assert_produces_warning instead)
239
- # |pytest\.warns
240
-
241
- # os.remove
242
- |os\.remove
243
-
244
227
# Unseeded numpy default_rng
245
228
|default_rng\(\)
246
229
files : ^pandas/tests/
Original file line number Diff line number Diff line change @@ -233,7 +233,7 @@ def html(self):
233
233
ret_code = self ._sphinx_build ("html" )
234
234
zip_fname = os .path .join (BUILD_PATH , "html" , "pandas.zip" )
235
235
if os .path .exists (zip_fname ):
236
- os .remove (zip_fname )
236
+ os .remove (zip_fname ) # noqa: TID251
237
237
238
238
if ret_code == 0 :
239
239
if self .single_doc_html is not None :
@@ -285,7 +285,7 @@ def zip_html(self) -> None:
285
285
"""
286
286
zip_fname = os .path .join (BUILD_PATH , "html" , "pandas.zip" )
287
287
if os .path .exists (zip_fname ):
288
- os .remove (zip_fname )
288
+ os .remove (zip_fname ) # noqa: TID251
289
289
dirname = os .path .join (BUILD_PATH , "html" )
290
290
fnames = os .listdir (dirname )
291
291
os .chdir (dirname )
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ def test_series_setitem(indexer):
18
18
19
19
# using custom check instead of tm.assert_produces_warning because that doesn't
20
20
# fail if multiple warnings are raised
21
- with pytest .warns () as record :
21
+ with pytest .warns () as record : # noqa: TID251
22
22
df ["a" ][indexer ] = 0
23
23
assert len (record ) == 1
24
24
assert record [0 ].category == ChainedAssignmentError
Original file line number Diff line number Diff line change @@ -331,6 +331,17 @@ exclude = [
331
331
332
332
[tool .ruff .lint .flake8-tidy-imports .banned-api ]
333
333
"urllib.request.urlopen".msg = " Use pandas.io.common.urlopen instead of urllib.request.urlopen"
334
+ # numpy.random is banned but np.random is not. Is this intentional?
335
+ # "numpy.random".msg = "Do not use numpy.random"
336
+ "pytest.warns".msg = " Use tm.assert_produces_warning instead of pytest.warns"
337
+ "pytest.xfail".msg = " Use pytest.mark.xfail instead of pytest.xfail"
338
+ "conftest".msg = " No direct imports from conftest"
339
+ "numpy.testing".msg = " Do not use numpy.testing"
340
+ # "numpy.array_equal".msg = "Do not use numpy.array_equal" # Used in pandas/core
341
+ "unittest.mock".msg = " use pytest builtin monkeypatch fixture instead"
342
+ "os.remove".msg = " Do not use os.remove"
343
+
344
+
334
345
335
346
[tool .ruff .per-file-ignores ]
336
347
# relative imports allowed for asv_bench
Original file line number Diff line number Diff line change 1
- from unittest .mock import (
1
+ from unittest .mock import ( # noqa: TID251
2
2
mock_open ,
3
3
patch ,
4
4
)
You can’t perform that action at this time.
0 commit comments