Skip to content

Commit 9a52a81

Browse files
authored
STYLE use absolute imports (#39561)
1 parent 3bb83b0 commit 9a52a81

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+100
-106
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,8 @@ repos:
195195
rev: v0.1.7
196196
hooks:
197197
- id: no-string-hints
198+
- repo: https://github.com/MarcoGorelli/abs-imports
199+
rev: v0.1.2
200+
hooks:
201+
- id: abs-imports
202+
files: ^pandas/

pandas/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
import pandas.arrays
181181

182182
# use the closest tagged version if possible
183-
from ._version import get_versions
183+
from pandas._version import get_versions
184184

185185
v = get_versions()
186186
__version__ = v.get("closest-tag", v["version"])

pandas/_libs/tslibs/__init__.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,28 @@
2727
"tz_compare",
2828
]
2929

30-
from . import dtypes
31-
from .conversion import OutOfBoundsTimedelta, localize_pydatetime
32-
from .dtypes import Resolution
33-
from .nattype import NaT, NaTType, iNaT, is_null_datetimelike, nat_strings
34-
from .np_datetime import OutOfBoundsDatetime
35-
from .offsets import BaseOffset, Tick, to_offset
36-
from .period import IncompatibleFrequency, Period
37-
from .timedeltas import Timedelta, delta_to_nanoseconds, ints_to_pytimedelta
38-
from .timestamps import Timestamp
39-
from .timezones import tz_compare
40-
from .tzconversion import tz_convert_from_utc_single
41-
from .vectorized import (
30+
from pandas._libs.tslibs import dtypes
31+
from pandas._libs.tslibs.conversion import OutOfBoundsTimedelta, localize_pydatetime
32+
from pandas._libs.tslibs.dtypes import Resolution
33+
from pandas._libs.tslibs.nattype import (
34+
NaT,
35+
NaTType,
36+
iNaT,
37+
is_null_datetimelike,
38+
nat_strings,
39+
)
40+
from pandas._libs.tslibs.np_datetime import OutOfBoundsDatetime
41+
from pandas._libs.tslibs.offsets import BaseOffset, Tick, to_offset
42+
from pandas._libs.tslibs.period import IncompatibleFrequency, Period
43+
from pandas._libs.tslibs.timedeltas import (
44+
Timedelta,
45+
delta_to_nanoseconds,
46+
ints_to_pytimedelta,
47+
)
48+
from pandas._libs.tslibs.timestamps import Timestamp
49+
from pandas._libs.tslibs.timezones import tz_compare
50+
from pandas._libs.tslibs.tzconversion import tz_convert_from_utc_single
51+
from pandas._libs.tslibs.vectorized import (
4252
dt64arr_to_periodarr,
4353
get_resolution,
4454
ints_to_pydatetime,

pandas/core/arrays/boolean.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
from pandas.core.dtypes.missing import isna
2424

2525
from pandas.core import ops
26-
27-
from .masked import BaseMaskedArray, BaseMaskedDtype
26+
from pandas.core.arrays.masked import BaseMaskedArray, BaseMaskedDtype
2827

2928
if TYPE_CHECKING:
3029
import pyarrow

pandas/core/arrays/floating.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
from pandas.core.dtypes.dtypes import ExtensionDtype, register_extension_dtype
2424
from pandas.core.dtypes.missing import isna
2525

26+
from pandas.core.arrays.numeric import NumericArray, NumericDtype
2627
from pandas.core.ops import invalid_comparison
2728
from pandas.core.tools.numeric import to_numeric
2829

29-
from .numeric import NumericArray, NumericDtype
30-
3130

3231
class FloatingDtype(NumericDtype):
3332
"""

pandas/core/arrays/integer.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@
2323
)
2424
from pandas.core.dtypes.missing import isna
2525

26+
from pandas.core.arrays.masked import BaseMaskedArray, BaseMaskedDtype
27+
from pandas.core.arrays.numeric import NumericArray, NumericDtype
2628
from pandas.core.ops import invalid_comparison
2729
from pandas.core.tools.numeric import to_numeric
2830

29-
from .masked import BaseMaskedArray, BaseMaskedDtype
30-
from .numeric import NumericArray, NumericDtype
31-
3231

3332
class _IntegerDtype(NumericDtype):
3433
"""

pandas/core/arrays/numeric.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
)
1919

2020
from pandas.core import ops
21-
22-
from .masked import BaseMaskedArray, BaseMaskedDtype
21+
from pandas.core.arrays.masked import BaseMaskedArray, BaseMaskedDtype
2322

2423
if TYPE_CHECKING:
2524
import pyarrow

pandas/core/arrays/timedeltas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def _add_period(self, other: Period):
419419
Add a Period object.
420420
"""
421421
# We will wrap in a PeriodArray and defer to the reversed operation
422-
from .period import PeriodArray
422+
from pandas.core.arrays.period import PeriodArray
423423

424424
i8vals = np.broadcast_to(other.ordinal, self.shape)
425425
oth = PeriodArray(i8vals, freq=other.freq)

pandas/core/strings/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# - PandasArray
2727
# - Categorical
2828

29-
from .accessor import StringMethods
30-
from .base import BaseStringArrayMethods
29+
from pandas.core.strings.accessor import StringMethods
30+
from pandas.core.strings.base import BaseStringArrayMethods
3131

3232
__all__ = ["StringMethods", "BaseStringArrayMethods"]

pandas/tests/api/test_types.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pandas._testing as tm
22
from pandas.api import types
3-
4-
from .test_api import Base
3+
from pandas.tests.api.test_api import Base
54

65

76
class TestTypes(Base):

0 commit comments

Comments
 (0)