Skip to content
Open
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
52 changes: 31 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ name = "microsoft-python-type-stubs"
version = "0"

[dependency-groups]
hygiene = ["ruff ==0.11.*"]
hygiene = ["ruff ==0.14.*"]
tests = [
# Tools used for testing
"docopt-ng",
"mypy ==1.16.*",
"mypy ==1.19.*",
"pyright",

# External type stubs and optional dependencies
Expand Down Expand Up @@ -55,15 +55,22 @@ target-version = "py39"
extend-select = [
"FA", # flake8-future-annotations
"I", # isort
"PGH", # pygrep-hooks
"PGH", # pygrep-hooks and blanket-noqa
"PIE790", # unnecessary-placeholder
"PIE", # flake8-pie and unnecessary-placeholder
"PYI", # flake8-pyi
"RUF", # Ruff-specific and unused-noqa
"TC", # flake8-type-checking
"UP", # pyupgrade
"W", # pycodestyle Warning
"YTT", # flake8-2020 (version_info misuses)
]
ignore = [
# Not colored correctly in Pylance https://github.com/microsoft/pylance-release/issues/6942
"UP047",

# TODO: Investigate and fix or configure
"PYI051", # Request for autofix: https://github.com/astral-sh/ruff/issues/14185

###
# Rules we don't want or don't agree with
###
Expand All @@ -77,9 +84,6 @@ ignore = [
"PYI011",
"PYI014",
"PYI053",

# TODO: Investigate and fix or configure
"PYI051", # Request for autofix: https://github.com/astral-sh/ruff/issues/14185
]

[tool.ruff.lint.per-file-ignores]
Expand Down Expand Up @@ -144,13 +148,12 @@ reportSelfClsParameterName = false
reportUnsupportedDunderAll = "error"

[tool.mypy]
fixed_format_cache = true # Will be default in mypy 1.20
strict = true
check_untyped_defs = true # Strict check on all defs
show_column_numbers = true
# Not all imports in these stubs are gonna be typed
# Don't infer symbols from untyped packages as Any
follow_untyped_imports = true
warn_unused_ignores = false # Change from pandas
# Partial stubs are acceptable
disallow_any_generics = false
disallow_incomplete_defs = false
Expand All @@ -165,25 +168,32 @@ disable_error_code = [
# as they are inherited from the implementation.
"override",
# TODO
"assignment", # 744 errors in 155 files
"assignment", # 688 errors in 155 files
]

[[tool.mypy.overrides]]
# follow_untyped_imports = true will cause stubtest to run mypy on the source
# So disable it for partial stubs
module = ["sympy.*"]
follow_untyped_imports = false
disable_error_code = ["import-untyped", "misc"]
disable_error_code = [
# TODO
"misc", # 185
]

[[tool.mypy.overrides]]
# These modules are to be removed soon, not worth solving many issues
module = ["matplotlib.*", "networkx.*"]
module = ["matplotlib.*"]
disable_error_code = ["assignment", "misc", "untyped-decorator"]

[[tool.mypy.overrides]]
module = ["sklearn.*"]
disable_error_code = [
"assignment",
"misc",
# TODO
"misc", # 25
"overload-overlap", # 14
]

[[tool.mypy.overrides]]
module = ["skimage.*", "sklearn.*"]
# TODO: Too many untyped decorators still left
# https://github.com/python/mypy/issues/19148
disable_error_code = ["misc"]
module = ["skimage.*"]
disable_error_code = [
# TODO: Too many untyped decorators still left
"untyped-decorator", # 52
]
5 changes: 1 addition & 4 deletions stubs/sympy-stubs/stats/crv_types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ from typing_extensions import Self
from sympy import Equality, FiniteSet, Integral, Interval, Ne, Piecewise, Sum
from sympy.core.basic import Basic
from sympy.core.relational import Relational
from sympy.matrices import MatrixBase
from sympy.stats.crv import SingleContinuousDistribution
from sympy.stats.joint_rv import JointRandomSymbol
from sympy.stats.rv import RandomSymbol, is_random
from sympy.stats.rv import RandomSymbol

oo = ...
__all__ = [
Expand Down Expand Up @@ -66,8 +65,6 @@ __all__ = [
"WignerSemicircle",
]

@is_random.register(MatrixBase)
def _(x) -> bool: ...
def rv(symbol, cls, args, **kwargs) -> RandomSymbol: ...

class ContinuousDistributionHandmade(SingleContinuousDistribution):
Expand Down
7 changes: 2 additions & 5 deletions stubs/sympy-stubs/stats/random_matrix_models.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Any, Literal
from typing import Any
from typing_extensions import Self

from sympy import Equality, Integral, Ne
from sympy.core.basic import Basic
from sympy.core.function import Lambda
from sympy.core.relational import Relational
from sympy.stats.joint_rv_types import JointDistributionHandmade
from sympy.stats.rv import Density, RandomMatrixSymbol, is_random
from sympy.stats.rv import Density, RandomMatrixSymbol

__all__ = [
"CircularEnsemble",
Expand All @@ -22,9 +22,6 @@ __all__ = [
"level_spacing_distribution",
]

@is_random.register(RandomMatrixSymbol)
def _(x) -> Literal[True]: ...

class RandomMatrixEnsembleModel(Basic):
def __new__(cls, sym, dim=...) -> Self: ...

Expand Down
6 changes: 1 addition & 5 deletions stubs/sympy-stubs/stats/rv.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from collections.abc import Generator
from functools import singledispatch
from typing import Any
from typing_extensions import Self

Expand All @@ -24,10 +23,7 @@ from sympy.utilities.decorator import doctest_depends_on

x = ...

@singledispatch
def is_random(x) -> bool: ...
@is_random.register(Basic)
def _(x) -> bool: ...
def is_random(x: object) -> bool: ...

class RandomDomain(Basic):
is_ProductDomain = ...
Expand Down
9 changes: 2 additions & 7 deletions stubs/sympy-stubs/stats/stochastic_process_types.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Generator
from typing import Any, Literal
from typing import Any
from typing_extensions import Self

from sympy import Equality, Integral, Ne, Piecewise, Sum
Expand All @@ -23,7 +23,7 @@ from sympy.stats.drv_types import PoissonDistribution
from sympy.stats.frv_types import BernoulliDistribution
from sympy.stats.joint_rv import JointDistribution, JointRandomSymbol
from sympy.stats.joint_rv_types import JointDistributionHandmade
from sympy.stats.rv import Density, Distribution, RandomIndexedSymbol, RandomSymbol, is_random
from sympy.stats.rv import Density, Distribution, RandomIndexedSymbol, RandomSymbol
from sympy.stats.symbolic_multivariate_probability import ExpectationMatrix
from sympy.stats.symbolic_probability import Expectation, Probability
from sympy.tensor.indexed import Indexed
Expand All @@ -43,11 +43,6 @@ __all__ = [
"GammaProcess",
]

@is_random.register(Indexed)
def _(x) -> bool: ...
@is_random.register(RandomIndexedSymbol)
def _(x) -> Literal[True]: ...

class StochasticProcess(Basic):
index_set = ...
def __new__(cls, sym, state_space=..., **kwargs) -> Self: ...
Expand Down
8 changes: 1 addition & 7 deletions stubs/sympy-stubs/stats/symbolic_probability.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Literal
from typing import Any
from typing_extensions import Self

from sympy import Basic, Equality, Integral, Ne, Piecewise, Sum
Expand All @@ -8,16 +8,10 @@ from sympy.core.function import Lambda
from sympy.core.relational import Relational
from sympy.series.order import Order
from sympy.stats.frv_types import BernoulliDistribution
from sympy.stats.rv import RandomSymbol, is_random
from sympy.stats.symbolic_multivariate_probability import CrossCovarianceMatrix, ExpectationMatrix, VarianceMatrix

__all__ = ["Probability", "Expectation", "Variance", "Covariance"]

@is_random.register(Expr) # type: ignore[has-type]
def _(x) -> bool: ...
@is_random.register(RandomSymbol) # type: ignore[has-type]
def _(x) -> Literal[True]: ...

class Probability(Expr):
def __new__(cls, prob, condition=..., **kwargs) -> Self: ...
def doit(self, **hints) -> Any | BernoulliDistribution | Probability | Equality | Lambda | Order | Relational | Ne | int: ...
Expand Down