diff --git a/.github/workflows/code-checks.yml b/.github/workflows/code-checks.yml index 728019b06e053..4aa49f23b724b 100644 --- a/.github/workflows/code-checks.yml +++ b/.github/workflows/code-checks.yml @@ -177,7 +177,7 @@ jobs: id: setup_python uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: '3.11' cache: 'pip' cache-dependency-path: 'requirements-dev.txt' diff --git a/.github/workflows/package-checks.yml b/.github/workflows/package-checks.yml index 9800cc1694313..23570d916688b 100644 --- a/.github/workflows/package-checks.yml +++ b/.github/workflows/package-checks.yml @@ -42,7 +42,7 @@ jobs: id: setup_python uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: '3.11' - name: Pip install with extra run: | @@ -51,14 +51,10 @@ jobs: conda_forge_recipe: if: ${{ github.event.label.name == 'Build' || contains(github.event.pull_request.labels.*.name, 'Build') || github.event_name == 'push'}} runs-on: ubuntu-24.04 - strategy: - matrix: - python-version: ['3.10', '3.11'] - fail-fast: false - name: Test Conda Forge Recipe - Python ${{ matrix.python-version }} + name: Test Conda Forge Recipe concurrency: # https://github.community/t/concurrecy-not-work-for-push/183068/7 - group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-conda-forge-recipe-${{ matrix.python-version }} + group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-conda-forge-recipe cancel-in-progress: true steps: - name: Checkout @@ -71,7 +67,7 @@ jobs: with: environment-name: recipe-test create-args: >- - python=${{ matrix.python-version }} + python=3.11 boa conda-verify cache-downloads: true diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 7bee8474d4db5..46490fa324009 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -27,18 +27,18 @@ jobs: strategy: matrix: platform: [ubuntu-24.04, ubuntu-24.04-arm] - env_file: [actions-310.yaml, actions-311.yaml, actions-312.yaml, actions-313.yaml] + env_file: [actions-311.yaml, actions-312.yaml, actions-313.yaml] # Prevent the include jobs from overriding other jobs pattern: [""] pandas_future_infer_string: ["1"] include: - name: "Downstream Compat" - env_file: actions-311-downstream_compat.yaml + env_file: actions-313-downstream_compat.yaml pattern: "not slow and not network and not single_cpu" pytest_target: "pandas/tests/test_downstream.py" platform: ubuntu-24.04 - name: "Minimum Versions" - env_file: actions-310-minimum_versions.yaml + env_file: actions-311-minimum_versions.yaml pattern: "not slow and not network and not single_cpu" platform: ubuntu-24.04 - name: "Freethreading" @@ -50,7 +50,7 @@ jobs: pattern: "not slow and not network and not single_cpu" platform: ubuntu-24.04 - name: "Locale: it_IT" - env_file: actions-311.yaml + env_file: actions-313.yaml pattern: "not slow and not network and not single_cpu" extra_apt: "language-pack-it" # Use the utf8 version as the default, it has no bad side-effect. @@ -61,7 +61,7 @@ jobs: extra_loc: "it_IT" platform: ubuntu-24.04 - name: "Locale: zh_CN" - env_file: actions-311.yaml + env_file: actions-313.yaml pattern: "not slow and not network and not single_cpu" extra_apt: "language-pack-zh-hans" # Use the utf8 version as the default, it has no bad side-effect. @@ -72,16 +72,16 @@ jobs: extra_loc: "zh_CN" platform: ubuntu-24.04 - name: "PANDAS_FUTURE_INFER_STRING=0" - env_file: actions-312.yaml + env_file: actions-313.yaml pandas_future_infer_string: "0" platform: ubuntu-24.04 - name: "Numpy Dev" - env_file: actions-311-numpydev.yaml + env_file: actions-313-numpydev.yaml pattern: "not slow and not network and not single_cpu" test_args: "-W error::DeprecationWarning -W error::FutureWarning" platform: ubuntu-24.04 - name: "Pyarrow Nightly" - env_file: actions-311-pyarrownightly.yaml + env_file: actions-313-pyarrownightly.yaml pattern: "not slow and not network and not single_cpu" platform: ubuntu-24.04 fail-fast: false @@ -183,7 +183,7 @@ jobs: matrix: # Note: Don't use macOS latest since macos 14 appears to be arm64 only os: [macos-13, macos-14, windows-latest] - env_file: [actions-310.yaml, actions-311.yaml, actions-312.yaml, actions-313.yaml] + env_file: [actions-311.yaml, actions-312.yaml, actions-313.yaml] fail-fast: false runs-on: ${{ matrix.os }} name: ${{ format('{0} {1}', matrix.os, matrix.env_file) }} diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 6fe0a5f40d77e..7f0b3d0289c31 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -101,7 +101,7 @@ jobs: - [macos-14, macosx_arm64] - [windows-2022, win_amd64] - [windows-11-arm, win_arm64] - python: [["cp310", "3.10"], ["cp311", "3.11"], ["cp312", "3.12"], ["cp313", "3.13"], ["cp313t", "3.13"]] + python: [["cp311", "3.11"], ["cp312", "3.12"], ["cp313", "3.13"], ["cp313t", "3.13"]] include: # Build Pyodide wheels and upload them to Anaconda.org # NOTE: this job is similar to the one in unit-tests.yml except for the fact @@ -110,8 +110,6 @@ jobs: python: ["cp312", "3.12"] cibw_build_frontend: 'build' exclude: - - buildplat: [windows-11-arm, win_arm64] - python: ["cp310", "3.10"] # BackendUnavailable: Cannot import 'mesonpy' - buildplat: [windows-11-arm, win_arm64] python: ["cp313t", "3.13"] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e2b0e5c0bd10d..51be4c3f77973 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,7 +45,6 @@ repos: hooks: - id: codespell types_or: [python, rst, markdown, cython, c] - additional_dependencies: [tomli] - repo: https://github.com/MarcoGorelli/cython-lint rev: v0.16.7 hooks: @@ -77,7 +76,7 @@ repos: rev: v3.20.0 hooks: - id: pyupgrade - args: [--py310-plus] + args: [--py311-plus] - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.10.0 hooks: @@ -235,7 +234,7 @@ repos: entry: python scripts/generate_pip_deps_from_conda.py files: ^(environment.yml|requirements-dev.txt)$ pass_filenames: false - additional_dependencies: [tomli, pyyaml] + additional_dependencies: [pyyaml] - id: title-capitalization name: Validate correct capitalization among titles in documentation entry: python scripts/validate_rst_title_capitalization.py @@ -290,7 +289,7 @@ repos: entry: python -m scripts.validate_min_versions_in_sync language: python files: ^(ci/deps/actions-.*-minimum_versions\.yaml|pandas/compat/_optional\.py)$ - additional_dependencies: [tomli, pyyaml] + additional_dependencies: [pyyaml] pass_filenames: false - id: validate-errors-locations name: Validate errors locations diff --git a/asv_bench/asv.conf.json b/asv_bench/asv.conf.json index d286e57ce6b51..1a288e399a699 100644 --- a/asv_bench/asv.conf.json +++ b/asv_bench/asv.conf.json @@ -29,7 +29,7 @@ // The Pythons you'd like to test against. If not provided, defaults // to the current version of Python used to run `asv`. - "pythons": ["3.10"], + "pythons": ["3.11"], // The matrix of dependencies to test. Each key is the name of a // package (in PyPI) and the values are version numbers. An empty diff --git a/ci/deps/actions-310.yaml b/ci/deps/actions-310.yaml deleted file mode 100644 index 83386f07b631c..0000000000000 --- a/ci/deps/actions-310.yaml +++ /dev/null @@ -1,63 +0,0 @@ -name: pandas-dev -channels: - - conda-forge -dependencies: - - python=3.10 - - # build dependencies - - versioneer - - cython<4.0.0a0 - - meson=1.2.1 - - meson-python=0.13.1 - - # test dependencies - - pytest>=7.3.2 - - pytest-cov - - pytest-xdist>=3.4.0 - - pytest-localserver>=0.8.1 - - pytest-qt>=4.4.0 - - boto3=1.37.3 - - # required dependencies - - python-dateutil - - numpy - - # optional dependencies - - beautifulsoup4>=4.12.3 - - bottleneck>=1.3.6 - - fastparquet>=2024.2.0 - - fsspec>=2023.12.2 - - html5lib>=1.1 - - hypothesis>=6.84.0 - - gcsfs>=2023.12.2 - - jinja2>=3.1.3 - - lxml>=4.9.2 - - matplotlib>=3.8.3 - - numba>=0.59.0 - - numexpr>=2.9.0 - - odfpy>=1.4.1 - - qtpy>=2.3.0 - - openpyxl>=3.1.2 - - psycopg2>=2.9.6 - - pyarrow>=12.0.1 - - pyiceberg>=0.7.1 - - pymysql>=1.1.0 - - pyqt>=5.15.9 - - pyreadstat>=1.2.6 - - pytables>=3.8.0 - - python-calamine>=0.1.7 - - pytz>=2023.4 - - pyxlsb>=1.0.10 - - s3fs>=2023.12.2 - - scipy>=1.12.0 - - sqlalchemy>=2.0.0 - - tabulate>=0.9.0 - - xarray>=2024.1.1 - - xlrd>=2.0.1 - - xlsxwriter>=3.2.0 - - zstandard>=0.22.0 - - - pip: - - adbc-driver-postgresql>=0.10.0 - - adbc-driver-sqlite>=0.8.0 - - tzdata>=2023.3 diff --git a/ci/deps/actions-310-minimum_versions.yaml b/ci/deps/actions-311-minimum_versions.yaml similarity index 98% rename from ci/deps/actions-310-minimum_versions.yaml rename to ci/deps/actions-311-minimum_versions.yaml index ee2d083ffc56f..f9dc5d2367344 100644 --- a/ci/deps/actions-310-minimum_versions.yaml +++ b/ci/deps/actions-311-minimum_versions.yaml @@ -4,7 +4,7 @@ name: pandas-dev channels: - conda-forge dependencies: - - python=3.10 + - python=3.11 # build dependencies - versioneer diff --git a/ci/deps/actions-311-downstream_compat.yaml b/ci/deps/actions-313-downstream_compat.yaml similarity index 98% rename from ci/deps/actions-311-downstream_compat.yaml rename to ci/deps/actions-313-downstream_compat.yaml index 0cce1dc8ff79d..c118bbcdf1697 100644 --- a/ci/deps/actions-311-downstream_compat.yaml +++ b/ci/deps/actions-313-downstream_compat.yaml @@ -3,7 +3,7 @@ name: pandas-dev channels: - conda-forge dependencies: - - python=3.11 + - python=3.13 # build dependencies - versioneer diff --git a/ci/deps/actions-311-numpydev.yaml b/ci/deps/actions-313-numpydev.yaml similarity index 96% rename from ci/deps/actions-311-numpydev.yaml rename to ci/deps/actions-313-numpydev.yaml index f8a84441ddb3b..a1474d70c9487 100644 --- a/ci/deps/actions-311-numpydev.yaml +++ b/ci/deps/actions-313-numpydev.yaml @@ -2,7 +2,7 @@ name: pandas-dev channels: - conda-forge dependencies: - - python=3.11 + - python=3.13 # build dependencies - versioneer diff --git a/ci/deps/actions-311-pyarrownightly.yaml b/ci/deps/actions-313-pyarrownightly.yaml similarity index 96% rename from ci/deps/actions-311-pyarrownightly.yaml rename to ci/deps/actions-313-pyarrownightly.yaml index 5c74c243f0f6c..e56813cffb901 100644 --- a/ci/deps/actions-311-pyarrownightly.yaml +++ b/ci/deps/actions-313-pyarrownightly.yaml @@ -2,7 +2,7 @@ name: pandas-dev channels: - conda-forge dependencies: - - python=3.11 + - python=3.13 # build dependencies - versioneer diff --git a/ci/meta.yaml b/ci/meta.yaml index 853c3093fa5bc..da6b2b08e26ac 100644 --- a/ci/meta.yaml +++ b/ci/meta.yaml @@ -31,7 +31,6 @@ requirements: - numpy >=1.21.6 # [py<311] - numpy >=1.23.2 # [py>=311] - versioneer - - tomli # [py<311] run: - python - numpy >=1.21.6 # [py<311] @@ -66,7 +65,6 @@ test: - pytest-xdist >=3.4.0 - pytest-cov - hypothesis >=6.84.0 - - tomli # [py<311] about: home: http://pandas.pydata.org diff --git a/doc/source/development/contributing_environment.rst b/doc/source/development/contributing_environment.rst index d7b779debcd5e..c09e8595f0241 100644 --- a/doc/source/development/contributing_environment.rst +++ b/doc/source/development/contributing_environment.rst @@ -133,7 +133,7 @@ Consult the docs for setting up pyenv `here `__. pyenv virtualenv # For instance: - pyenv virtualenv 3.10 pandas-dev + pyenv virtualenv 3.11 pandas-dev # Activate the virtualenv pyenv activate pandas-dev diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index e9996dcf8bc6a..834477f2aa46a 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -305,7 +305,7 @@ This change also applies to :meth:`.DataFrameGroupBy.value_counts`. Here, there Increased minimum version for Python ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -pandas 3.0.0 supports Python 3.10 and higher. +pandas 3.0.0 supports Python 3.11 and higher. Increased minimum versions for dependencies ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/environment.yml b/environment.yml index 2a566773b884a..1c7ebd0cea1ff 100644 --- a/environment.yml +++ b/environment.yml @@ -122,5 +122,4 @@ dependencies: - pip: - adbc-driver-postgresql>=0.10.0 - adbc-driver-sqlite>=0.8.0 - - typing_extensions; python_version<"3.11" - tzdata>=2023.3 diff --git a/pandas/_libs/arrays.pyi b/pandas/_libs/arrays.pyi index 60e4ff3fab74e..7b373240952ca 100644 --- a/pandas/_libs/arrays.pyi +++ b/pandas/_libs/arrays.pyi @@ -1,11 +1,11 @@ from collections.abc import Sequence +from typing import Self import numpy as np from pandas._typing import ( AxisInt, DtypeObj, - Self, Shape, ) diff --git a/pandas/_libs/include/pandas/vendored/klib/khash_python.h b/pandas/_libs/include/pandas/vendored/klib/khash_python.h index 04e2d1e39ce2a..e0bb96d57b9e1 100644 --- a/pandas/_libs/include/pandas/vendored/klib/khash_python.h +++ b/pandas/_libs/include/pandas/vendored/klib/khash_python.h @@ -222,15 +222,11 @@ static inline int pyobject_cmp(PyObject *a, PyObject *b) { } static inline Py_hash_t _Pandas_HashDouble(double val) { - // Since Python3.10, nan is no longer has hash 0 + // nan no longer has hash 0 if (isnan(val)) { return 0; } -#if PY_VERSION_HEX < 0x030A0000 - return _Py_HashDouble(val); -#else return _Py_HashDouble(NULL, val); -#endif } static inline Py_hash_t floatobject_hash(PyFloatObject *key) { diff --git a/pandas/_libs/internals.pyi b/pandas/_libs/internals.pyi index a680304d55ea2..11d059ec53920 100644 --- a/pandas/_libs/internals.pyi +++ b/pandas/_libs/internals.pyi @@ -3,6 +3,7 @@ from collections.abc import ( Sequence, ) from typing import ( + Self, final, overload, ) @@ -12,7 +13,6 @@ import numpy as np from pandas._typing import ( ArrayLike, - Self, npt, ) diff --git a/pandas/_libs/lib.pyi b/pandas/_libs/lib.pyi index 310cd3c3d76ec..e50b301c34868 100644 --- a/pandas/_libs/lib.pyi +++ b/pandas/_libs/lib.pyi @@ -11,6 +11,7 @@ from typing import ( Final, Literal, TypeAlias, + TypeGuard, overload, ) @@ -19,7 +20,6 @@ import numpy as np from pandas._typing import ( ArrayLike, DtypeObj, - TypeGuard, npt, ) diff --git a/pandas/_libs/sparse.pyi b/pandas/_libs/sparse.pyi index 8727b1a5b0420..7ba82f3bc1268 100644 --- a/pandas/_libs/sparse.pyi +++ b/pandas/_libs/sparse.pyi @@ -1,11 +1,9 @@ from collections.abc import Sequence +from typing import Self import numpy as np -from pandas._typing import ( - Self, - npt, -) +from pandas._typing import npt class SparseIndex: length: int diff --git a/pandas/_libs/tslibs/dtypes.pyi b/pandas/_libs/tslibs/dtypes.pyi index b435b9e2d8b31..1a87e753b2061 100644 --- a/pandas/_libs/tslibs/dtypes.pyi +++ b/pandas/_libs/tslibs/dtypes.pyi @@ -1,6 +1,5 @@ from enum import Enum - -from pandas._typing import Self +from typing import Self OFFSET_TO_PERIOD_FREQSTR: dict[str, str] diff --git a/pandas/_libs/tslibs/nattype.pyi b/pandas/_libs/tslibs/nattype.pyi index ff3bb5b70801e..ab236dafe1450 100644 --- a/pandas/_libs/tslibs/nattype.pyi +++ b/pandas/_libs/tslibs/nattype.pyi @@ -6,6 +6,7 @@ from datetime import ( from typing import ( Literal, NoReturn, + Self, TypeAlias, overload, ) @@ -15,7 +16,6 @@ import numpy as np from pandas._libs.tslibs.period import Period from pandas._typing import ( Frequency, - Self, TimestampNonexistent, ) diff --git a/pandas/_libs/tslibs/offsets.pyi b/pandas/_libs/tslibs/offsets.pyi index a71aa42b4f671..ce7426f8164be 100644 --- a/pandas/_libs/tslibs/offsets.pyi +++ b/pandas/_libs/tslibs/offsets.pyi @@ -7,6 +7,7 @@ from datetime import ( from typing import ( Any, Literal, + Self, TypeVar, overload, ) @@ -16,7 +17,6 @@ import numpy as np from pandas._libs.tslibs.nattype import NaTType from pandas._typing import ( OffsetCalendar, - Self, npt, ) diff --git a/pandas/_libs/tslibs/timedeltas.pyi b/pandas/_libs/tslibs/timedeltas.pyi index c885543b2fc6d..2200f9ebbbbb5 100644 --- a/pandas/_libs/tslibs/timedeltas.pyi +++ b/pandas/_libs/tslibs/timedeltas.pyi @@ -2,6 +2,7 @@ from datetime import timedelta from typing import ( ClassVar, Literal, + Self, TypeAlias, overload, ) @@ -14,7 +15,6 @@ from pandas._libs.tslibs import ( ) from pandas._typing import ( Frequency, - Self, npt, ) diff --git a/pandas/_libs/tslibs/timestamps.pyi b/pandas/_libs/tslibs/timestamps.pyi index c769b09d1b7a1..3195ce9641f2b 100644 --- a/pandas/_libs/tslibs/timestamps.pyi +++ b/pandas/_libs/tslibs/timestamps.pyi @@ -9,6 +9,7 @@ from time import struct_time from typing import ( ClassVar, Literal, + Self, TypeAlias, overload, ) @@ -22,10 +23,7 @@ from pandas._libs.tslibs import ( Tick, Timedelta, ) -from pandas._typing import ( - Self, - TimestampNonexistent, -) +from pandas._typing import TimestampNonexistent _TimeZones: TypeAlias = str | _tzinfo | None | int diff --git a/pandas/_testing/_warnings.py b/pandas/_testing/_warnings.py index a752c8db90f38..6ed8a7b9154d4 100644 --- a/pandas/_testing/_warnings.py +++ b/pandas/_testing/_warnings.py @@ -16,8 +16,6 @@ ) import warnings -from pandas.compat import PY311 - if TYPE_CHECKING: from collections.abc import ( Generator, @@ -216,7 +214,7 @@ def _assert_caught_no_extra_warnings( # due to these open files. if any("matplotlib" in mod for mod in sys.modules): continue - if PY311 and actual_warning.category == EncodingWarning: + if actual_warning.category == EncodingWarning: # EncodingWarnings are checked in the CI # pyproject.toml errors on EncodingWarnings in pandas # Ignore EncodingWarnings from other libraries diff --git a/pandas/_typing.py b/pandas/_typing.py index 889252bb00438..0a6653f05e59a 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -16,12 +16,13 @@ tzinfo, ) from os import PathLike -import sys from typing import ( TYPE_CHECKING, Any, Literal, + ParamSpec, Protocol, + SupportsIndex, TypeAlias, TypeVar, Union, @@ -85,28 +86,8 @@ # Name "npt._ArrayLikeInt_co" is not defined [name-defined] NumpySorter: TypeAlias = npt._ArrayLikeInt_co | None # type: ignore[name-defined] - from typing import ( - ParamSpec, - SupportsIndex, - ) - from typing import Concatenate # pyright: ignore[reportUnusedImport] - from typing import TypeGuard # pyright: ignore[reportUnusedImport] - - P = ParamSpec("P") - - if sys.version_info >= (3, 11): - from typing import Self # pyright: ignore[reportUnusedImport] - from typing import Unpack # pyright: ignore[reportUnusedImport] - else: - from typing_extensions import Self # pyright: ignore[reportUnusedImport] - from typing_extensions import Unpack # pyright: ignore[reportUnusedImport] - -else: - ParamSpec: Any = None - Self: Any = None - TypeGuard: Any = None - Concatenate: Any = None - Unpack: Any = None + +P = ParamSpec("P") HashableT = TypeVar("HashableT", bound=Hashable) HashableT2 = TypeVar("HashableT2", bound=Hashable) diff --git a/pandas/compat/__init__.py b/pandas/compat/__init__.py index d5dbcb74d29e4..7e91ed8863f55 100644 --- a/pandas/compat/__init__.py +++ b/pandas/compat/__init__.py @@ -18,7 +18,6 @@ from pandas.compat._constants import ( IS64, ISMUSL, - PY311, PY312, PYPY, WASM, @@ -155,7 +154,6 @@ def is_ci_environment() -> bool: "HAS_PYARROW", "IS64", "ISMUSL", - "PY311", "PY312", "PYPY", "WASM", diff --git a/pandas/compat/_constants.py b/pandas/compat/_constants.py index c7b7341013251..adba59bb542df 100644 --- a/pandas/compat/_constants.py +++ b/pandas/compat/_constants.py @@ -13,17 +13,15 @@ IS64 = sys.maxsize > 2**32 -PY311 = sys.version_info >= (3, 11) PY312 = sys.version_info >= (3, 12) PYPY = platform.python_implementation() == "PyPy" WASM = (sys.platform == "emscripten") or (platform.machine() in ["wasm32", "wasm64"]) ISMUSL = "musl" in (sysconfig.get_config_var("HOST_GNU_TYPE") or "") -REF_COUNT = 2 if PY311 else 3 +REF_COUNT = 2 __all__ = [ "IS64", "ISMUSL", - "PY311", "PY312", "PYPY", "WASM", diff --git a/pandas/compat/_optional.py b/pandas/compat/_optional.py index 7e882bc242394..9133a79986ae4 100644 --- a/pandas/compat/_optional.py +++ b/pandas/compat/_optional.py @@ -16,7 +16,7 @@ if TYPE_CHECKING: import types -# Update install.rst, actions-310-minimum_versions.yaml, +# Update install.rst, actions-311-minimum_versions.yaml, # deps_minimum.toml & pyproject.toml when updating versions! VERSIONS = { diff --git a/pandas/core/_numba/extensions.py b/pandas/core/_numba/extensions.py index 413fdafc7fd04..7b98cfe639322 100644 --- a/pandas/core/_numba/extensions.py +++ b/pandas/core/_numba/extensions.py @@ -12,7 +12,7 @@ from contextlib import contextmanager import operator -from typing import TYPE_CHECKING +from typing import Self import numba from numba import types @@ -41,9 +41,6 @@ from pandas.core.internals import SingleBlockManager from pandas.core.series import Series -if TYPE_CHECKING: - from pandas._typing import Self - # Helper function to hack around fact that Index casts numpy string dtype to object # diff --git a/pandas/core/arrays/_arrow_string_mixins.py b/pandas/core/arrays/_arrow_string_mixins.py index 07cbf489cfe1c..502dd8a1541f0 100644 --- a/pandas/core/arrays/_arrow_string_mixins.py +++ b/pandas/core/arrays/_arrow_string_mixins.py @@ -6,6 +6,7 @@ TYPE_CHECKING, Any, Literal, + Self, ) import numpy as np @@ -24,10 +25,7 @@ if TYPE_CHECKING: from collections.abc import Callable - from pandas._typing import ( - Scalar, - Self, - ) + from pandas._typing import Scalar class ArrowStringArrayMixin: diff --git a/pandas/core/arrays/_mixins.py b/pandas/core/arrays/_mixins.py index 26585e7bab8e3..c4ad941970bd4 100644 --- a/pandas/core/arrays/_mixins.py +++ b/pandas/core/arrays/_mixins.py @@ -5,6 +5,7 @@ TYPE_CHECKING, Any, Literal, + Self, cast, overload, ) @@ -23,7 +24,6 @@ PositionalIndexer2D, PositionalIndexerTuple, ScalarIndexer, - Self, SequenceIndexer, Shape, TakeIndexer, diff --git a/pandas/core/arrays/arrow/array.py b/pandas/core/arrays/arrow/array.py index ad1d576bfec32..60dc7ea2a1e96 100644 --- a/pandas/core/arrays/arrow/array.py +++ b/pandas/core/arrays/arrow/array.py @@ -8,6 +8,7 @@ TYPE_CHECKING, Any, Literal, + Self, cast, overload, ) @@ -196,7 +197,6 @@ def floordiv_compat( NumpyValueArrayLike, PositionalIndexer, Scalar, - Self, SortKind, TakeIndexer, TimeAmbiguous, diff --git a/pandas/core/arrays/base.py b/pandas/core/arrays/base.py index bfa2309bb023a..90fb8c175ebf6 100644 --- a/pandas/core/arrays/base.py +++ b/pandas/core/arrays/base.py @@ -15,6 +15,7 @@ Any, ClassVar, Literal, + Self, cast, overload, ) @@ -95,7 +96,6 @@ NumpyValueArrayLike, PositionalIndexer, ScalarIndexer, - Self, SequenceIndexer, Shape, SortKind, diff --git a/pandas/core/arrays/boolean.py b/pandas/core/arrays/boolean.py index dc236d82543cc..a5109ab17af70 100644 --- a/pandas/core/arrays/boolean.py +++ b/pandas/core/arrays/boolean.py @@ -4,6 +4,7 @@ from typing import ( TYPE_CHECKING, ClassVar, + Self, cast, ) @@ -30,7 +31,6 @@ from pandas._typing import ( DtypeObj, - Self, npt, type_t, ) diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index f2a401bd3687a..86e5f93609d1c 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -7,6 +7,7 @@ from typing import ( TYPE_CHECKING, Literal, + Self, cast, overload, ) @@ -105,7 +106,6 @@ DtypeObj, NpDtype, Ordered, - Self, Shape, SortKind, npt, diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index d5e654c95577e..6582d9585fbfa 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -10,6 +10,7 @@ TYPE_CHECKING, Any, Literal, + Self, TypeAlias, Union, cast, @@ -65,7 +66,6 @@ PositionalIndexer2D, PositionalIndexerTuple, ScalarIndexer, - Self, SequenceIndexer, TakeIndexer, TimeAmbiguous, diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 57c138d9828bd..3f4f16b4ef0cd 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -7,6 +7,7 @@ ) from typing import ( TYPE_CHECKING, + Self, TypeVar, cast, overload, @@ -84,7 +85,6 @@ DateTimeErrorChoices, DtypeObj, IntervalClosedType, - Self, TimeAmbiguous, TimeNonexistent, npt, diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index 4bcbe2eedee47..09706f4e53d60 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -9,6 +9,7 @@ from typing import ( TYPE_CHECKING, Literal, + Self, TypeAlias, overload, ) @@ -31,7 +32,6 @@ NpDtype, PositionalIndexer, ScalarIndexer, - Self, SequenceIndexer, SortKind, TimeArrayLike, diff --git a/pandas/core/arrays/masked.py b/pandas/core/arrays/masked.py index 9c5965951da68..0f619df14ee0c 100644 --- a/pandas/core/arrays/masked.py +++ b/pandas/core/arrays/masked.py @@ -4,6 +4,7 @@ TYPE_CHECKING, Any, Literal, + Self, cast, overload, ) @@ -94,7 +95,6 @@ PositionalIndexer, Scalar, ScalarIndexer, - Self, SequenceIndexer, Shape, npt, diff --git a/pandas/core/arrays/numeric.py b/pandas/core/arrays/numeric.py index 59279d24231e0..324e2fc3bf108 100644 --- a/pandas/core/arrays/numeric.py +++ b/pandas/core/arrays/numeric.py @@ -4,6 +4,7 @@ from typing import ( TYPE_CHECKING, Any, + Self, ) import numpy as np @@ -36,7 +37,6 @@ from pandas._typing import ( DtypeObj, - Self, npt, ) diff --git a/pandas/core/arrays/numpy_.py b/pandas/core/arrays/numpy_.py index fd2c8c9d63362..73e509474b6e4 100644 --- a/pandas/core/arrays/numpy_.py +++ b/pandas/core/arrays/numpy_.py @@ -4,6 +4,7 @@ TYPE_CHECKING, Any, Literal, + Self, ) import numpy as np @@ -39,7 +40,6 @@ InterpolateOptions, NpDtype, Scalar, - Self, npt, ) diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index ae92e17332c76..626e28edd0e9c 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -6,6 +6,7 @@ TYPE_CHECKING, Any, Literal, + Self, TypeVar, cast, overload, @@ -86,7 +87,6 @@ NpDtype, NumpySorter, NumpyValueArrayLike, - Self, npt, ) diff --git a/pandas/core/arrays/sparse/array.py b/pandas/core/arrays/sparse/array.py index 137dbb6e4d139..384a264ca690e 100644 --- a/pandas/core/arrays/sparse/array.py +++ b/pandas/core/arrays/sparse/array.py @@ -11,6 +11,7 @@ TYPE_CHECKING, Any, Literal, + Self, cast, overload, ) @@ -113,7 +114,6 @@ class ellipsis(Enum): PositionalIndexer, Scalar, ScalarIndexer, - Self, SequenceIndexer, npt, ) diff --git a/pandas/core/arrays/string_.py b/pandas/core/arrays/string_.py index c124c5ed3845b..983e7b246032c 100644 --- a/pandas/core/arrays/string_.py +++ b/pandas/core/arrays/string_.py @@ -6,6 +6,7 @@ TYPE_CHECKING, Any, Literal, + Self, cast, ) import warnings @@ -85,7 +86,6 @@ NumpySorter, NumpyValueArrayLike, Scalar, - Self, npt, type_t, ) diff --git a/pandas/core/arrays/string_arrow.py b/pandas/core/arrays/string_arrow.py index 2ca12870709f0..af446eb0da04a 100644 --- a/pandas/core/arrays/string_arrow.py +++ b/pandas/core/arrays/string_arrow.py @@ -4,6 +4,7 @@ import re from typing import ( TYPE_CHECKING, + Self, ) import warnings @@ -54,7 +55,6 @@ ArrayLike, Dtype, NpDtype, - Self, npt, ) diff --git a/pandas/core/arrays/timedeltas.py b/pandas/core/arrays/timedeltas.py index 9012b9f36348a..52e799702cc3e 100644 --- a/pandas/core/arrays/timedeltas.py +++ b/pandas/core/arrays/timedeltas.py @@ -4,6 +4,7 @@ import operator from typing import ( TYPE_CHECKING, + Self, cast, ) @@ -69,7 +70,6 @@ DateTimeErrorChoices, DtypeObj, NpDtype, - Self, npt, ) diff --git a/pandas/core/base.py b/pandas/core/base.py index 2e2bf487562a8..7c00d3925685f 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -10,6 +10,7 @@ Any, Generic, Literal, + Self, cast, final, overload, @@ -23,7 +24,6 @@ DtypeObj, IndexLabel, NDFrameT, - Self, Shape, npt, ) diff --git a/pandas/core/common.py b/pandas/core/common.py index e166d0e7628db..c25d910b73100 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -25,6 +25,7 @@ from typing import ( TYPE_CHECKING, Any, + Concatenate, TypeVar, cast, overload, @@ -51,7 +52,6 @@ from pandas._typing import ( AnyArrayLike, ArrayLike, - Concatenate, NpDtype, P, RandomState, diff --git a/pandas/core/computation/pytables.py b/pandas/core/computation/pytables.py index 77b7d9ad11a6c..d176beb6cde00 100644 --- a/pandas/core/computation/pytables.py +++ b/pandas/core/computation/pytables.py @@ -12,6 +12,7 @@ TYPE_CHECKING, Any, ClassVar, + Self, ) import numpy as np @@ -42,10 +43,7 @@ ) if TYPE_CHECKING: - from pandas._typing import ( - Self, - npt, - ) + from pandas._typing import npt class PyTablesScope(_scope.Scope): diff --git a/pandas/core/dtypes/base.py b/pandas/core/dtypes/base.py index b53fc84328eca..ae48ad153e2d6 100644 --- a/pandas/core/dtypes/base.py +++ b/pandas/core/dtypes/base.py @@ -7,6 +7,7 @@ from typing import ( TYPE_CHECKING, Any, + Self, TypeVar, cast, overload, @@ -28,7 +29,6 @@ if TYPE_CHECKING: from pandas._typing import ( DtypeObj, - Self, Shape, npt, type_t, @@ -146,7 +146,7 @@ def __eq__(self, other: object) -> bool: return False def __hash__(self) -> int: - # for python>=3.10, different nan objects have different hashes + # different nan objects have different hashes # we need to avoid that and thus use hash function with old behavior return object_hash(tuple(getattr(self, attr) for attr in self._metadata)) diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index be71414b06207..eb5c7739e5132 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -15,6 +15,7 @@ from typing import ( TYPE_CHECKING, Any, + Self, cast, ) import warnings @@ -84,7 +85,6 @@ IntervalClosedType, Ordered, Scalar, - Self, npt, type_t, ) diff --git a/pandas/core/dtypes/inference.py b/pandas/core/dtypes/inference.py index 918d107f2ce6c..928e44e51b3cf 100644 --- a/pandas/core/dtypes/inference.py +++ b/pandas/core/dtypes/inference.py @@ -6,7 +6,10 @@ from numbers import Number import re from re import Pattern -from typing import TYPE_CHECKING +from typing import ( + TYPE_CHECKING, + TypeGuard, +) import numpy as np @@ -15,8 +18,6 @@ if TYPE_CHECKING: from collections.abc import Hashable - from pandas._typing import TypeGuard - is_bool = lib.is_bool is_integer = lib.is_integer diff --git a/pandas/core/frame.py b/pandas/core/frame.py index e48620a854edb..f14cb74f7cddf 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -31,6 +31,7 @@ TYPE_CHECKING, Any, Literal, + Self, cast, overload, ) @@ -242,7 +243,6 @@ ReindexMethod, Renamer, Scalar, - Self, SequenceNotStr, SortKind, StorageOptions, diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 2ae28266266f6..db13b8cb1d39d 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -14,8 +14,10 @@ TYPE_CHECKING, Any, ClassVar, + Concatenate, Literal, NoReturn, + Self, cast, final, overload, @@ -41,7 +43,6 @@ Axis, AxisInt, CompressionOptions, - Concatenate, DtypeArg, DtypeBackend, DtypeObj, @@ -66,7 +67,6 @@ ReindexMethod, Renamer, Scalar, - Self, SequenceNotStr, SortKind, StorageOptions, diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 0e9c014b48a9c..b67397b99dc20 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -25,7 +25,9 @@ class providing the base-class of operations. from textwrap import dedent from typing import ( TYPE_CHECKING, + Concatenate, Literal, + Self, TypeAlias, TypeVar, Union, @@ -146,9 +148,7 @@ class providing the base-class of operations. from pandas._libs.tslibs.timedeltas import Timedelta from pandas._typing import ( Any, - Concatenate, P, - Self, T, ) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index e8c5a03a6de50..df4df2a4913c2 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -11,6 +11,7 @@ ClassVar, Literal, NoReturn, + Self, cast, final, overload, @@ -59,7 +60,6 @@ Level, NaPosition, ReindexMethod, - Self, Shape, SliceType, npt, diff --git a/pandas/core/indexes/category.py b/pandas/core/indexes/category.py index d20a84449fb85..92081d7c71236 100644 --- a/pandas/core/indexes/category.py +++ b/pandas/core/indexes/category.py @@ -4,6 +4,7 @@ TYPE_CHECKING, Any, Literal, + Self, cast, ) @@ -44,7 +45,6 @@ from pandas._typing import ( Dtype, DtypeObj, - Self, npt, ) diff --git a/pandas/core/indexes/datetimelike.py b/pandas/core/indexes/datetimelike.py index 8b316de30662c..62831f941b535 100644 --- a/pandas/core/indexes/datetimelike.py +++ b/pandas/core/indexes/datetimelike.py @@ -11,6 +11,7 @@ from typing import ( TYPE_CHECKING, Any, + Self, cast, final, ) @@ -74,7 +75,6 @@ from pandas._typing import ( Axis, JoinHow, - Self, npt, ) diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index 9adbaadbdcdc8..b79043e8f61c8 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -2,7 +2,10 @@ import datetime as dt import operator -from typing import TYPE_CHECKING +from typing import ( + TYPE_CHECKING, + Self, +) import warnings import numpy as np @@ -55,7 +58,6 @@ DtypeObj, Frequency, IntervalClosedType, - Self, TimeAmbiguous, TimeNonexistent, npt, diff --git a/pandas/core/indexes/frozen.py b/pandas/core/indexes/frozen.py index 254bd71ade209..bdecd8e3fefe5 100644 --- a/pandas/core/indexes/frozen.py +++ b/pandas/core/indexes/frozen.py @@ -10,17 +10,14 @@ from __future__ import annotations from typing import ( - TYPE_CHECKING, NoReturn, + Self, ) from pandas.core.base import PandasObject from pandas.io.formats.printing import pprint_thing -if TYPE_CHECKING: - from pandas._typing import Self - class FrozenList(PandasObject, list): """ diff --git a/pandas/core/indexes/interval.py b/pandas/core/indexes/interval.py index 8c40b630e8cfd..ad3278d3ec205 100644 --- a/pandas/core/indexes/interval.py +++ b/pandas/core/indexes/interval.py @@ -11,6 +11,7 @@ TYPE_CHECKING, Any, Literal, + Self, ) import numpy as np @@ -97,7 +98,6 @@ Dtype, DtypeObj, IntervalClosedType, - Self, npt, ) _index_doc_kwargs = dict(ibase._index_doc_kwargs) diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index f16ae9483b186..016b30e215d02 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -15,6 +15,7 @@ TYPE_CHECKING, Any, Literal, + Self, cast, ) import warnings @@ -40,7 +41,6 @@ IndexLabel, IndexT, Scalar, - Self, Shape, npt, ) diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 0a7a0319bed3a..f2ea1eaaf9cea 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -4,7 +4,10 @@ datetime, timedelta, ) -from typing import TYPE_CHECKING +from typing import ( + TYPE_CHECKING, + Self, +) import numpy as np @@ -50,7 +53,6 @@ from pandas._typing import ( Dtype, DtypeObj, - Self, npt, ) diff --git a/pandas/core/indexes/range.py b/pandas/core/indexes/range.py index 2db50bbbdfa37..a3b173d297253 100644 --- a/pandas/core/indexes/range.py +++ b/pandas/core/indexes/range.py @@ -12,6 +12,7 @@ TYPE_CHECKING, Any, Literal, + Self, cast, overload, ) @@ -59,7 +60,6 @@ JoinHow, NaPosition, NumpySorter, - Self, npt, ) diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 42dd8adbead09..85c59b103cc86 100644 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -5,6 +5,7 @@ from typing import ( TYPE_CHECKING, Any, + Self, cast, final, ) @@ -81,7 +82,6 @@ from pandas._typing import ( Axis, AxisInt, - Self, T, npt, ) diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 6aaf0b4abea1c..72a03d1ff0cde 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -6,6 +6,7 @@ TYPE_CHECKING, Any, Literal, + Self, cast, final, ) @@ -32,7 +33,6 @@ IgnoreRaise, InterpolateOptions, QuantileInterpolation, - Self, Shape, npt, ) diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index 67d7ffa80462a..94437ac93570c 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -11,6 +11,7 @@ Any, Literal, NoReturn, + Self, cast, final, ) @@ -99,7 +100,6 @@ AxisInt, DtypeObj, QuantileInterpolation, - Self, Shape, npt, ) diff --git a/pandas/core/resample.py b/pandas/core/resample.py index 2778e6e7eef76..3b84ce609a409 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -4,7 +4,9 @@ from textwrap import dedent from typing import ( TYPE_CHECKING, + Concatenate, Literal, + Self, cast, final, no_type_check, @@ -96,13 +98,11 @@ Any, AnyArrayLike, Axis, - Concatenate, FreqIndexT, Frequency, IndexLabel, InterpolateOptions, P, - Self, T, TimedeltaConvertibleTypes, TimeGrouperOrigin, diff --git a/pandas/core/series.py b/pandas/core/series.py index 6ae03f2464f76..6e0dd00efc59b 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -20,6 +20,7 @@ TYPE_CHECKING, Any, Literal, + Self, cast, overload, ) @@ -191,7 +192,6 @@ ReindexMethod, Renamer, Scalar, - Self, SortKind, StorageOptions, Suffixes, diff --git a/pandas/core/strings/base.py b/pandas/core/strings/base.py index 78c4f3acbe1aa..eee0fcf3df5b0 100644 --- a/pandas/core/strings/base.py +++ b/pandas/core/strings/base.py @@ -4,6 +4,7 @@ from typing import ( TYPE_CHECKING, Literal, + Self, ) from pandas._libs import lib @@ -18,7 +19,6 @@ from pandas._typing import ( NpDtype, Scalar, - Self, ) diff --git a/pandas/core/window/expanding.py b/pandas/core/window/expanding.py index bff3485c9cb86..4c4d43f0c7545 100644 --- a/pandas/core/window/expanding.py +++ b/pandas/core/window/expanding.py @@ -4,7 +4,9 @@ from typing import ( TYPE_CHECKING, Any, + Concatenate, Literal, + Self, final, overload, ) @@ -41,10 +43,8 @@ from collections.abc import Callable from pandas._typing import ( - Concatenate, P, QuantileInterpolation, - Self, T, WindowingRankType, ) diff --git a/pandas/core/window/rolling.py b/pandas/core/window/rolling.py index 03534bbee4c58..b2dd92c9c7d60 100644 --- a/pandas/core/window/rolling.py +++ b/pandas/core/window/rolling.py @@ -13,7 +13,9 @@ from typing import ( TYPE_CHECKING, Any, + Concatenate, Literal, + Self, final, overload, ) @@ -109,11 +111,9 @@ from pandas._typing import ( ArrayLike, - Concatenate, NDFrameT, QuantileInterpolation, P, - Self, T, WindowingRankType, npt, diff --git a/pandas/io/excel/_base.py b/pandas/io/excel/_base.py index 1dc6c1f08b49a..137ce208c5da1 100644 --- a/pandas/io/excel/_base.py +++ b/pandas/io/excel/_base.py @@ -18,6 +18,7 @@ Any, Generic, Literal, + Self, TypeVar, Union, cast, @@ -82,7 +83,6 @@ HashableT, IntStrT, ReadBuffer, - Self, SequenceNotStr, StorageOptions, WriteExcelBuffer, diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 0f734a81795c4..5be18d09396a8 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -10,6 +10,8 @@ import textwrap from typing import ( TYPE_CHECKING, + Concatenate, + Self, overload, ) @@ -66,7 +68,6 @@ Any, Axis, AxisInt, - Concatenate, ExcelWriterMergeCells, FilePath, IndexLabel, @@ -75,7 +76,6 @@ P, QuantileInterpolation, Scalar, - Self, StorageOptions, T, WriteBuffer, diff --git a/pandas/io/json/_json.py b/pandas/io/json/_json.py index 59911a57acc02..e1286eee65128 100644 --- a/pandas/io/json/_json.py +++ b/pandas/io/json/_json.py @@ -11,6 +11,7 @@ Any, Generic, Literal, + Self, TypeVar, final, overload, @@ -82,7 +83,6 @@ JSONEngine, JSONSerializable, ReadBuffer, - Self, StorageOptions, WriteBuffer, ) diff --git a/pandas/io/parsers/readers.py b/pandas/io/parsers/readers.py index 4fbd71ed03662..b872464147311 100644 --- a/pandas/io/parsers/readers.py +++ b/pandas/io/parsers/readers.py @@ -19,7 +19,9 @@ Any, Generic, Literal, + Self, TypedDict, + Unpack, overload, ) import warnings @@ -89,9 +91,7 @@ HashableT, IndexLabel, ReadCsvBuffer, - Self, StorageOptions, - Unpack, UsecolsArgType, ) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 64a05c87e0f80..cfd5b3ac1f33f 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -20,6 +20,7 @@ Any, Final, Literal, + Self, TypeAlias, cast, overload, @@ -127,7 +128,6 @@ AxisInt, DtypeArg, FilePath, - Self, Shape, npt, ) diff --git a/pandas/io/sas/sasreader.py b/pandas/io/sas/sasreader.py index 6daf4a24781bd..1424d43d2a053 100644 --- a/pandas/io/sas/sasreader.py +++ b/pandas/io/sas/sasreader.py @@ -11,6 +11,7 @@ from collections.abc import Iterator from typing import ( TYPE_CHECKING, + Self, overload, ) @@ -28,7 +29,6 @@ CompressionOptions, FilePath, ReadBuffer, - Self, ) from pandas import DataFrame diff --git a/pandas/io/sql.py b/pandas/io/sql.py index 7376843f7e8ff..18129257af1c9 100644 --- a/pandas/io/sql.py +++ b/pandas/io/sql.py @@ -24,6 +24,7 @@ TYPE_CHECKING, Any, Literal, + Self, cast, overload, ) @@ -85,7 +86,6 @@ DtypeArg, DtypeBackend, IndexLabel, - Self, ) from pandas import Index diff --git a/pandas/io/stata.py b/pandas/io/stata.py index 08177e76ee237..5b102a567f409 100644 --- a/pandas/io/stata.py +++ b/pandas/io/stata.py @@ -26,6 +26,7 @@ TYPE_CHECKING, AnyStr, Final, + Self, cast, ) import warnings @@ -84,7 +85,6 @@ CompressionOptions, FilePath, ReadBuffer, - Self, StorageOptions, WriteBuffer, ) diff --git a/pandas/tests/arrays/categorical/test_api.py b/pandas/tests/arrays/categorical/test_api.py index 6ac2e74288359..efccb129ac6ef 100644 --- a/pandas/tests/arrays/categorical/test_api.py +++ b/pandas/tests/arrays/categorical/test_api.py @@ -3,8 +3,6 @@ import numpy as np import pytest -from pandas.compat import PY311 - from pandas import ( Categorical, CategoricalIndex, @@ -47,11 +45,7 @@ def test_set_ordered(self): assert not cat2.set_ordered(False).ordered # removed in 0.19.0 - msg = ( - "property 'ordered' of 'Categorical' object has no setter" - if PY311 - else "can't set attribute" - ) + msg = "property 'ordered' of 'Categorical' object has no setter" with pytest.raises(AttributeError, match=msg): cat.ordered = True with pytest.raises(AttributeError, match=msg): @@ -435,11 +429,7 @@ def test_codes_immutable(self): tm.assert_numpy_array_equal(c.codes, exp) # Assignments to codes should raise - msg = ( - "property 'codes' of 'Categorical' object has no setter" - if PY311 - else "can't set attribute" - ) + msg = "property 'codes' of 'Categorical' object has no setter" with pytest.raises(AttributeError, match=msg): c.codes = np.array([0, 1, 2, 0, 1], dtype="int8") diff --git a/pandas/tests/extension/test_arrow.py b/pandas/tests/extension/test_arrow.py index c3e1d33ec93df..8ab88690c77e7 100644 --- a/pandas/tests/extension/test_arrow.py +++ b/pandas/tests/extension/test_arrow.py @@ -35,7 +35,6 @@ from pandas._libs import lib from pandas._libs.tslibs import timezones from pandas.compat import ( - PY311, PY312, is_ci_environment, is_platform_windows, @@ -344,13 +343,7 @@ def test_from_sequence_pa_array_notimplemented(self, request): def test_from_sequence_of_strings_pa_array(self, data, request): pa_dtype = data.dtype.pyarrow_dtype - if pa.types.is_time64(pa_dtype) and pa_dtype.equals("time64[ns]") and not PY311: - request.applymarker( - pytest.mark.xfail( - reason="Nanosecond time parsing not supported.", - ) - ) - elif pa.types.is_timestamp(pa_dtype) and pa_dtype.tz is not None: + if pa.types.is_timestamp(pa_dtype) and pa_dtype.tz is not None: _require_timezone_database(request) pa_array = data._pa_array.cast(pa.string()) diff --git a/pandas/tests/indexes/multi/test_get_set.py b/pandas/tests/indexes/multi/test_get_set.py index 7f292aacc39ca..9633681d36b6e 100644 --- a/pandas/tests/indexes/multi/test_get_set.py +++ b/pandas/tests/indexes/multi/test_get_set.py @@ -1,8 +1,6 @@ import numpy as np import pytest -from pandas.compat import PY311 - from pandas.core.dtypes.dtypes import DatetimeTZDtype import pandas as pd @@ -150,11 +148,7 @@ def test_set_levels_codes_directly(idx): with pytest.raises(AttributeError, match=msg): idx.levels = new_levels - msg = ( - "property 'codes' of 'MultiIndex' object has no setter" - if PY311 - else "can't set attribute" - ) + msg = "property 'codes' of 'MultiIndex' object has no setter" with pytest.raises(AttributeError, match=msg): idx.codes = new_codes diff --git a/pandas/tests/indexes/period/test_freq_attr.py b/pandas/tests/indexes/period/test_freq_attr.py index e1ecffa4982bd..7018188a807df 100644 --- a/pandas/tests/indexes/period/test_freq_attr.py +++ b/pandas/tests/indexes/period/test_freq_attr.py @@ -1,7 +1,5 @@ import pytest -from pandas.compat import PY311 - from pandas import ( offsets, period_range, @@ -19,10 +17,6 @@ def test_freq_setter_deprecated(self): idx.freq # warning for setter - msg = ( - "property 'freq' of 'PeriodArray' object has no setter" - if PY311 - else "can't set attribute" - ) + msg = "property 'freq' of 'PeriodArray' object has no setter" with pytest.raises(AttributeError, match=msg): idx.freq = offsets.Day() diff --git a/pandas/tests/io/parser/common/test_read_errors.py b/pandas/tests/io/parser/common/test_read_errors.py index a73327beea8bb..f3019bd1c8187 100644 --- a/pandas/tests/io/parser/common/test_read_errors.py +++ b/pandas/tests/io/parser/common/test_read_errors.py @@ -12,7 +12,6 @@ import numpy as np import pytest -from pandas.compat import PY311 from pandas.errors import ( EmptyDataError, ParserError, @@ -227,12 +226,10 @@ def test_null_byte_char(request, all_parsers): names = ["a", "b"] parser = all_parsers - if parser.engine == "c" or (parser.engine == "python" and PY311): - if parser.engine == "python" and PY311: + if parser.engine in ["c", "python"]: + if parser.engine == "python": request.applymarker( - pytest.mark.xfail( - reason="In Python 3.11, this is read as an empty character not null" - ) + pytest.mark.xfail(reason="This is read as an empty character not null") ) expected = DataFrame([[np.nan, "foo"]], columns=names) out = parser.read_csv(StringIO(data), names=names) diff --git a/pandas/tests/io/parser/test_quoting.py b/pandas/tests/io/parser/test_quoting.py index a70b7e3389c1b..3531747358d5c 100644 --- a/pandas/tests/io/parser/test_quoting.py +++ b/pandas/tests/io/parser/test_quoting.py @@ -8,7 +8,6 @@ import pytest -from pandas.compat import PY311 from pandas.errors import ParserError from pandas import DataFrame @@ -90,14 +89,14 @@ def test_null_quote_char(all_parsers, quoting, quote_char): # Sanity checking. msg = ( '"quotechar" must be a 1-character string' - if PY311 and all_parsers.engine == "python" and quote_char == "" + if all_parsers.engine == "python" and quote_char == "" else "quotechar must be set if quoting enabled" ) with pytest.raises(TypeError, match=msg): parser.read_csv(StringIO(data), **kwargs) - elif not (PY311 and all_parsers.engine == "python"): - # Python 3.11+ doesn't support null/blank quote chars in their csv parsers + elif all_parsers.engine != "python": + # Python doesn't support null/blank quote chars in their csv parsers expected = DataFrame([[1, 2, 3]], columns=["a", "b", "c"]) result = parser.read_csv(StringIO(data), **kwargs) tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/io/pytables/test_file_handling.py b/pandas/tests/io/pytables/test_file_handling.py index 27b5d34146f85..295c3b72ba5e2 100644 --- a/pandas/tests/io/pytables/test_file_handling.py +++ b/pandas/tests/io/pytables/test_file_handling.py @@ -4,8 +4,6 @@ import pytest from pandas.compat import ( - PY311, - is_ci_environment, is_platform_linux, is_platform_little_endian, is_platform_mac, @@ -279,18 +277,10 @@ def test_complibs_default_settings_override(tmp_path, setup_path): @pytest.mark.parametrize("lvl", range(10)) @pytest.mark.parametrize("lib", tables.filters.all_complibs) @pytest.mark.filterwarnings("ignore:object name is not a valid") -@pytest.mark.skipif( - not PY311 and is_ci_environment() and is_platform_linux(), - reason="Segfaulting in a CI environment", - # with xfail, would sometimes raise UnicodeDecodeError - # invalid state byte -) def test_complibs(tmp_path, lvl, lib, request): # GH14478 - if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: - request.applymarker( - pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11") - ) + if is_platform_linux() and lib == "blosc2" and lvl != 0: + request.applymarker(pytest.mark.xfail(reason=f"Fails for {lib} on Linux")) df = DataFrame( np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) ) diff --git a/pandas/tests/io/test_parquet.py b/pandas/tests/io/test_parquet.py index 9f9304c8d1664..4fe3a97cb2386 100644 --- a/pandas/tests/io/test_parquet.py +++ b/pandas/tests/io/test_parquet.py @@ -151,7 +151,7 @@ def df_full(): @pytest.fixture( params=[ - datetime.datetime.now(datetime.timezone.utc), + datetime.datetime.now(datetime.UTC), datetime.datetime.now(datetime.timezone.min), datetime.datetime.now(datetime.timezone.max), datetime.datetime.strptime("2019-01-04T16:41:24+0200", "%Y-%m-%dT%H:%M:%S%z"), @@ -1001,7 +1001,7 @@ def test_timezone_aware_index(self, pa, timezone_aware_date_list): expected = df[:] if pa_version_under13p0: expected.index = expected.index.as_unit("ns") - if timezone_aware_date_list.tzinfo != datetime.timezone.utc: + if timezone_aware_date_list.tzinfo != datetime.UTC: # pyarrow returns pytz.FixedOffset while pandas constructs datetime.timezone # https://github.com/pandas-dev/pandas/issues/37286 try: diff --git a/pandas/tests/reshape/merge/test_merge_asof.py b/pandas/tests/reshape/merge/test_merge_asof.py index f7b0876c5a605..0e5fcccd73e26 100644 --- a/pandas/tests/reshape/merge/test_merge_asof.py +++ b/pandas/tests/reshape/merge/test_merge_asof.py @@ -2070,7 +2070,7 @@ def test_tolerance_tz(self, unit): start=to_datetime("2016-01-02"), freq="D", periods=5, - tz=datetime.timezone.utc, + tz=datetime.UTC, unit=unit, ), "value1": np.arange(5), @@ -2082,7 +2082,7 @@ def test_tolerance_tz(self, unit): start=to_datetime("2016-01-01"), freq="D", periods=5, - tz=datetime.timezone.utc, + tz=datetime.UTC, unit=unit, ), "value2": list("ABCDE"), @@ -2096,7 +2096,7 @@ def test_tolerance_tz(self, unit): start=to_datetime("2016-01-02"), freq="D", periods=5, - tz=datetime.timezone.utc, + tz=datetime.UTC, unit=unit, ), "value1": np.arange(5), diff --git a/pandas/tests/test_downstream.py b/pandas/tests/test_downstream.py index d7398ffe259cb..4565efb8880e2 100644 --- a/pandas/tests/test_downstream.py +++ b/pandas/tests/test_downstream.py @@ -269,13 +269,10 @@ def test_from_obscure_array(dtype, box): else: data = box(arr) - if not isinstance(data, memoryview): - # FIXME(GH#44431) these raise on memoryview and attempted fix - # fails on py3.10 - func = {"M8[ns]": pd.to_datetime, "m8[ns]": pd.to_timedelta}[dtype] - result = func(arr).array - expected = func(data).array - tm.assert_equal(result, expected) + func = {"M8[ns]": pd.to_datetime, "m8[ns]": pd.to_timedelta}[dtype] + result = func(arr).array + expected = func(data).array + tm.assert_equal(result, expected) # Let's check the Indexes while we're here idx_cls = {"M8[ns]": DatetimeIndex, "m8[ns]": TimedeltaIndex}[dtype] diff --git a/pandas/tests/tools/test_to_time.py b/pandas/tests/tools/test_to_time.py index 5e61f5e1a3029..d4f48c9e0721e 100644 --- a/pandas/tests/tools/test_to_time.py +++ b/pandas/tests/tools/test_to_time.py @@ -4,8 +4,6 @@ import numpy as np import pytest -from pandas.compat import PY311 - from pandas import Series import pandas._testing as tm from pandas.core.tools.times import to_time @@ -40,10 +38,6 @@ def test_parsers_time(self, time_string): def test_odd_format(self): new_string = "14.15" - msg = r"Cannot convert arg \['14\.15'\] to a time" - if not PY311: - with pytest.raises(ValueError, match=msg): - to_time(new_string) assert to_time(new_string, format="%H.%M") == time(14, 15) def test_arraylike(self): diff --git a/pandas/tests/tslibs/test_resolution.py b/pandas/tests/tslibs/test_resolution.py index 0e7705ad7ed94..59004d2cabdee 100644 --- a/pandas/tests/tslibs/test_resolution.py +++ b/pandas/tests/tslibs/test_resolution.py @@ -22,7 +22,7 @@ def test_get_resolution_non_nano_data(): res = get_resolution(arr, None, NpyDatetimeUnit.NPY_FR_us.value) assert res == Resolution.RESO_US - res = get_resolution(arr, datetime.timezone.utc, NpyDatetimeUnit.NPY_FR_us.value) + res = get_resolution(arr, datetime.UTC, NpyDatetimeUnit.NPY_FR_us.value) assert res == Resolution.RESO_US diff --git a/pyproject.toml b/pyproject.toml index 5c836951961f2..0ea46b92e9e01 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ authors = [ { name = 'The Pandas Development Team', email='pandas-dev@python.org' }, ] license = {file = 'LICENSE'} -requires-python = '>=3.10' +requires-python = '>=3.11' dependencies = [ "numpy>=1.26.0", "python-dateutil>=2.8.2", @@ -41,7 +41,6 @@ classifiers = [ 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', 'Programming Language :: Python :: 3.13', @@ -199,7 +198,7 @@ test-command = """ [tool.ruff] line-length = 88 -target-version = "py310" +target-version = "py311" fix = true [tool.ruff.lint] @@ -277,8 +276,6 @@ ignore = [ "B015", # Function definition does not bind loop variable "B023", - # Only works with python >=3.10 - "B905", # Too many arguments to function call "PLR0913", # Too many returns @@ -331,7 +328,7 @@ ignore = [ "PLR0124", # collection-literal-concatenation "RUF005", - # pairwise-over-zipped (>=PY310 only) + # pairwise-over-zipped "RUF007", # mutable-class-default "RUF012", @@ -393,6 +390,8 @@ ignore = [ "PLW0603", # runtime-cast-value "TC006", + # zip-without-explicit-strict + "B905", ] exclude = [ diff --git a/requirements-dev.txt b/requirements-dev.txt index 3e2e637927389..708aa7567a009 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -85,5 +85,4 @@ jupyterlite-core jupyterlite-pyodide-kernel adbc-driver-postgresql>=0.10.0 adbc-driver-sqlite>=0.8.0 -typing_extensions; python_version<"3.11" tzdata>=2023.3 diff --git a/scripts/generate_pip_deps_from_conda.py b/scripts/generate_pip_deps_from_conda.py index 68cda68e26001..f84f79f4862f1 100755 --- a/scripts/generate_pip_deps_from_conda.py +++ b/scripts/generate_pip_deps_from_conda.py @@ -16,11 +16,8 @@ import pathlib import re import sys +import tomllib -if sys.version_info >= (3, 11): - import tomllib -else: - import tomli as tomllib import yaml EXCLUDE = {"python", "c-compiler", "cxx-compiler"} diff --git a/scripts/tests/data/deps_minimum.toml b/scripts/tests/data/deps_minimum.toml index e6135ca088772..b2399a4b43093 100644 --- a/scripts/tests/data/deps_minimum.toml +++ b/scripts/tests/data/deps_minimum.toml @@ -39,7 +39,6 @@ classifiers = [ 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Topic :: Scientific/Engineering' ] diff --git a/scripts/tests/test_validate_min_versions_in_sync.py b/scripts/tests/test_validate_min_versions_in_sync.py index b6e339c13889f..7594e7ad93e38 100644 --- a/scripts/tests/test_validate_min_versions_in_sync.py +++ b/scripts/tests/test_validate_min_versions_in_sync.py @@ -1,14 +1,9 @@ import pathlib -import sys +import tomllib import pytest import yaml -if sys.version_info >= (3, 11): - import tomllib -else: - import tomli as tomllib - from scripts.validate_min_versions_in_sync import ( get_toml_map_from, get_yaml_map_from, diff --git a/scripts/validate_min_versions_in_sync.py b/scripts/validate_min_versions_in_sync.py index a45791f6c05cd..91755fb9b36d9 100755 --- a/scripts/validate_min_versions_in_sync.py +++ b/scripts/validate_min_versions_in_sync.py @@ -16,16 +16,11 @@ import pathlib import sys +import tomllib +from typing import Any import yaml -if sys.version_info >= (3, 11): - import tomllib -else: - import tomli as tomllib - -from typing import Any - from scripts.generate_pip_deps_from_conda import CONDA_TO_PIP DOC_PATH = pathlib.Path("doc/source/getting_started/install.rst").resolve()