Skip to content

STYLE: fix pylint reimported warnings #49645

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 2 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 0 additions & 2 deletions pandas/_testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,6 @@ def makeCustomIndex(
for i in range(nlevels):

def keyfunc(x):
import re

numeric_tuple = re.sub(r"[^\d_]_?", "", x).split("_")
return [int(num) for num in numeric_tuple]

Expand Down
1 change: 0 additions & 1 deletion pandas/_testing/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def set_timezone(tz: str) -> Generator[None, None, None]:
...
'EST'
"""
import os
import time

def setTZ(tz) -> None:
Expand Down
2 changes: 0 additions & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9045,8 +9045,6 @@ def compare(
keep_equal: bool_t = False,
result_names: Suffixes = ("self", "other"),
):
from pandas.core.reshape.concat import concat

if type(self) is not type(other):
cls_self, cls_other = type(self).__name__, type(other).__name__
raise TypeError(
Expand Down
1 change: 0 additions & 1 deletion pandas/io/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,6 @@ def pandasSQL_builder(con, schema: str | None = None) -> SQLDatabase | SQLiteDat
provided parameters.
"""
import sqlite3
import warnings

if isinstance(con, sqlite3.Connection) or con is None:
return SQLiteDatabase(con)
Expand Down
2 changes: 0 additions & 2 deletions pandas/plotting/_matplotlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1655,8 +1655,6 @@ def _start_base(self):
return self.bottom

def _make_plot(self) -> None:
import matplotlib as mpl

colors = self._get_colors()
ncolors = len(colors)

Expand Down
2 changes: 0 additions & 2 deletions pandas/tests/groupby/test_grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,6 @@ def test_groupby_grouper(self, df):

def test_groupby_dict_mapping(self):
# GH #679
from pandas import Series

s = Series({"T1": 5})
result = s.groupby({"T1": "T2"}).agg(sum)
expected = s.groupby(["T2"]).agg(sum)
Expand Down
6 changes: 1 addition & 5 deletions pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,11 +953,7 @@ def test_loc_coercion(self):

def test_loc_coercion2(self):
# GH#12045
import datetime

df = DataFrame(
{"date": [datetime.datetime(2012, 1, 1), datetime.datetime(1012, 1, 2)]}
)
df = DataFrame({"date": [datetime(2012, 1, 1), datetime(1012, 1, 2)]})
expected = df.dtypes

result = df.iloc[[0]]
Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/io/excel/test_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,10 +882,7 @@ def test_read_from_file_url(self, read_ext, datapath):
tm.assert_frame_equal(url_table, local_table)

def test_read_from_pathlib_path(self, read_ext):

# GH12655
from pathlib import Path

str_path = "test1" + read_ext
expected = pd.read_excel(str_path, sheet_name="Sheet1", index_col=0)

Expand Down
17 changes: 4 additions & 13 deletions pandas/tests/io/formats/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from datetime import (
datetime,
time,
timedelta,
)
from io import StringIO
import itertools
Expand Down Expand Up @@ -994,12 +995,10 @@ def test_truncate_with_different_dtypes(self):
# when truncated the dtypes of the splits can differ

# 11594
import datetime

s = Series(
[datetime.datetime(2012, 1, 1)] * 10
+ [datetime.datetime(1012, 1, 2)]
+ [datetime.datetime(2012, 1, 3)] * 10
[datetime(2012, 1, 1)] * 10
+ [datetime(1012, 1, 2)]
+ [datetime(2012, 1, 3)] * 10
)

with option_context("display.max_rows", 8):
Expand Down Expand Up @@ -1250,8 +1249,6 @@ def test_long_series(self):
dtype="int64",
)

import re

str_rep = str(s)
nmatches = len(re.findall("dtype", str_rep))
assert nmatches == 1
Expand Down Expand Up @@ -2445,12 +2442,6 @@ def test_datetimeindex_highprecision(self, start_date):
assert start_date in result

def test_timedelta64(self):

from datetime import (
datetime,
timedelta,
)

Series(np.array([1100, 20], dtype="timedelta64[ns]")).to_string()

s = Series(date_range("2012-1-1", periods=3, freq="D"))
Expand Down
2 changes: 0 additions & 2 deletions pandas/tests/io/json/test_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,6 @@ def test_with_large_max_level(self):

def test_deprecated_import(self):
with tm.assert_produces_warning(FutureWarning):
from pandas.io.json import json_normalize

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

Expand Down
2 changes: 0 additions & 2 deletions pandas/tests/reductions/test_reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,8 +890,6 @@ def test_idxmax(self):
allna = string_series * np.nan
assert isna(allna.idxmax())

from pandas import date_range

s = Series(date_range("20130102", periods=6))
result = s.idxmax()
assert result == 5
Expand Down
2 changes: 0 additions & 2 deletions pandas/tests/reshape/concat/test_datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

class TestDatetimeConcat:
def test_concat_datetime64_block(self):
from pandas.core.indexes.datetimes import date_range

rng = date_range("1/1/2000", periods=10)

df = DataFrame({"time": rng})
Expand Down
6 changes: 0 additions & 6 deletions pandas/tests/series/accessors/test_dt_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,12 +632,6 @@ def test_strftime_all_nat(self, data):
tm.assert_series_equal(result, expected)

def test_valid_dt_with_missing_values(self):

from datetime import (
date,
time,
)

# GH 8689
ser = Series(date_range("20130101", periods=5, freq="D"))
ser.iloc[2] = pd.NaT
Expand Down
2 changes: 0 additions & 2 deletions pandas/tests/tseries/offsets/test_custom_business_month.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,6 @@ def test_holidays(self):

@pytest.mark.filterwarnings("ignore:Non:pandas.errors.PerformanceWarning")
def test_datetimeindex(self):
from pandas.tseries.holiday import USFederalHolidayCalendar

hcal = USFederalHolidayCalendar()
freq = CBMonthEnd(calendar=hcal)

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ disable = [
"raise-missing-from",
"redefined-builtin",
"redefined-outer-name",
"reimported",
"self-assigning-variable",
"self-cls-assignment",
"signature-differs",
Expand Down