Without scipy-stubs |
With scipy-stubs |
|---|---|
![]() |
![]() |
![]() |
![]() |
- VSCode
1.96.2 - PyLance
2024.12.100 pyright == 1.1.391scipy == 1.15.0
| import itertools, typing | |
| def primes(n: int, /) -> typing.Generator[int]: | |
| yield next(sieve := itertools.count(prime := 2)) | |
| for _ in range(n): | |
| yield (prime := next(sieve := filter(prime.__rmod__, sieve))) |
original post: scipy/scipy-stubs#153 (comment)
Overloads are roughly similar to pattern matching[^1], but from the perspective of the caller.
Consider this function for example
| import subprocess | |
| from pathlib import Path | |
| # see https://github.com/astral-sh/ruff/pull/18224 | |
| from ruff.__main__ import ( # type: ignore[import-untyped] # pyright: ignore[reportMissingTypeStubs] | |
| find_ruff_bin, # noqa: PLC2701 | |
| ) | |
| def ruff_format(source: str) -> str: |
| trait Family { | |
| type Member<T>; | |
| } | |
| trait Functor<A> { | |
| type Of: Family<Member<A> = Self>; | |
| fn fmap<B>(self, f: impl FnMut(A) -> B) -> <Self::Of as Family>::Member<B>; | |
| } | |
| // |
| module | usage_count | |
|---|---|---|
| scipy.stats | 1556 | |
| scipy.signal | 1506 | |
| scipy.linalg | 1342 | |
| scipy.optimize | 1319 | |
| scipy.sparse | 748 | |
| scipy.interpolate | 497 | |
| scipy.special | 441 | |
| scipy.ndimage | 434 | |
| scipy.spatial | 417 |
| { | |
| "label": "", | |
| "message": "ty", | |
| "logoSvg": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"48\" height=\"48\"><path d=\"M48 7.7H27.8V0h-24v7.7H0v18.2h3.8v14.3c0 4.3 3.5 7.8 7.8 7.8H48V29.8H27.8v-3.9h12.4c4.3 0 7.8-3.5 7.8-7.8V7.7Z\" fill=\"#46ebe1\"/></svg>", | |
| "logoWidth": 10, | |
| "labelColor": "grey", | |
| "color": "#261230" | |
| } |
| from typing import Protocol, Literal, reveal_type | |
| class CanRMul[InT, OutT](Protocol): | |
| def __rmul__(self, other: InT, /) -> OutT: ... | |
| def twice[OutT](x: CanRMul[Literal[2], OutT]) -> OutT: | |
| return 2 * x |