Skip to content

Commit 289f32d

Browse files
authored
STYLE: fix pylint reimported warnings (#49645)
* STYLE: fix pylint reimported warnings * fixup! STYLE: fix pylint reimported warnings
1 parent 9dbb7d7 commit 289f32d

File tree

15 files changed

+6
-45
lines changed

15 files changed

+6
-45
lines changed

pandas/_testing/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,6 @@ def makeCustomIndex(
610610
for i in range(nlevels):
611611

612612
def keyfunc(x):
613-
import re
614-
615613
numeric_tuple = re.sub(r"[^\d_]_?", "", x).split("_")
616614
return [int(num) for num in numeric_tuple]
617615

pandas/_testing/contexts.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def set_timezone(tz: str) -> Generator[None, None, None]:
6262
...
6363
'EST'
6464
"""
65-
import os
6665
import time
6766

6867
def setTZ(tz) -> None:

pandas/core/generic.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9018,8 +9018,6 @@ def compare(
90189018
keep_equal: bool_t = False,
90199019
result_names: Suffixes = ("self", "other"),
90209020
):
9021-
from pandas.core.reshape.concat import concat
9022-
90239021
if type(self) is not type(other):
90249022
cls_self, cls_other = type(self).__name__, type(other).__name__
90259023
raise TypeError(

pandas/io/sql.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,6 @@ def pandasSQL_builder(con, schema: str | None = None) -> SQLDatabase | SQLiteDat
741741
provided parameters.
742742
"""
743743
import sqlite3
744-
import warnings
745744

746745
if isinstance(con, sqlite3.Connection) or con is None:
747746
return SQLiteDatabase(con)

pandas/plotting/_matplotlib/core.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,8 +1655,6 @@ def _start_base(self):
16551655
return self.bottom
16561656

16571657
def _make_plot(self) -> None:
1658-
import matplotlib as mpl
1659-
16601658
colors = self._get_colors()
16611659
ncolors = len(colors)
16621660

pandas/tests/groupby/test_grouping.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,6 @@ def test_groupby_grouper(self, df):
393393

394394
def test_groupby_dict_mapping(self):
395395
# GH #679
396-
from pandas import Series
397-
398396
s = Series({"T1": 5})
399397
result = s.groupby({"T1": "T2"}).agg(sum)
400398
expected = s.groupby(["T2"]).agg(sum)

pandas/tests/indexing/test_loc.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -953,11 +953,7 @@ def test_loc_coercion(self):
953953

954954
def test_loc_coercion2(self):
955955
# GH#12045
956-
import datetime
957-
958-
df = DataFrame(
959-
{"date": [datetime.datetime(2012, 1, 1), datetime.datetime(1012, 1, 2)]}
960-
)
956+
df = DataFrame({"date": [datetime(2012, 1, 1), datetime(1012, 1, 2)]})
961957
expected = df.dtypes
962958

963959
result = df.iloc[[0]]

pandas/tests/io/excel/test_readers.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,10 +882,7 @@ def test_read_from_file_url(self, read_ext, datapath):
882882
tm.assert_frame_equal(url_table, local_table)
883883

884884
def test_read_from_pathlib_path(self, read_ext):
885-
886885
# GH12655
887-
from pathlib import Path
888-
889886
str_path = "test1" + read_ext
890887
expected = pd.read_excel(str_path, sheet_name="Sheet1", index_col=0)
891888

pandas/tests/io/formats/test_format.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from datetime import (
66
datetime,
77
time,
8+
timedelta,
89
)
910
from io import StringIO
1011
import itertools
@@ -994,12 +995,10 @@ def test_truncate_with_different_dtypes(self):
994995
# when truncated the dtypes of the splits can differ
995996

996997
# 11594
997-
import datetime
998-
999998
s = Series(
1000-
[datetime.datetime(2012, 1, 1)] * 10
1001-
+ [datetime.datetime(1012, 1, 2)]
1002-
+ [datetime.datetime(2012, 1, 3)] * 10
999+
[datetime(2012, 1, 1)] * 10
1000+
+ [datetime(1012, 1, 2)]
1001+
+ [datetime(2012, 1, 3)] * 10
10031002
)
10041003

10051004
with option_context("display.max_rows", 8):
@@ -1250,8 +1249,6 @@ def test_long_series(self):
12501249
dtype="int64",
12511250
)
12521251

1253-
import re
1254-
12551252
str_rep = str(s)
12561253
nmatches = len(re.findall("dtype", str_rep))
12571254
assert nmatches == 1
@@ -2445,12 +2442,6 @@ def test_datetimeindex_highprecision(self, start_date):
24452442
assert start_date in result
24462443

24472444
def test_timedelta64(self):
2448-
2449-
from datetime import (
2450-
datetime,
2451-
timedelta,
2452-
)
2453-
24542445
Series(np.array([1100, 20], dtype="timedelta64[ns]")).to_string()
24552446

24562447
s = Series(date_range("2012-1-1", periods=3, freq="D"))

pandas/tests/io/json/test_normalize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ def test_with_large_max_level(self):
866866

867867
def test_deprecated_import(self):
868868
with tm.assert_produces_warning(FutureWarning):
869-
from pandas.io.json import json_normalize
869+
from pandas.io.json import json_normalize # pylint: disable=reimported
870870

871871
recs = [{"a": 1, "b": 2, "c": 3}, {"a": 4, "b": 5, "c": 6}]
872872
json_normalize(recs)

pandas/tests/reductions/test_reductions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,8 +866,6 @@ def test_idxmax(self):
866866
allna = string_series * np.nan
867867
assert isna(allna.idxmax())
868868

869-
from pandas import date_range
870-
871869
s = Series(date_range("20130102", periods=6))
872870
result = s.idxmax()
873871
assert result == 5

pandas/tests/reshape/concat/test_datetimes.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
class TestDatetimeConcat:
2424
def test_concat_datetime64_block(self):
25-
from pandas.core.indexes.datetimes import date_range
26-
2725
rng = date_range("1/1/2000", periods=10)
2826

2927
df = DataFrame({"time": rng})

pandas/tests/series/accessors/test_dt_accessor.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -632,12 +632,6 @@ def test_strftime_all_nat(self, data):
632632
tm.assert_series_equal(result, expected)
633633

634634
def test_valid_dt_with_missing_values(self):
635-
636-
from datetime import (
637-
date,
638-
time,
639-
)
640-
641635
# GH 8689
642636
ser = Series(date_range("20130101", periods=5, freq="D"))
643637
ser.iloc[2] = pd.NaT

pandas/tests/tseries/offsets/test_custom_business_month.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,6 @@ def test_holidays(self):
400400

401401
@pytest.mark.filterwarnings("ignore:Non:pandas.errors.PerformanceWarning")
402402
def test_datetimeindex(self):
403-
from pandas.tseries.holiday import USFederalHolidayCalendar
404-
405403
hcal = USFederalHolidayCalendar()
406404
freq = CBMonthEnd(calendar=hcal)
407405

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ disable = [
153153
"raise-missing-from",
154154
"redefined-builtin",
155155
"redefined-outer-name",
156-
"reimported",
157156
"self-assigning-variable",
158157
"self-cls-assignment",
159158
"signature-differs",

0 commit comments

Comments
 (0)