Skip to content

Commit a747171

Browse files
author
MarcoGorelli
committed
fixups
1 parent 1a056df commit a747171

29 files changed

+57
-310
lines changed

.pre-commit-config.yaml

+8-16
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,10 @@ repos:
181181
types: [rst]
182182
args: [--filename=*.rst]
183183
additional_dependencies: [flake8-rst==0.7.0, flake8==3.7.9]
184-
- id: frame-or-series-union
185-
name: Check for use of Union[Series, DataFrame] instead of FrameOrSeriesUnion alias
186-
entry: Union\[.*(Series,.*DataFrame|DataFrame,.*Series).*\]
187-
language: pygrep
188-
types: [python]
189-
exclude: ^pandas/_typing\.py$
190184
- id: inconsistent-namespace-usage
191185
name: 'Check for inconsistent use of pandas namespace'
192186
entry: python scripts/check_for_inconsistent_pandas_namespace.py
187+
exclude: ^pandas/core/interchange/
193188
language: python
194189
types: [python]
195190
- id: no-os-remove
@@ -200,9 +195,7 @@ repos:
200195
files: ^pandas/tests/
201196
exclude: |
202197
(?x)^
203-
pandas/tests/io/excel/test_writers\.py
204-
|pandas/tests/io/pytables/common\.py
205-
|pandas/tests/io/pytables/test_store\.py$
198+
pandas/tests/io/pytables/test_store\.py$
206199
- id: unwanted-patterns
207200
name: Unwanted patterns
208201
language: pygrep
@@ -216,12 +209,8 @@ repos:
216209
|\.__class__
217210
218211
# np.bool/np.object instead of np.bool_/np.object_
219-
|np\.bool[^_8]
220-
|np\.object[^_8]
221-
222-
# imports from pandas.core.common instead of `import pandas.core.common as com`
223-
|from\ pandas\.core\.common\ import
224-
|from\ pandas\.core\ import\ common
212+
|np\.bool[^_8`]
213+
|np\.object[^_8`]
225214
226215
# imports from collections.abc instead of `from collections import abc`
227216
|from\ collections\.abc\ import
@@ -331,7 +320,10 @@ repos:
331320
language: python
332321
entry: python scripts/validate_unwanted_patterns.py --validation-type="private_import_across_module"
333322
types: [python]
334-
exclude: ^(asv_bench|pandas/tests|doc)/
323+
exclude: |
324+
(?x)
325+
^(asv_bench|pandas/tests|doc)/
326+
|scripts/validate_min_versions_in_sync\.py$
335327
- id: unwanted-patterns-strings-to-concatenate
336328
name: Check for use of not concatenated strings
337329
language: python

doc/scripts/eval_performance.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
from pandas import DataFrame
77

88
setup_common = """from pandas import DataFrame
9-
from numpy.random import randn
10-
df = DataFrame(randn(%d, 3), columns=list('abc'))
9+
df = DataFrame(np.random.randn(%d, 3), columns=list('abc'))
1110
%s"""
1211

1312
setup_with = "s = 'a + b * (c ** 2 + b ** 2 - a) / (a * c) ** 3'"

doc/source/development/code_style.rst

-218
This file was deleted.

doc/source/development/contributing_codebase.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Pre-commit
4343
----------
4444

4545
Additionally, :ref:`Continuous Integration <contributing.ci>` will run code formatting checks
46-
like ``black``, ``flake8`` (including a `pandas-dev-flaker <https://github.com/pandas-dev/pandas-dev-flaker>`_ plugin),
46+
like ``black``, ``flake8``,
4747
``isort``, and ``cpplint`` and more using `pre-commit hooks <https://pre-commit.com/>`_
4848
Any warnings from these checks will cause the :ref:`Continuous Integration <contributing.ci>` to fail; therefore,
4949
it is helpful to run the check yourself before submitting code. This

doc/source/whatsnew/v1.4.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ Null-values are no longer coerced to NaN-value in value_counts and mode
320320
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
321321

322322
:meth:`Series.value_counts` and :meth:`Series.mode` no longer coerce ``None``,
323-
``NaT`` and other null-values to a NaN-value for ``np.object``-dtype. This
323+
``NaT`` and other null-values to a NaN-value for ``np.object_``-dtype. This
324324
behavior is now consistent with ``unique``, ``isin`` and others
325325
(:issue:`42688`).
326326

pandas/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
)
136136

137137
from pandas import api, arrays, errors, io, plotting, tseries
138-
from pandas import testing # noqa:PDF015
138+
from pandas import testing
139139
from pandas.util._print_versions import show_versions
140140

141141
from pandas.io.api import (

pandas/_libs/lib.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,7 @@ def infer_dtype(value: object, skipna: bool = True) -> str:
14821482
return val
14831483

14841484
if values.descr.type_num != NPY_OBJECT:
1485-
# i.e. values.dtype != np.object
1485+
# i.e. values.dtype != np.object_
14861486
# This should not be reached
14871487
values = values.astype(object)
14881488

pandas/compat/__init__.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
import sys
1515

1616
from pandas._typing import F
17-
import pandas.compat._compressors
17+
from pandas.compat._compressors import (
18+
LZMAFile,
19+
has_lzma,
20+
)
1821
from pandas.compat._constants import (
1922
IS64,
2023
PY39,
@@ -131,7 +134,7 @@ def is_ci_environment() -> bool:
131134
return os.environ.get("PANDAS_CI", "0") == "1"
132135

133136

134-
def get_lzma_file() -> type[pandas.compat._compressors.LZMAFile]:
137+
def get_lzma_file() -> type[LZMAFile]:
135138
"""
136139
Importing the `LZMAFile` class from the `lzma` module.
137140
@@ -145,13 +148,13 @@ def get_lzma_file() -> type[pandas.compat._compressors.LZMAFile]:
145148
RuntimeError
146149
If the `lzma` module was not imported correctly, or didn't exist.
147150
"""
148-
if not pandas.compat._compressors.has_lzma:
151+
if not has_lzma:
149152
raise RuntimeError(
150153
"lzma module not available. "
151154
"A Python re-install with the proper dependencies, "
152155
"might be required to solve this issue."
153156
)
154-
return pandas.compat._compressors.LZMAFile
157+
return LZMAFile
155158

156159

157160
__all__ = [

pandas/core/arrays/string_arrow.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from collections.abc import Callable # noqa: PDF001
3+
from collections import abc
44
import re
55
from typing import Union
66

@@ -302,7 +302,7 @@ def _str_endswith(self, pat: str, na=None):
302302
def _str_replace(
303303
self,
304304
pat: str | re.Pattern,
305-
repl: str | Callable,
305+
repl: str | abc.Callable,
306306
n: int = -1,
307307
case: bool = True,
308308
flags: int = 0,

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@
133133
from pandas.core import (
134134
algorithms as algos,
135135
arraylike,
136+
common,
136137
indexing,
137138
nanops,
138139
sample,
139140
)
140-
from pandas.core import common # noqa: PDF018
141141
from pandas.core.array_algos.replace import should_use_regex
142142
from pandas.core.arrays import ExtensionArray
143143
from pandas.core.base import PandasObject

0 commit comments

Comments
 (0)