Skip to content

Commit

Permalink
1.1.400 would require too many difficult changes
Browse files Browse the repository at this point in the history
  • Loading branch information
twoertwein committed Dec 16, 2023
1 parent c5408df commit dadcf1f
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 10 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ci:
autofix_prs: false
autoupdate_schedule: monthly
# manual stage hooks
skip: [pylint, pyright, pyright-reportGeneralTypeIssues, mypy]
skip: [pylint, pyright, mypy]
repos:
- repo: https://github.com/hauntsaninja/black-pre-commit-mirror
# black compiled with mypyc
Expand Down Expand Up @@ -132,11 +132,11 @@ repos:
types: [python]
stages: [manual]
additional_dependencies: &pyright_dependencies
- pyright@1.1.340
- id: pyright-reportGeneralTypeIssues
- pyright@1.1.339
- id: pyright
# note: assumes python env is setup and activated
name: pyright reportGeneralTypeIssues
entry: pyright --skipunannotated -p pyright_reportGeneralTypeIssues.json --level warning
entry: pyright -p pyright_reportGeneralTypeIssues.json --level warning
language: node
pass_filenames: false
types: [python]
Expand Down
4 changes: 3 additions & 1 deletion pandas/_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ def get_default_val(pat: str):
class DictWrapper:
"""provide attribute-style access to a nested dict"""

d: dict[str, Any]

def __init__(self, d: dict[str, Any], prefix: str = "") -> None:
object.__setattr__(self, "d", d)
object.__setattr__(self, "prefix", prefix)
Expand Down Expand Up @@ -250,7 +252,7 @@ def __getattr__(self, key: str):
else:
return _get_option(prefix)

def __dir__(self) -> Iterable[str]:
def __dir__(self) -> list[str]:
return list(self.d.keys())


Expand Down
1 change: 0 additions & 1 deletion pandas/_libs/tslibs/nattype.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import typing
import numpy as np

from pandas._libs.tslibs.period import Period

from pandas._typing import Self

NaT: NaTType
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
Any,
Callable,
Literal,
MutableMapping,
cast,
)
import warnings
Expand Down Expand Up @@ -63,6 +62,7 @@
Generator,
Hashable,
Iterable,
MutableMapping,
Sequence,
)

Expand Down
52 changes: 50 additions & 2 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
from pandas.util._decorators import (
Appender,
cache_readonly,
deprecate_nonkeyword_arguments,
doc,
)
from pandas.util._exceptions import (
Expand Down Expand Up @@ -1896,7 +1897,18 @@ def set_names(self, names, *, level=None, inplace: bool = False) -> Self | None:
return idx
return None

def rename(self, name, inplace: bool = False):
@overload
def rename(self, name, *, inplace: Literal[False] = ...) -> Self:
...

@overload
def rename(self, name, *, inplace: Literal[True]) -> None:
...

@deprecate_nonkeyword_arguments(
version="3.0", allowed_args=["self", "name"], name="rename"
)
def rename(self, name, inplace: bool = False) -> Self | None:
"""
Alter Index or MultiIndex name.
Expand Down Expand Up @@ -5792,13 +5804,49 @@ def asof_locs(

return result

@overload
def sort_values(
self,
*,
return_indexer: Literal[False] = ...,
ascending: bool = ...,
na_position: NaPosition = ...,
key: Callable | None = ...,
) -> Self:
...

@overload
def sort_values(
self,
*,
return_indexer: Literal[True],
ascending: bool = ...,
na_position: NaPosition = ...,
key: Callable | None = ...,
) -> tuple[Self, np.ndarray]:
...

@overload
def sort_values(
self,
*,
return_indexer: bool = ...,
ascending: bool = ...,
na_position: NaPosition = ...,
key: Callable | None = ...,
) -> Self | tuple[Self, np.ndarray]:
...

@deprecate_nonkeyword_arguments(
version="3.0", allowed_args=["self"], name="sort_values"
)
def sort_values(
self,
return_indexer: bool = False,
ascending: bool = True,
na_position: NaPosition = "last",
key: Callable | None = None,
):
) -> Self | tuple[Self, np.ndarray]:
"""
Return a sorted copy of the index.
Expand Down
42 changes: 41 additions & 1 deletion pandas/core/indexes/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
TYPE_CHECKING,
Any,
Callable,
Literal,
cast,
overload,
)

import numpy as np
Expand All @@ -25,6 +27,7 @@
from pandas.compat.numpy import function as nv
from pandas.util._decorators import (
cache_readonly,
deprecate_nonkeyword_arguments,
doc,
)

Expand Down Expand Up @@ -555,13 +558,50 @@ def equals(self, other: object) -> bool:
return self._range == other._range
return super().equals(other)

# error: Signature of "sort_values" incompatible with supertype "Index"
@overload # type: ignore[override]
def sort_values(
self,
*,
return_indexer: Literal[False] = ...,
ascending: bool = ...,
na_position: NaPosition = ...,
key: Callable | None = ...,
) -> Self:
...

@overload
def sort_values(
self,
*,
return_indexer: Literal[True],
ascending: bool = ...,
na_position: NaPosition = ...,
key: Callable | None = ...,
) -> tuple[Self, np.ndarray | RangeIndex]:
...

@overload
def sort_values(
self,
*,
return_indexer: bool = ...,
ascending: bool = ...,
na_position: NaPosition = ...,
key: Callable | None = ...,
) -> Self | tuple[Self, np.ndarray | RangeIndex]:
...

@deprecate_nonkeyword_arguments(
version="3.0", allowed_args=["self"], name="sort_values"
)
def sort_values(
self,
return_indexer: bool = False,
ascending: bool = True,
na_position: NaPosition = "last",
key: Callable | None = None,
):
) -> Self | tuple[Self, np.ndarray | RangeIndex]:
if key is not None:
return super().sort_values(
return_indexer=return_indexer,
Expand Down
2 changes: 2 additions & 0 deletions pyright_reportGeneralTypeIssues.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"typeCheckingMode": "off",
"reportGeneralTypeIssues": true,
"useLibraryCodeForTypes": false,
"analyzeUnannotatedFunctions": false,
"disableBytesTypePromotions": true,
"include":
[
Expand Down Expand Up @@ -40,6 +41,7 @@
"pandas/core/arrays/string_arrow.py",
"pandas/core/arrays/timedeltas.py",
"pandas/core/computation/align.py",
"pandas/core/computation/ops.py",
"pandas/core/construction.py",
"pandas/core/dtypes/cast.py",
"pandas/core/dtypes/common.py",
Expand Down

0 comments on commit dadcf1f

Please sign in to comment.