Skip to content

Small fixes to re-enable a few PYI rules #359

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 1 commit into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,9 @@ ignore = [
"F401",

# TODO: Investigate and fix or configure
"PYI001",
"PYI002",
"PYI017",
"PYI024",
"PYI048",
"PYI051", # Request for autofix: https://github.com/astral-sh/ruff/issues/14185
"PYI052",
]
[tool.ruff.lint.per-file-ignores]
"*.pyi" = [
Expand Down
8 changes: 4 additions & 4 deletions stubs/sklearn/model_selection/_search.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ from ..utils.validation import check_is_fitted as check_is_fitted, indexable as
from . import BaseCrossValidator
from ._split import check_cv as check_cv

BaseEstimatorT = TypeVar("BaseEstimatorT", bound=BaseEstimator, default=BaseEstimator, covariant=True)
_BaseEstimatorT = TypeVar("_BaseEstimatorT", bound=BaseEstimator, default=BaseEstimator, covariant=True)

__all__ = ["GridSearchCV", "ParameterGrid", "ParameterSampler", "RandomizedSearchCV"]

Expand Down Expand Up @@ -84,7 +84,7 @@ class BaseSearchCV(MetaEstimatorMixin, BaseEstimator, metaclass=ABCMeta):
**fit_params,
) -> Self: ...

class GridSearchCV(BaseSearchCV, Generic[BaseEstimatorT]):
class GridSearchCV(BaseSearchCV, Generic[_BaseEstimatorT]):
feature_names_in_: ndarray = ...
n_features_in_: int = ...
classes_: ndarray = ...
Expand All @@ -95,14 +95,14 @@ class GridSearchCV(BaseSearchCV, Generic[BaseEstimatorT]):
best_index_: int = ...
best_params_: dict = ...
best_score_: float = ...
best_estimator_: BaseEstimatorT = ...
best_estimator_: _BaseEstimatorT = ...
cv_results_: dict[str, ndarray] = ...

_required_parameters: ClassVar[list] = ...

def __init__(
self,
estimator: BaseEstimatorT,
estimator: _BaseEstimatorT,
param_grid: Mapping | Sequence[dict],
*,
scoring: ArrayLike | None | tuple | Callable | Mapping | str = None,
Expand Down
4 changes: 3 additions & 1 deletion stubs/sympy-stubs/codegen/ast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ class FloatBaseType(Type):
class FloatType(FloatBaseType):
__slots__ = ...
_fields = ...
_construct_nexp = _construct_nmant = _construct_nbits = Integer
_construct_nexp = Integer
_construct_nmant = Integer
_construct_nbits = Integer
@property
def max_exponent(self) -> Expr: ...
@property
Expand Down
3 changes: 2 additions & 1 deletion stubs/sympy-stubs/matrices/dense.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class DenseMatrix(RepMatrix):
class MutableDenseMatrix(DenseMatrix, MutableRepMatrix):
def simplify(self, **kwargs) -> None: ...

Matrix = MutableMatrix = MutableDenseMatrix
Matrix = MutableDenseMatrix
MutableMatrix = MutableDenseMatrix

def list2numpy(l, dtype=...) -> NDArray[Any, Any]: ...
def matrix2numpy(m, dtype=...) -> NDArray[Any, Any]: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/sympy-stubs/polys/domains/simpledomain.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ from typing_extensions import Self
from sympy.polys.domains.domain import Domain

class SimpleDomain(Domain):
is_Simple = True
is_Simple: bool = True
def inject(self, *gens) -> Self: ...
4 changes: 2 additions & 2 deletions stubs/sympy-stubs/polys/matrices/dense.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ from typing import Any, TypeVar

from sympy.polys.matrices._typing import RingElement

T = TypeVar("T")
R = TypeVar("R", bound=RingElement)
T = TypeVar("T") # noqa: PYI001 # Exists at runtime
R = TypeVar("R", bound=RingElement) # noqa: PYI001 # Exists at runtime

def ddm_transpose(matrix: Sequence[Sequence[T]]) -> list[list[T]]: ...
def ddm_iadd(a: list[list[R]], b: Sequence[Sequence[R]]) -> None: ...
Expand Down
3 changes: 2 additions & 1 deletion stubs/sympy-stubs/polys/polymatrix.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ class MutablePolyDenseMatrix:
def nullspace(self) -> list[Self]: ...
def rank(self): ...

PolyMatrix = MutablePolyMatrix = MutablePolyDenseMatrix
PolyMatrix = MutablePolyDenseMatrix
MutablePolyMatrix = MutablePolyDenseMatrix
4 changes: 2 additions & 2 deletions tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ def install_requirements(test_folder: Path):
def run_pyright():
print("\nRunning Pyright...")
# https://github.com/RobertCraigie/pyright-python#keeping-pyright-and-pylance-in-sync
del os.environ["PYRIGHT_PYTHON_FORCE_VERSION"]
os.environ.pop("PYRIGHT_PYTHON_FORCE_VERSION", None)
os.environ["PYRIGHT_PYTHON_PYLANCE_VERSION"] = "latest-prerelease"
return subprocess.run((sys.executable, "-m", "pyright"))


def run_mypy():
print("\nRunning mypy...")
return subprocess.run((sys.executable, "-m", "mypy"))
return subprocess.run((sys.executable, "-m", "mypy", "."))


def main():
Expand Down