diff --git a/python/helpers/typeshed/.flake8 b/python/helpers/typeshed/.flake8 index c3f4ab2b86e8..e45a7f11787b 100644 --- a/python/helpers/typeshed/.flake8 +++ b/python/helpers/typeshed/.flake8 @@ -2,7 +2,9 @@ # Y: Flake8 is only used to run flake8-pyi, everything else is in Ruff select = Y # Ignore rules normally excluded by default -extend-ignore = Y090,Y091 +# Also ignore Y041 (redundant (complex |) float | int), see +# https://github.com/python/typeshed/issues/16059 +extend-ignore = Y041,Y090,Y091 per-file-ignores = # Generated protobuf files: # Y021: Include docstrings diff --git a/python/helpers/typeshed/MAINTAINERS.md b/python/helpers/typeshed/MAINTAINERS.md index 7f33b516f22b..2048da2064d9 100644 --- a/python/helpers/typeshed/MAINTAINERS.md +++ b/python/helpers/typeshed/MAINTAINERS.md @@ -97,3 +97,9 @@ requests as "not planned" with an explanation like this: We gladly accept type stub contributions for third-party libraries that are published on PyPI in typeshed. To contribute a new library, please follow the steps outlined in [CONTRIBUTING.md](/python/typeshed/blob/main/CONTRIBUTING.md). The `create_baseline_stubs.py` script can be useful to create an initial version, suitable for inclusion in typeshed. That said, we don't keep requests for third-party library stubs open, unless there are issues that need to be addressed before a PR can be opened. Therefore, I'm closing this issue. + +### Asking to remove tests + + Please remove the tests. In typeshed, we only add regression tests for functions and classes which are known to have caused complex problems in the past, or where stubs are difficult to get right. 100% test coverage for typeshed is neither necessary nor desirable, as it would lead to code duplication. + + See [`tests/REGRESSION.md`](https://github.com/python/typeshed/blob/main/tests/REGRESSION.md) for more information. diff --git a/python/helpers/typeshed/pyrightconfig.stricter.json b/python/helpers/typeshed/pyrightconfig.stricter.json index 5cd12e0013b6..3c170f4fba99 100644 --- a/python/helpers/typeshed/pyrightconfig.stricter.json +++ b/python/helpers/typeshed/pyrightconfig.stricter.json @@ -40,6 +40,7 @@ "stubs/Flask-SocketIO", "stubs/fpdf2", "stubs/gdb", + "stubs/geojson", "stubs/geopandas", "stubs/google-cloud-ndb", "stubs/grpcio-channelz/grpc_channelz/v1", diff --git a/python/helpers/typeshed/requirements-tests.txt b/python/helpers/typeshed/requirements-tests.txt index 0e4d19f10cd7..4672a004e702 100644 --- a/python/helpers/typeshed/requirements-tests.txt +++ b/python/helpers/typeshed/requirements-tests.txt @@ -11,9 +11,9 @@ mypy-protobuf==5.1.0; python_version < "3.15" packaging==26.2 pathspec>=1.1.1 pre-commit +ruff==0.15.20 # Required by create_baseline_stubs.py. # stubdefaulter depends on libcst, which does not yet install cleanly on Python 3.15. -ruff==0.15.20 stubdefaulter==0.1.0; python_version < "3.15" termcolor>=2.3 tomli==2.4.1; python_version < "3.11" diff --git a/python/helpers/typeshed/stdlib/@tests/test_cases/check_tkinter.py b/python/helpers/typeshed/stdlib/@tests/test_cases/check_tkinter.py index eb344f3a234a..acb9a24ec5b1 100644 --- a/python/helpers/typeshed/stdlib/@tests/test_cases/check_tkinter.py +++ b/python/helpers/typeshed/stdlib/@tests/test_cases/check_tkinter.py @@ -24,7 +24,6 @@ def foo(x: int, y: str) -> None: root.after(1000, foo, 10, "lol") root.after(1000, foo, 10, 10) # type: ignore - # Font size must be integer label = tkinter.Label() label.config(font=("", 12)) diff --git a/python/helpers/typeshed/stdlib/asyncio/protocols.pyi b/python/helpers/typeshed/stdlib/asyncio/protocols.pyi index 3a8965f03e29..f63b9e084382 100644 --- a/python/helpers/typeshed/stdlib/asyncio/protocols.pyi +++ b/python/helpers/typeshed/stdlib/asyncio/protocols.pyi @@ -27,11 +27,9 @@ class BufferedProtocol(BaseProtocol): class DatagramProtocol(BaseProtocol): __slots__ = () def connection_made(self, transport: transports.DatagramTransport) -> None: ... # type: ignore[override] - # addr can be a tuple[int, int] for some unusual protocols like socket.AF_NETLINK. - # Use tuple[str | Any, int] to not cause typechecking issues on most usual cases. - # This could be improved by using tuple[AnyOf[str, int], int] if the AnyOf feature is accepted. - # See https://github.com/python/typing/issues/566 - def datagram_received(self, data: bytes, addr: tuple[str | Any, int]) -> None: ... + # addr is a tuple[str, int] for IPv4 or tuple[str, int, int, int] for IPv6. + # It can also be a tuple[int, int] for unusual protocols like socket.AF_NETLINK. + def datagram_received(self, data: bytes, addr: tuple[Any, ...]) -> None: ... def error_received(self, exc: Exception) -> None: ... class SubprocessProtocol(BaseProtocol): diff --git a/python/helpers/typeshed/stdlib/lib2to3/pytree.pyi b/python/helpers/typeshed/stdlib/lib2to3/pytree.pyi index 045f7882721a..f634f5065c0e 100644 --- a/python/helpers/typeshed/stdlib/lib2to3/pytree.pyi +++ b/python/helpers/typeshed/stdlib/lib2to3/pytree.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete, SupportsGetItem, SupportsLenAndGetItem, Unused +from _typeshed import SupportsGetItem, SupportsLenAndGetItem, Unused from abc import abstractmethod from collections.abc import Iterable, Iterator, MutableSequence from typing import ClassVar, Final, TypeAlias @@ -48,7 +48,7 @@ class Base: class Node(Base): fixers_applied: MutableSequence[BaseFix] | None # Is Unbound until set in refactor.RefactoringTool - future_features: frozenset[Incomplete] + future_features: frozenset[str] # Is Unbound until set in pgen2.parse.Parser.pop used_names: set[str] def __init__( diff --git a/python/helpers/typeshed/stdlib/tkinter/__init__.pyi b/python/helpers/typeshed/stdlib/tkinter/__init__.pyi index 45001cfea75a..681c6ddba546 100644 --- a/python/helpers/typeshed/stdlib/tkinter/__init__.pyi +++ b/python/helpers/typeshed/stdlib/tkinter/__init__.pyi @@ -3905,7 +3905,7 @@ class OptionMenu(Menubutton): variable: StringVar, value: str, *values: str, - command: Callable[[StringVar], object] | None = ..., + command: Callable[[str], object] | None = ..., name: str | None = None, ) -> None: ... else: @@ -3916,7 +3916,7 @@ class OptionMenu(Menubutton): variable: StringVar, value: str, *values: str, - command: Callable[[StringVar], object] | None = ..., + command: Callable[[str], object] | None = ..., ) -> None: ... # configure, config, cget are inherited from Menubutton # destroy and __getitem__ are overridden, signature does not change diff --git a/python/helpers/typeshed/stubs/Deprecated/METADATA.toml b/python/helpers/typeshed/stubs/Deprecated/METADATA.toml index 43db3066d9b7..e5fbb122e82f 100644 --- a/python/helpers/typeshed/stubs/Deprecated/METADATA.toml +++ b/python/helpers/typeshed/stubs/Deprecated/METADATA.toml @@ -1,3 +1,2 @@ version = "~=1.3.1" upstream-repository = "https://github.com/laurent-laporte-pro/deprecated" -dependencies = [] diff --git a/python/helpers/typeshed/stubs/Flask-SocketIO/METADATA.toml b/python/helpers/typeshed/stubs/Flask-SocketIO/METADATA.toml index ef14c192a276..13115c99f63b 100644 --- a/python/helpers/typeshed/stubs/Flask-SocketIO/METADATA.toml +++ b/python/helpers/typeshed/stubs/Flask-SocketIO/METADATA.toml @@ -1,3 +1,3 @@ version = "5.6.*" -dependencies = ["Flask>=0.9"] upstream-repository = "https://github.com/miguelgrinberg/flask-socketio" +dependencies = ["Flask>=0.9"] diff --git a/python/helpers/typeshed/stubs/Jetson.GPIO/METADATA.toml b/python/helpers/typeshed/stubs/Jetson.GPIO/METADATA.toml index 9afedb7c6c2b..d5b6d8358e23 100644 --- a/python/helpers/typeshed/stubs/Jetson.GPIO/METADATA.toml +++ b/python/helpers/typeshed/stubs/Jetson.GPIO/METADATA.toml @@ -1,2 +1,2 @@ -version = "2.1.12" +version = "2.1.13" upstream-repository = "https://github.com/NVIDIA/jetson-gpio" diff --git a/python/helpers/typeshed/stubs/Pygments/METADATA.toml b/python/helpers/typeshed/stubs/Pygments/METADATA.toml index 41f7ee57a067..1768af3414c0 100644 --- a/python/helpers/typeshed/stubs/Pygments/METADATA.toml +++ b/python/helpers/typeshed/stubs/Pygments/METADATA.toml @@ -1,6 +1,6 @@ version = "2.20.*" upstream-repository = "https://github.com/pygments/pygments" -dependencies = ["types-docutils"] +optional-dependencies = ["types-docutils"] partial-stub = true [tool.stubtest] diff --git a/python/helpers/typeshed/stubs/bleach/METADATA.toml b/python/helpers/typeshed/stubs/bleach/METADATA.toml index 155a221bcd9d..f43ce83e8f47 100644 --- a/python/helpers/typeshed/stubs/bleach/METADATA.toml +++ b/python/helpers/typeshed/stubs/bleach/METADATA.toml @@ -1,6 +1,6 @@ version = "6.4.*" -dependencies = ["types-html5lib"] upstream-repository = "https://github.com/mozilla/bleach" +dependencies = ["types-html5lib"] [tool.stubtest] extras = ["css"] diff --git a/python/helpers/typeshed/stubs/click-log/METADATA.toml b/python/helpers/typeshed/stubs/click-log/METADATA.toml index b0192b0669d0..af9b07a4091b 100644 --- a/python/helpers/typeshed/stubs/click-log/METADATA.toml +++ b/python/helpers/typeshed/stubs/click-log/METADATA.toml @@ -1,3 +1,3 @@ version = "0.4.*" -dependencies = ["click>=8.0.0"] upstream-repository = "https://github.com/click-contrib/click-log" +dependencies = ["click>=8.0.0"] diff --git a/python/helpers/typeshed/stubs/click-web/METADATA.toml b/python/helpers/typeshed/stubs/click-web/METADATA.toml index a0ef4e108b51..b155c1e542e9 100644 --- a/python/helpers/typeshed/stubs/click-web/METADATA.toml +++ b/python/helpers/typeshed/stubs/click-web/METADATA.toml @@ -1,3 +1,3 @@ version = "0.8.*" -dependencies = ["click>=8.0.0", "Flask>=2.3.2"] upstream-repository = "https://github.com/fredrik-corneliusson/click-web" +dependencies = ["click>=8.0.0", "Flask>=2.3.2"] diff --git a/python/helpers/typeshed/stubs/docker/METADATA.toml b/python/helpers/typeshed/stubs/docker/METADATA.toml index 3aedabd37987..70bcc93efcaa 100644 --- a/python/helpers/typeshed/stubs/docker/METADATA.toml +++ b/python/helpers/typeshed/stubs/docker/METADATA.toml @@ -1,3 +1,4 @@ version = "7.2.*" upstream-repository = "https://github.com/docker/docker-py" -dependencies = ["types-paramiko", "types-requests", "urllib3>=2"] +dependencies = ["types-requests", "urllib3>=2"] +optional-dependencies = ["types-paramiko"] diff --git a/python/helpers/typeshed/stubs/geojson/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/geojson/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000000..d3376f747930 --- /dev/null +++ b/python/helpers/typeshed/stubs/geojson/@tests/stubtest_allowlist.txt @@ -0,0 +1,3 @@ +# Stub missing OK, not part of public API +geojson.factory +geojson.examples diff --git a/python/helpers/typeshed/stubs/geojson/METADATA.toml b/python/helpers/typeshed/stubs/geojson/METADATA.toml new file mode 100644 index 000000000000..2e98409a8944 --- /dev/null +++ b/python/helpers/typeshed/stubs/geojson/METADATA.toml @@ -0,0 +1,2 @@ +version = "3.3.0" +upstream-repository = "https://github.com/jazzband/geojson" diff --git a/python/helpers/typeshed/stubs/geojson/geojson/__init__.pyi b/python/helpers/typeshed/stubs/geojson/geojson/__init__.pyi new file mode 100644 index 000000000000..a022f4f97930 --- /dev/null +++ b/python/helpers/typeshed/stubs/geojson/geojson/__init__.pyi @@ -0,0 +1,28 @@ +from geojson._version import __version__, __version_info__ +from geojson.base import GeoJSON +from geojson.codec import GeoJSONEncoder, dump, dumps, load, loads +from geojson.feature import Feature, FeatureCollection +from geojson.geometry import GeometryCollection, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon +from geojson.utils import coords, map_coords + +__all__ = [ + "dump", + "dumps", + "load", + "loads", + "GeoJSONEncoder", + "coords", + "map_coords", + "Point", + "LineString", + "Polygon", + "MultiLineString", + "MultiPoint", + "MultiPolygon", + "GeometryCollection", + "Feature", + "FeatureCollection", + "GeoJSON", + "__version__", + "__version_info__", +] diff --git a/python/helpers/typeshed/stubs/geojson/geojson/_version.pyi b/python/helpers/typeshed/stubs/geojson/geojson/_version.pyi new file mode 100644 index 000000000000..fd947dd9c0e2 --- /dev/null +++ b/python/helpers/typeshed/stubs/geojson/geojson/_version.pyi @@ -0,0 +1,2 @@ +__version__: str +__version_info__: tuple[int, ...] diff --git a/python/helpers/typeshed/stubs/geojson/geojson/base.pyi b/python/helpers/typeshed/stubs/geojson/geojson/base.pyi new file mode 100644 index 000000000000..7472837e0814 --- /dev/null +++ b/python/helpers/typeshed/stubs/geojson/geojson/base.pyi @@ -0,0 +1,17 @@ +from _typeshed import Incomplete +from collections.abc import Iterable +from typing import Any + +class GeoJSON(dict[str, Any]): + def __init__(self, iterable: Iterable[tuple[str, Any]] = (), **extra) -> None: ... + def __getattr__(self, name: str | int) -> Incomplete: ... + def __setattr__(self, name: str, value) -> None: ... + def __delattr__(self, name: str) -> None: ... + @property + def __geo_interface__(self) -> None | GeoJSON: ... + @classmethod + def to_instance(cls, ob, default=None, strict: bool = False) -> GeoJSON: ... + @property + def is_valid(self) -> bool: ... + def check_list_errors(self, checkFunc, lst) -> list[str] | None: ... + def errors(self) -> list[str] | None: ... diff --git a/python/helpers/typeshed/stubs/geojson/geojson/codec.pyi b/python/helpers/typeshed/stubs/geojson/geojson/codec.pyi new file mode 100644 index 000000000000..7b9d82f0944e --- /dev/null +++ b/python/helpers/typeshed/stubs/geojson/geojson/codec.pyi @@ -0,0 +1,33 @@ +import json +from _typeshed import SupportsRead, SupportsWrite +from collections.abc import Callable +from typing import Any +from typing_extensions import Never + +from geojson.base import GeoJSON + +class GeoJSONEncoder(json.JSONEncoder): + def default(self, obj) -> GeoJSON: ... + +def dump( + obj, fp: SupportsWrite[str], cls: type[json.JSONEncoder] | None = json.JSONEncoder, allow_nan: bool = False, **kwargs +) -> None: ... +def dumps( + obj, cls: type[json.JSONEncoder] | None = json.JSONEncoder, allow_nan: bool = False, ensure_ascii: bool = False, **kwargs +) -> str: ... +def load( + fp: SupportsRead[str], + cls: type[json.JSONDecoder] = json.JSONDecoder, + parse_constant: Callable[..., Never] = ..., + object_hook: Callable[[dict[str, Any]], GeoJSON] = GeoJSON.to_instance, + **kwargs, +) -> GeoJSON: ... +def loads( + s: str, + cls: type[json.JSONDecoder] = json.JSONDecoder, + parse_constant: Callable[..., Never] = ..., + object_hook: Callable[[dict[str, Any]], GeoJSON] = GeoJSON.to_instance, + **kwargs, +) -> GeoJSON: ... + +PyGFPEncoder = GeoJSONEncoder diff --git a/python/helpers/typeshed/stubs/geojson/geojson/feature.pyi b/python/helpers/typeshed/stubs/geojson/geojson/feature.pyi new file mode 100644 index 000000000000..41aff456863e --- /dev/null +++ b/python/helpers/typeshed/stubs/geojson/geojson/feature.pyi @@ -0,0 +1,15 @@ +from typing import Any + +from geojson.base import GeoJSON +from geojson.geometry import Geometry + +class Feature(GeoJSON): + def __init__( + self, id: None | str | int = None, geometry: None | Geometry = None, properties: None | dict[str, Any] = None, **extra + ) -> None: ... + def errors(self) -> list[str] | None: ... + +class FeatureCollection(GeoJSON): + def __init__(self, features: list[Feature | Geometry], **extra) -> None: ... + def errors(self) -> list[str] | None: ... + def __getitem__(self, key: int | str) -> Feature: ... diff --git a/python/helpers/typeshed/stubs/geojson/geojson/geometry.pyi b/python/helpers/typeshed/stubs/geojson/geojson/geometry.pyi new file mode 100644 index 000000000000..04fa942cca7f --- /dev/null +++ b/python/helpers/typeshed/stubs/geojson/geojson/geometry.pyi @@ -0,0 +1,52 @@ +from collections.abc import Sequence +from decimal import Decimal +from typing import Literal, TypeAlias + +from geojson.base import GeoJSON + +_InputCoord: TypeAlias = float | Decimal | Geometry | Sequence[_InputCoord] +_CleanCoord: TypeAlias = float | Decimal | list[_CleanCoord] + +DEFAULT_PRECISION: Literal[6] + +class Geometry(GeoJSON): + def __init__( + self, + coordinates: None | Sequence[_InputCoord] | Geometry = None, + validate: bool = False, + precision: None | int = None, + **extra, + ) -> None: ... + @classmethod + def clean_coordinates(cls, coords: Sequence[_InputCoord] | Geometry, precision: int) -> list[_CleanCoord]: ... + +class GeometryCollection(GeoJSON): + def __init__(self, geometries: Sequence[Geometry] | None = None, **extra) -> None: ... + def errors(self) -> list[str] | None: ... + def __getitem__(self, key) -> Geometry | tuple[()] | None: ... + +def check_point(coord) -> str | None: ... + +class Point(Geometry): + def errors(self) -> list[str] | None: ... + +class MultiPoint(Geometry): + def errors(self) -> list[str] | None: ... + +def check_line_string(coord) -> str | None: ... + +class LineString(Geometry): + def errors(self) -> list[str] | None: ... + +class MultiLineString(MultiPoint): + def errors(self) -> list[str] | None: ... + +def check_polygon(coord) -> str | None: ... + +class Polygon(Geometry): + def errors(self) -> list[str] | None: ... + +class MultiPolygon(Geometry): + def errors(self) -> list[str] | None: ... + +class Default: ... diff --git a/python/helpers/typeshed/stubs/geojson/geojson/mapping.pyi b/python/helpers/typeshed/stubs/geojson/geojson/mapping.pyi new file mode 100644 index 000000000000..d9b0e4900ebb --- /dev/null +++ b/python/helpers/typeshed/stubs/geojson/geojson/mapping.pyi @@ -0,0 +1,6 @@ +from typing import Any, Literal + +GEO_INTERFACE_MARKER: Literal["__geo_interface__"] + +def is_mapping(obj) -> bool: ... +def to_mapping(obj) -> dict[str, Any]: ... diff --git a/python/helpers/typeshed/stubs/geojson/geojson/utils.pyi b/python/helpers/typeshed/stubs/geojson/geojson/utils.pyi new file mode 100644 index 000000000000..9e35c35bfc81 --- /dev/null +++ b/python/helpers/typeshed/stubs/geojson/geojson/utils.pyi @@ -0,0 +1,16 @@ +from _typeshed import Incomplete +from collections.abc import Callable, Generator +from typing import Any, Literal + +from geojson.base import GeoJSON +from geojson.geometry import Geometry, LineString, Point, Polygon + +def coords(obj: GeoJSON | dict[str, Any]) -> Generator[tuple[float]]: ... +def map_coords(func: Callable[[Incomplete], float | Geometry], obj: GeoJSON | dict[str, Any]) -> dict[str, Any]: ... +def map_tuples(func: Callable[[Incomplete], float | Geometry], obj: GeoJSON | dict[str, Any]) -> dict[str, Any]: ... +def map_geometries(func: Callable[[Incomplete], float | Geometry], obj: GeoJSON | dict[str, Any]) -> dict[str, Any]: ... +def generate_random( + featureType: Literal["Point", "LineString", "Polygon"], + numberVertices: int = 3, + boundingBox: list[float] = [-180.0, -90.0, 180.0, 90.0], +) -> Point | LineString | Polygon: ... diff --git a/python/helpers/typeshed/stubs/geopandas/METADATA.toml b/python/helpers/typeshed/stubs/geopandas/METADATA.toml index 35e3c34d4ae4..653120efd9b8 100644 --- a/python/helpers/typeshed/stubs/geopandas/METADATA.toml +++ b/python/helpers/typeshed/stubs/geopandas/METADATA.toml @@ -1,7 +1,7 @@ -# Requires a version of numpy with a `py.typed` file version = "1.1.4" -dependencies = ["numpy>=1.20", "pandas-stubs", "types-shapely", "pyproj"] upstream-repository = "https://github.com/geopandas/geopandas" +# Requires a version of numpy with a `py.typed` file +dependencies = ["numpy>=1.20", "pandas-stubs", "types-shapely", "pyproj"] [tool.stubtest] # libproj-dev and proj-bin are required to build pyproj if wheels for the diff --git a/python/helpers/typeshed/stubs/grpcio/METADATA.toml b/python/helpers/typeshed/stubs/grpcio/METADATA.toml index f3cfbb32e927..83fb9bd9533b 100644 --- a/python/helpers/typeshed/stubs/grpcio/METADATA.toml +++ b/python/helpers/typeshed/stubs/grpcio/METADATA.toml @@ -1,4 +1,4 @@ -version = "~= 1.82.1" +version = "~= 1.83.0" upstream-repository = "https://github.com/grpc/grpc" partial-stub = true diff --git a/python/helpers/typeshed/stubs/grpcio/grpc/aio/__init__.pyi b/python/helpers/typeshed/stubs/grpcio/grpc/aio/__init__.pyi index 13d347569d1b..4703a0864a0f 100644 --- a/python/helpers/typeshed/stubs/grpcio/grpc/aio/__init__.pyi +++ b/python/helpers/typeshed/stubs/grpcio/grpc/aio/__init__.pyi @@ -28,6 +28,7 @@ from grpc import ( RpcError, RpcMethodHandler, ServerCredentials, + Status, StatusCode, _Options, ) @@ -279,6 +280,8 @@ class ServicerContext(Generic[_TRequest, _TResponse], metaclass=abc.ABCMeta): async def send_initial_metadata(self, initial_metadata: _MetadataType) -> None: ... def add_done_callback(self, callback: _DoneCallback[_TRequest, _TResponse]) -> None: ... @abc.abstractmethod + async def abort_with_status(self, status: Status) -> Never: ... + @abc.abstractmethod def set_trailing_metadata(self, trailing_metadata: _MetadataType) -> None: ... @abc.abstractmethod def invocation_metadata(self) -> Metadata | None: ... diff --git a/python/helpers/typeshed/stubs/gunicorn/METADATA.toml b/python/helpers/typeshed/stubs/gunicorn/METADATA.toml index 3e4de3113f9f..3725c9c6add0 100644 --- a/python/helpers/typeshed/stubs/gunicorn/METADATA.toml +++ b/python/helpers/typeshed/stubs/gunicorn/METADATA.toml @@ -1,6 +1,6 @@ version = "26.0.0" upstream-repository = "https://github.com/benoitc/gunicorn" -dependencies = ["types-gevent"] +optional-dependencies = ["types-gevent"] [tool.stubtest] supported-platforms = ["linux", "darwin"] diff --git a/python/helpers/typeshed/stubs/hnswlib/METADATA.toml b/python/helpers/typeshed/stubs/hnswlib/METADATA.toml index f9dfc34c413b..df04086d96d4 100644 --- a/python/helpers/typeshed/stubs/hnswlib/METADATA.toml +++ b/python/helpers/typeshed/stubs/hnswlib/METADATA.toml @@ -1,4 +1,9 @@ version = "0.8.*" +upstream-repository = "https://github.com/nmslib/hnswlib" # Requires a version of numpy with a `py.typed` file dependencies = ["numpy>=1.21"] -upstream-repository = "https://github.com/nmslib/hnswlib" + +[tool.stubtest] +# TODO: stubtest fails on Linux because it gets killed with a SIGILL +# for unknown reasons. See https://github.com/python/typeshed/issues/16100 +ci-platforms = ["darwin"] diff --git a/python/helpers/typeshed/stubs/hvac/hvac/api/secrets_engines/kv_v1.pyi b/python/helpers/typeshed/stubs/hvac/hvac/api/secrets_engines/kv_v1.pyi index 3a9fc7072ac9..68117f2bdddb 100644 --- a/python/helpers/typeshed/stubs/hvac/hvac/api/secrets_engines/kv_v1.pyi +++ b/python/helpers/typeshed/stubs/hvac/hvac/api/secrets_engines/kv_v1.pyi @@ -1,3 +1,5 @@ +from typing import Any + from hvac.api.vault_api_base import VaultApiBase DEFAULT_MOUNT_POINT: str @@ -6,6 +8,6 @@ class KvV1(VaultApiBase): def read_secret(self, path: str, mount_point: str = "secret"): ... def list_secrets(self, path: str, mount_point: str = "secret"): ... def create_or_update_secret( - self, path: str, secret: dict[str, str], method: str | None = None, mount_point: str = "secret" + self, path: str, secret: dict[str, Any], method: str | None = None, mount_point: str = "secret" ): ... def delete_secret(self, path: str, mount_point: str = "secret"): ... diff --git a/python/helpers/typeshed/stubs/hvac/hvac/api/secrets_engines/kv_v2.pyi b/python/helpers/typeshed/stubs/hvac/hvac/api/secrets_engines/kv_v2.pyi index 7dcfdfb16748..6e838ffd152f 100644 --- a/python/helpers/typeshed/stubs/hvac/hvac/api/secrets_engines/kv_v2.pyi +++ b/python/helpers/typeshed/stubs/hvac/hvac/api/secrets_engines/kv_v2.pyi @@ -1,3 +1,5 @@ +from typing import Any + from hvac.api.vault_api_base import VaultApiBase DEFAULT_MOUNT_POINT: str @@ -15,7 +17,7 @@ class KvV2(VaultApiBase): def read_secret_version( self, path: str, version: int | None = None, mount_point: str = "secret", raise_on_deleted_version: bool | None = None ): ... - def create_or_update_secret(self, path: str, secret: dict[str, str], cas: int | None = None, mount_point: str = "secret"): ... + def create_or_update_secret(self, path: str, secret: dict[str, Any], cas: int | None = None, mount_point: str = "secret"): ... def patch(self, path: str, secret: dict[str, str], mount_point: str = "secret"): ... def delete_latest_version_of_secret(self, path: str, mount_point: str = "secret"): ... def delete_secret_versions(self, path: str, versions: list[int], mount_point: str = "secret"): ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/distance_measures.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/distance_measures.pyi index 06ecfd181cc2..f52a300f8f66 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/distance_measures.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/distance_measures.pyi @@ -5,4 +5,4 @@ from numpy.random import RandomState __all__ = ["diameter"] @_dispatchable -def diameter(G: Graph[_Node], seed: int | RandomState | None = None): ... +def diameter(G: Graph[_Node], seed: int | RandomState | None = None) -> int: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi index af1c01f9ec8e..4518df47f2a1 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi @@ -9,8 +9,8 @@ __all__ = ["randomized_partitioning", "one_exchange"] @_dispatchable def randomized_partitioning( G: Graph[_Node], seed: int | RandomState | None = None, p: float = 0.5, weight: str | None = None -): ... +) -> tuple[float, tuple[set[Incomplete], set[Incomplete]]]: ... @_dispatchable def one_exchange( G: Graph[_Node], initial_cut: set[Incomplete] | None = None, seed: int | RandomState | None = None, weight: str | None = None -): ... +) -> tuple[float, tuple[set[Incomplete], set[Incomplete]]]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/ramsey.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/ramsey.pyi index cd8d97f11cbe..f1248ef9d101 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/ramsey.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/ramsey.pyi @@ -1,7 +1,9 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["ramsey_R2"] @_dispatchable -def ramsey_R2(G: Graph[_Node]): ... +def ramsey_R2(G: Graph[_Node]) -> tuple[set[Incomplete], set[Incomplete]]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi index b4acded8791a..4f761fa97e24 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi @@ -11,6 +11,8 @@ __all__ = ["metric_closure", "steiner_tree"] @deprecated( "`metric_closure` is deprecated and will be removed in NetworkX 3.8. Use `networkx.all_pairs_shortest_path_length` instead." ) -def metric_closure(G: Graph[_Node], weight="weight"): ... +def metric_closure(G: Graph[_Node], weight="weight") -> Graph[Incomplete]: ... @_dispatchable -def steiner_tree(G: Graph[_Node], terminal_nodes: Iterable[Incomplete], weight: str = "weight", method: str | None = None): ... +def steiner_tree( + G: Graph[_Node], terminal_nodes: Iterable[Incomplete], weight: str = "weight", method: str | None = None +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi index eaff9c69cc07..3c388b8d6677 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi @@ -30,30 +30,32 @@ def traveling_salesman_problem( cycle: bool = True, method: Callable[..., Incomplete] | None = None, **kwargs, -): ... +) -> list[Incomplete]: ... @_dispatchable def asadpour_atsp( G: DiGraph[_Node], weight: str | None = "weight", seed: int | RandomState | None = None, source: str | None = None -): ... +) -> list[Incomplete]: ... @_dispatchable -def held_karp_ascent(G: Graph[_Node], weight="weight"): ... +def held_karp_ascent( + G: Graph[_Node], weight: str = "weight" +) -> tuple[float, dict[Incomplete, Incomplete] | Graph[Incomplete]]: ... @_dispatchable def spanning_tree_distribution(G: Graph[_Node], z: Mapping[Incomplete, Incomplete]) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def greedy_tsp(G: Graph[_Node], weight: str | None = "weight", source=None): ... +def greedy_tsp(G: Graph[_Node], weight: str | None = "weight", source=None) -> list[Incomplete]: ... @_dispatchable def simulated_annealing_tsp( G: Graph[_Node], - init_cycle, + init_cycle: Literal["greedy"] | Iterable[Incomplete], weight: str | None = "weight", source=None, temp: int | None = 100, - move="1-1", + move: Callable[..., Incomplete] | Literal["1-1", "1-0"] = "1-1", max_iterations: int | None = 10, N_inner: int | None = 100, - alpha=0.01, + alpha: float = 0.01, seed: int | RandomState | None = None, -): ... +) -> list[Incomplete]: ... @_dispatchable def threshold_accepting_tsp( G: Graph[_Node], @@ -61,9 +63,9 @@ def threshold_accepting_tsp( weight: str | None = "weight", source=None, threshold: int | None = 1, - move="1-1", + move: Callable[..., Incomplete] | Literal["1-1", "1-0"] = "1-1", max_iterations: int | None = 10, N_inner: int | None = 100, - alpha=0.1, + alpha: float = 0.1, seed: int | RandomState | None = None, -): ... +) -> list[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi index 1650588a9d73..ef4764e3d59d 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Iterable, Mapping +import numpy as np from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -17,7 +18,7 @@ def attribute_mixing_matrix( nodes: Iterable[Incomplete] | None = None, mapping: Mapping[Incomplete, Incomplete] | None = None, normalized: bool = True, -): ... +) -> np.ndarray[Incomplete, Incomplete]: ... @_dispatchable def degree_mixing_dict( G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes=None, normalized: bool = False @@ -31,6 +32,6 @@ def degree_mixing_matrix( nodes: Iterable[Incomplete] | None = None, normalized: bool = True, mapping: Mapping[Incomplete, Incomplete] | None = None, -): ... +) -> np.ndarray[Incomplete, Incomplete]: ... @_dispatchable -def mixing_dict(xy, normalized: bool = False) -> dict[Incomplete, Incomplete]: ... +def mixing_dict(xy: Iterable[tuple[Incomplete, Incomplete]], normalized: bool = False) -> dict[Incomplete, Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/basic.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/basic.pyi index afba78f9fdfc..8610070f70ce 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/basic.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/basic.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Iterable +from collections.abc import Collection, Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -15,6 +15,6 @@ def is_bipartite_node_set(G: Graph[_Node], nodes: Iterable[Incomplete]) -> bool: @_dispatchable def sets(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None) -> tuple[set[Incomplete], set[Incomplete]]: ... @_dispatchable -def density(B: Graph[_Node], nodes) -> float: ... +def density(B: Graph[_Node], nodes: Collection[Incomplete]) -> float: ... @_dispatchable -def degrees(B: Graph[_Node], nodes, weight: str | None = None) -> tuple[Incomplete, Incomplete]: ... +def degrees(B: Graph[_Node], nodes: Iterable[Incomplete], weight: str | None = None) -> tuple[Incomplete, Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi index 529287ee87d7..90ac03059f80 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,8 +7,10 @@ from networkx.utils.backends import _dispatchable __all__ = ["degree_centrality", "betweenness_centrality", "closeness_centrality"] @_dispatchable -def degree_centrality(G: Graph[_Node], nodes) -> dict[Incomplete, Incomplete]: ... +def degree_centrality(G: Graph[_Node], nodes: Iterable[Incomplete]) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def betweenness_centrality(G: Graph[_Node], nodes) -> dict[Incomplete, Incomplete]: ... +def betweenness_centrality(G: Graph[_Node], nodes: Iterable[Incomplete]) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def closeness_centrality(G: Graph[_Node], nodes, normalized: bool | None = True) -> dict[Incomplete, Incomplete]: ... +def closeness_centrality( + G: Graph[_Node], nodes: Iterable[Incomplete], normalized: bool | None = True +) -> dict[Incomplete, Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi index a80cc0fc6e36..de80e3d56b41 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi @@ -1,4 +1,5 @@ -from collections.abc import Generator +from _typeshed import Incomplete, StrPath, SupportsRead, SupportsWrite +from collections.abc import Collection, Generator, Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -7,27 +8,32 @@ __all__ = ["generate_edgelist", "write_edgelist", "parse_edgelist", "read_edgeli @_dispatchable def write_edgelist( - G: Graph[_Node], path, comments: str = "#", delimiter: str = " ", data: bool = True, encoding: str = "utf-8" + G: Graph[_Node], + path: StrPath | SupportsWrite[bytes], + comments: str = "#", + delimiter: str = " ", + data: bool = True, + encoding: str = "utf-8", ) -> None: ... @_dispatchable def generate_edgelist(G: Graph[_Node], delimiter: str = " ", data: bool = True) -> Generator[str]: ... @_dispatchable def parse_edgelist( - lines, + lines: Iterable[str], comments: str | None = "#", delimiter: str | None = None, - create_using: Graph[_Node] | None = None, - nodetype=None, - data=True, -): ... + create_using: Graph[_Node] | type[Graph[_Node]] | None = None, + nodetype: type[Incomplete] | None = None, + data: bool | Collection[tuple[str, type[Incomplete]]] = True, +) -> Graph[Incomplete]: ... @_dispatchable def read_edgelist( - path, + path: StrPath | SupportsRead[bytes], comments: str | None = "#", delimiter: str | None = None, - create_using=None, + create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None, nodetype=None, - data=True, + data: bool | Collection[tuple[str, type[Incomplete]]] = True, edgetype=None, encoding: str | None = "utf-8", -): ... +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/extendability.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/extendability.pyi index 155cb1cb05b3..3269743ce9c2 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/extendability.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/extendability.pyi @@ -4,4 +4,4 @@ from networkx.utils.backends import _dispatchable __all__ = ["maximal_extendability"] @_dispatchable -def maximal_extendability(G: Graph[_Node]): ... +def maximal_extendability(G: Graph[_Node]) -> int: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/generators.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/generators.pyi index f9aef242b895..cf5b9686cfb9 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/generators.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/generators.pyi @@ -17,27 +17,32 @@ __all__ = [ ] @_dispatchable -def complete_bipartite_graph(n1, n2, create_using: Graph[_Node] | None = None): ... +def complete_bipartite_graph(n1, n2, create_using: Graph[_Node] | type[Graph[_Node]] | None = None): ... @_dispatchable def configuration_model( aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], - create_using: Graph[_Node] | None = None, + create_using: Graph[_Node] | type[Graph[_Node]] | None = None, seed: int | RandomState | None = None, ): ... @_dispatchable -def havel_hakimi_graph(aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | None = None): ... +def havel_hakimi_graph( + aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | type[Graph[_Node]] | None = None +): ... @_dispatchable def reverse_havel_hakimi_graph( - aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | None = None + aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | type[Graph[_Node]] | None = None ): ... @_dispatchable def alternating_havel_hakimi_graph( - aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | None = None + aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | type[Graph[_Node]] | None = None ): ... @_dispatchable def preferential_attachment_graph( - aseq: Iterable[Incomplete], p: float, create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None + aseq: Iterable[Incomplete], + p: float, + create_using: Graph[_Node] | type[Graph[_Node]] | None = None, + seed: int | RandomState | None = None, ): ... @_dispatchable def random_graph(n: int, m: int, p: float, seed: int | RandomState | None = None, directed: bool | None = False): ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/matching.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/matching.pyi index 49c12489affe..d0df0b6da990 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/matching.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/matching.pyi @@ -13,7 +13,7 @@ def eppstein_matching(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = @_dispatchable def to_vertex_cover( G: Graph[_Node], matching: Mapping[Incomplete, Incomplete], top_nodes: Iterable[Incomplete] | None = None -): ... +) -> set[Incomplete]: ... maximum_matching = hopcroft_karp_matching diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi index 1a94c1310801..18bca470ca7f 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Iterable +import numpy as np from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -11,16 +12,16 @@ def biadjacency_matrix( G: Graph[_Node], row_order: Iterable[_Node], column_order: Iterable[Incomplete] | None = None, - dtype=None, + dtype: np.dtype[Incomplete] | None = None, weight: str | None = "weight", - format="csr", + format: str = "csr", ): ... # Return is a complex union of scipy classes depending on the format param @_dispatchable def from_biadjacency_matrix( A, - create_using: Graph[_Node] | None = None, + create_using: Graph[_Node] | type[Graph[_Node]] | None = None, edge_attribute: str = "weight", *, row_order: Iterable[Incomplete] | None = None, column_order: Iterable[Incomplete] | None = None, -): ... +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/projection.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/projection.pyi index 9f1fd27d3880..3d383557dbf5 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/projection.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/projection.pyi @@ -13,14 +13,14 @@ __all__ = [ ] @_dispatchable -def projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], multigraph: bool = False): ... +def projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], multigraph: bool = False) -> Graph[Incomplete]: ... @_dispatchable -def weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], ratio: bool = False): ... +def weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], ratio: bool = False) -> Graph[Incomplete]: ... @_dispatchable -def collaboration_weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete]): ... +def collaboration_weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete]) -> Graph[Incomplete]: ... @_dispatchable -def overlap_weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], jaccard: bool = True): ... +def overlap_weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], jaccard: bool = True) -> Graph[Incomplete]: ... @_dispatchable def generic_weighted_projected_graph( B: Graph[_Node], nodes: Iterable[Incomplete], weight_function: Callable[..., Incomplete] | None = None -): ... +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi index 462e8fef2d73..e7102d54aefe 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,4 +7,6 @@ from networkx.utils.backends import _dispatchable __all__ = ["spectral_bipartivity"] @_dispatchable -def spectral_bipartivity(G: Graph[_Node], nodes=None, weight: str = "weight") -> float | dict[Incomplete, Incomplete]: ... +def spectral_bipartivity( + G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, weight: str = "weight" +) -> float | dict[Incomplete, Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/group.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/group.pyi index 1e0c00b226c5..3a5e6b880783 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/group.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/group.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Iterable +from collections.abc import Collection, Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -15,8 +15,12 @@ __all__ = [ @_dispatchable def group_betweenness_centrality( - G: Graph[_Node], C, normalized: bool | None = True, weight: str | None = None, endpoints: bool | None = False -): ... + G: Graph[_Node], + C: Collection[Incomplete], + normalized: bool | None = True, + weight: str | None = None, + endpoints: bool | None = False, +) -> list[float] | float: ... @_dispatchable def prominent_group( G: Graph[_Node], diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi index b68497906824..fa270ac3847c 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Collection from networkx.classes.graph import Graph, _Node @@ -13,4 +14,4 @@ def laplacian_centrality( weight: str | None = "weight", walk_type: str | None = None, alpha: float = 0.95, -): ... +) -> dict[Incomplete, Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/load.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/load.pyi index d59db805b08f..30677a841399 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/load.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/centrality/load.pyi @@ -13,4 +13,4 @@ def newman_betweenness_centrality( load_centrality = newman_betweenness_centrality @_dispatchable -def edge_load_centrality(G: Graph[_Node], cutoff: bool | None = False): ... +def edge_load_centrality(G: Graph[_Node], cutoff: bool | None = False) -> dict[tuple[Incomplete, Incomplete], int]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/clique.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/clique.pyi index c9ad22af6625..225fc56a64e6 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/clique.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/clique.pyi @@ -24,13 +24,13 @@ def find_cliques(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None) -> def find_cliques_recursive(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None) -> Iterator[list[_Node]]: ... @_dispatchable def make_max_clique_graph( - G: Graph[_Node], create_using: Graph[_Node, _NodeData, _EdgeData] | None = None + G: Graph[_Node], create_using: Graph[_Node, _NodeData, _EdgeData] | type[Graph[_Node, _NodeData, _EdgeData]] | None = None ) -> Graph[_Node, _NodeData, _EdgeData]: ... @_dispatchable def make_clique_bipartite( G: Graph[_Node, _NodeData, _EdgeData], fpos: bool | None = None, - create_using: Graph[_Node, _NodeData, _EdgeData] | None = None, + create_using: Graph[_Node, _NodeData, _EdgeData] | type[Graph[_Node, _NodeData, _EdgeData]] | None = None, name=None, ) -> Graph[_Node]: ... @@ -41,9 +41,11 @@ def node_clique_number( @overload def node_clique_number(G: Graph[_Node], nodes=None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False) -> int: ... -def number_of_cliques(G: Graph[_Node], nodes=None, cliques=None) -> int | dict[Incomplete, Incomplete]: ... +def number_of_cliques( + G: Graph[_Node], nodes: list[_Node] | _Node | None = None, cliques: Iterable[Incomplete] | None = None +) -> int | dict[Incomplete, Incomplete]: ... @_dispatchable -def max_weight_clique(G: Graph[_Node], weight="weight") -> tuple[list[Incomplete], int]: ... +def max_weight_clique(G: Graph[_Node], weight: str | None = "weight") -> tuple[list[Incomplete], int]: ... class MaxWeightClique: G: Graph[Incomplete] diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/cluster.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/cluster.pyi index d04b17d420e1..ba66252cac44 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/cluster.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/cluster.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections import Counter from collections.abc import Generator, Iterable from networkx.classes.graph import Graph, _NBunch, _Node @@ -29,4 +30,6 @@ def transitivity(G: Graph[_Node]) -> float: ... @_dispatchable def square_clustering(G: Graph[_Node], nodes: Iterable[_Node] | None = None) -> float | int | dict[Incomplete, float | int]: ... @_dispatchable -def generalized_degree(G: Graph[_Node], nodes: Iterable[_Node] | None = None): ... +def generalized_degree( + G: Graph[_Node], nodes: Iterable[_Node] | None = None +) -> Counter[Incomplete] | dict[Incomplete, Counter[Incomplete]]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi index dffd5c269c0e..bae8b30ab4f1 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi @@ -20,4 +20,4 @@ def move_witnesses(src_color, dst_color, N, H, F, C, T_cal, L): ... def pad_graph(G: Graph[_Node], num_colors): ... def procedure_P(V_minus, V_plus, N, H, F, C, L, excluded_colors=None): ... @_dispatchable -def equitable_color(G: Graph[_Node], num_colors): ... +def equitable_color(G: Graph[_Node], num_colors: int) -> dict[Incomplete, Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi index c2b6ea607e7c..d3287b494edd 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete, Unused from collections.abc import Callable, Generator -from typing import Final +from typing import Final, Literal from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -37,4 +37,21 @@ def strategy_saturation_largest_first(G: Graph[_Node], colors) -> Generator[Inco STRATEGIES: Final[dict[str, Callable[..., Incomplete]]] @_dispatchable -def greedy_color(G: Graph[_Node], strategy="largest_first", interchange: bool = False): ... +def greedy_color( + G: Graph[_Node], + strategy: ( + Callable[..., Incomplete] + | Literal[ + "largest_first", + "random_sequential", + "smallest_last", + "independent_set", + "connected_sequential_bfs", + "connected_sequential_dfs", + "connected_sequential", + "saturation_largest_first", + "DSATUR", + ] + ) = "largest_first", + interchange: bool = False, +) -> dict[Incomplete, Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/kclique.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/kclique.pyi index a12cf98d4ba7..f3fecef092a1 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/kclique.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/kclique.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Generator, Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -7,4 +7,4 @@ from networkx.utils.backends import _dispatchable __all__ = ["k_clique_communities"] @_dispatchable -def k_clique_communities(G: Graph[_Node], k: int, cliques=None) -> Generator[Incomplete]: ... +def k_clique_communities(G: Graph[_Node], k: int, cliques: Iterable[Incomplete] | None = None) -> Generator[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/leiden.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/leiden.pyi index 6c6d88e39681..2cf5052c1229 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/leiden.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/leiden.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState @@ -11,7 +13,7 @@ def leiden_communities( resolution: float = 1, max_level: int | None = None, seed: int | RandomState | None = None, -): ... +) -> list[Incomplete]: ... @_dispatchable def leiden_partitions( G: Graph[_Node], weight: str | None = "weight", resolution: float = 1, seed: int | RandomState | None = None diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/lukes.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/lukes.pyi index c5ebcacdc47c..da43a5a29eb8 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/lukes.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/lukes.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from typing import Final from networkx.classes.graph import Graph, _Node @@ -13,4 +14,4 @@ PKEY: Final = "partitions" CLUSTER_EVAL_CACHE_SIZE: Final = 2048 @_dispatchable -def lukes_partitioning(G: Graph[_Node], max_size: int, node_weight=None, edge_weight=None): ... +def lukes_partitioning(G: Graph[_Node], max_size: int, node_weight=None, edge_weight=None) -> list[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/modularity_max.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/modularity_max.pyi index 701054c23e97..977fe8b70630 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/modularity_max.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/modularity_max.pyi @@ -10,4 +10,6 @@ def greedy_modularity_communities( G: Graph[_Node], weight: str | None = None, resolution: float | None = 1, cutoff: int | None = 1, best_n: int | None = None ) -> list[set[Incomplete]] | list[frozenset[Incomplete]]: ... @_dispatchable -def naive_greedy_modularity_communities(G: Graph[_Node], resolution: float = 1, weight: str | None = None): ... +def naive_greedy_modularity_communities( + G: Graph[_Node], resolution: float = 1, weight: str | None = None +) -> list[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/quality.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/quality.pyi index 8ded6a641250..98aa38954f00 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/quality.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/community/quality.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Iterable + from networkx.classes.graph import Graph, _Node from networkx.exception import NetworkXError from networkx.utils.backends import _dispatchable @@ -11,12 +14,14 @@ class NotAPartition(NetworkXError): require_partition: argmap @_dispatchable -def intra_community_edges(G: Graph[_Node], partition): ... +def intra_community_edges(G: Graph[_Node], partition: Iterable[Incomplete]): ... @_dispatchable -def inter_community_edges(G: Graph[_Node], partition): ... +def inter_community_edges(G: Graph[_Node], partition: Iterable[Incomplete]): ... @_dispatchable -def inter_community_non_edges(G: Graph[_Node], partition): ... +def inter_community_non_edges(G: Graph[_Node], partition: Iterable[Incomplete]): ... @_dispatchable -def modularity(G: Graph[_Node], communities, weight: str | None = "weight", resolution: float = 1): ... +def modularity( + G: Graph[_Node], communities: Iterable[set[Incomplete]], weight: str | None = "weight", resolution: float = 1 +) -> float: ... @_dispatchable -def partition_quality(G: Graph[_Node], partition): ... +def partition_quality(G: Graph[_Node], partition: Iterable[Incomplete]) -> tuple[float, float]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index db0c3a574e95..b29620946b71 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete, SupportsGetItem -from collections.abc import Generator +from collections.abc import Collection, Generator, Iterable from typing import NamedTuple from networkx.classes.graph import Graph, _Node @@ -20,11 +20,22 @@ def k_edge_augmentation( partial: bool = False, ) -> Generator[tuple[_Node, _Node]]: ... @_dispatchable -def partial_k_edge_augmentation(G: Graph[_Node], k, avail, weight: str | None = None): ... +def partial_k_edge_augmentation( + G: Graph[_Node], k: int, avail: dict[Incomplete, Incomplete] | Collection[tuple[Incomplete, ...]], weight: str | None = None +): ... @_dispatchable -def one_edge_augmentation(G: Graph[_Node], avail=None, weight: str | None = None, partial: bool = False): ... +def one_edge_augmentation( + G: Graph[_Node], + avail: dict[Incomplete, Incomplete] | Collection[tuple[Incomplete, ...]] | None = None, + weight: str | None = None, + partial: bool = False, +): ... @_dispatchable -def bridge_augmentation(G: Graph[_Node], avail=None, weight: str | None = None): ... +def bridge_augmentation( + G: Graph[_Node], + avail: dict[Incomplete, Incomplete] | Collection[tuple[Incomplete, ...]] | None = None, + weight: str | None = None, +): ... class MetaEdge(NamedTuple): meta_uv: Incomplete @@ -34,14 +45,27 @@ class MetaEdge(NamedTuple): @_dispatchable def unconstrained_one_edge_augmentation(G: Graph[_Node]): ... @_dispatchable -def weighted_one_edge_augmentation(G: Graph[_Node], avail, weight: str | None = None, partial: bool = False): ... +def weighted_one_edge_augmentation( + G: Graph[_Node], + avail: dict[Incomplete, Incomplete] | Collection[tuple[Incomplete, ...]], + weight: str | None = None, + partial: bool = False, +): ... @_dispatchable def unconstrained_bridge_augmentation(G: Graph[_Node]): ... @_dispatchable -def weighted_bridge_augmentation(G: Graph[_Node], avail, weight: str | None = None): ... +def weighted_bridge_augmentation( + G: Graph[_Node], avail: dict[Incomplete, Incomplete] | Collection[tuple[Incomplete, ...]], weight: str | None = None +): ... @_dispatchable -def collapse(G: Graph[_Node], grouped_nodes): ... +def collapse(G: Graph[_Node], grouped_nodes: Iterable[Incomplete]) -> Graph[Incomplete]: ... @_dispatchable def complement_edges(G: Graph[_Node]): ... @_dispatchable -def greedy_k_edge_augmentation(G: Graph[_Node], k, avail=None, weight: str | None = None, seed=None): ... +def greedy_k_edge_augmentation( + G: Graph[_Node], + k: int, + avail: dict[Incomplete, Incomplete] | Collection[tuple[Incomplete, ...]] | None = None, + weight: str | None = None, + seed=None, +): ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi index 2f5f91987f9c..f35a458714dd 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi @@ -7,9 +7,9 @@ from networkx.utils.backends import _dispatchable __all__ = ["k_edge_components", "k_edge_subgraphs", "bridge_components", "EdgeComponentAuxGraph"] @_dispatchable -def k_edge_components(G: Graph[_Node], k: int): ... +def k_edge_components(G: Graph[_Node], k: int) -> Generator[set[Incomplete]]: ... @_dispatchable -def k_edge_subgraphs(G: Graph[_Node], k: int): ... +def k_edge_subgraphs(G: Graph[_Node], k: int) -> Generator[Incomplete, Incomplete, Incomplete]: ... @_dispatchable def bridge_components(G: Graph[_Node]) -> Generator[Incomplete, Incomplete]: ... @@ -23,4 +23,4 @@ class EdgeComponentAuxGraph: def k_edge_subgraphs(self, k: int) -> Generator[Incomplete, Incomplete]: ... @_dispatchable -def general_k_edge_subgraphs(G: Graph[_Node], k): ... +def general_k_edge_subgraphs(G: Graph[_Node], k: int): ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/stoerwagner.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/stoerwagner.pyi index 501e5bf82c88..e06ceda6d62d 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/stoerwagner.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/connectivity/stoerwagner.pyi @@ -1,7 +1,11 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["stoer_wagner"] @_dispatchable -def stoer_wagner(G: Graph[_Node], weight: str = "weight", heap: type = ...): ... +def stoer_wagner( + G: Graph[_Node], weight: str = "weight", heap: type = ... +) -> tuple[int | float, tuple[list[Incomplete], list[Incomplete]]]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/core.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/core.pyi index f24963a9b307..f32aade116df 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/core.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/core.pyi @@ -9,14 +9,20 @@ __all__ = ["core_number", "k_core", "k_shell", "k_crust", "k_corona", "k_truss", @_dispatchable def core_number(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def k_core(G: Graph[_Node], k: int | None = None, core_number: Mapping[Incomplete, Incomplete] | None = None): ... +def k_core( + G: Graph[_Node], k: int | None = None, core_number: Mapping[Incomplete, Incomplete] | None = None +) -> Graph[Incomplete]: ... @_dispatchable -def k_shell(G: Graph[_Node], k: int | None = None, core_number: Mapping[Incomplete, Incomplete] | None = None): ... +def k_shell( + G: Graph[_Node], k: int | None = None, core_number: Mapping[Incomplete, Incomplete] | None = None +) -> Graph[Incomplete]: ... @_dispatchable -def k_crust(G: Graph[_Node], k: int | None = None, core_number: Mapping[Incomplete, Incomplete] | None = None): ... +def k_crust( + G: Graph[_Node], k: int | None = None, core_number: Mapping[Incomplete, Incomplete] | None = None +) -> Graph[Incomplete]: ... @_dispatchable -def k_corona(G: Graph[_Node], k: int | None, core_number: Mapping[Incomplete, Incomplete] | None = None): ... +def k_corona(G: Graph[_Node], k: int | None, core_number: Mapping[Incomplete, Incomplete] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def k_truss(G: Graph[_Node], k: int): ... +def k_truss(G: Graph[_Node], k: int) -> Graph[Incomplete]: ... @_dispatchable def onion_layers(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/cuts.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/cuts.pyi index be3f75e20529..4d16d5f516ac 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/cuts.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/cuts.pyi @@ -15,18 +15,22 @@ __all__ = [ ] @_dispatchable -def cut_size(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] | None = None, weight: str | None = None): ... +def cut_size(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] | None = None, weight: str | None = None) -> float: ... @_dispatchable -def volume(G: Graph[_Node], S: Iterable[_Node], weight: str | None = None): ... +def volume(G: Graph[_Node], S: Iterable[_Node], weight: str | None = None) -> float: ... @_dispatchable -def normalized_cut_size(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] | None = None, weight: str | None = None): ... +def normalized_cut_size( + G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] | None = None, weight: str | None = None +) -> float: ... @_dispatchable -def conductance(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] | None = None, weight: str | None = None): ... +def conductance(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] | None = None, weight: str | None = None) -> float: ... @_dispatchable -def edge_expansion(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] | None = None, weight: str | None = None): ... +def edge_expansion(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] | None = None, weight: str | None = None) -> float: ... @_dispatchable -def mixing_expansion(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] | None = None, weight: str | None = None): ... +def mixing_expansion( + G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] | None = None, weight: str | None = None +) -> float: ... @_dispatchable -def node_expansion(G: Graph[_Node], S: Iterable[_Node]): ... +def node_expansion(G: Graph[_Node], S: Iterable[_Node]) -> float: ... @_dispatchable -def boundary_expansion(G: Graph[_Node], S: Iterable[_Node]): ... +def boundary_expansion(G: Graph[_Node], S: Iterable[_Node]) -> float: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/d_separation.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/d_separation.pyi index 8b3dec50ae09..7904fb9cd3a9 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/d_separation.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/d_separation.pyi @@ -9,7 +9,9 @@ __all__ = ["is_d_separator", "is_minimal_d_separator", "find_minimal_d_separator @_dispatchable def is_d_separator(G: DiGraph[_Node], x: _Node | set[_Node], y: _Node | set[_Node], z: _Node | set[_Node]) -> bool: ... @_dispatchable -def find_minimal_d_separator(G: DiGraph[_Node], x, y, *, included=None, restricted=None) -> set[Incomplete] | None: ... +def find_minimal_d_separator( + G: DiGraph[_Node], x: set[Incomplete] | Incomplete, y: set[Incomplete] | Incomplete, *, included=None, restricted=None +) -> set[Incomplete] | None: ... @_dispatchable def is_minimal_d_separator( G: DiGraph[_Node], diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/dag.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/dag.pyi index 58e1bce57ca6..62b93319e8b1 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/dag.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/dag.pyi @@ -40,7 +40,9 @@ def all_topological_sorts(G: DiGraph[_Node]) -> Generator[list[_Node]]: ... @_dispatchable def is_aperiodic(G: DiGraph[_Node]) -> bool: ... @_dispatchable -def transitive_closure(G: Graph[_Node, _NodeData, _EdgeData], reflexive=False) -> Graph[_Node, _NodeData, _EdgeData]: ... +def transitive_closure( + G: Graph[_Node, _NodeData, _EdgeData], reflexive: bool | None = False +) -> Graph[_Node, _NodeData, _EdgeData]: ... @_dispatchable def transitive_closure_dag( G: DiGraph[_Node, _NodeData, _EdgeData], topo_order: Iterable[Incomplete] | None = None diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/dominance.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/dominance.pyi index 76b3ed977bc9..acc979d8d9ab 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/dominance.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/dominance.pyi @@ -1,9 +1,11 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["immediate_dominators", "dominance_frontiers"] @_dispatchable -def immediate_dominators(G: Graph[_Node], start: _Node): ... +def immediate_dominators(G: Graph[_Node], start: _Node) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def dominance_frontiers(G: Graph[_Node], start: _Node): ... +def dominance_frontiers(G: Graph[_Node], start: _Node) -> dict[Incomplete, Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/euler.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/euler.pyi index 94aeeae3fdf1..eaffb70723d6 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/euler.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/euler.pyi @@ -2,6 +2,7 @@ from _typeshed import Incomplete from collections.abc import Generator from networkx.classes.graph import Graph, _Node +from networkx.classes.multigraph import MultiGraph from networkx.utils.backends import _dispatchable __all__ = ["is_eulerian", "eulerian_circuit", "eulerize", "is_semieulerian", "has_eulerian_path", "eulerian_path"] @@ -17,4 +18,4 @@ def has_eulerian_path(G: Graph[_Node], source: _Node | None = None) -> bool: ... @_dispatchable def eulerian_path(G: Graph[_Node], source=None, keys: bool = False) -> Generator[Incomplete, Incomplete]: ... @_dispatchable -def eulerize(G: Graph[_Node]): ... +def eulerize(G: Graph[_Node]) -> MultiGraph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi index 90a90d365a2d..767af34353d8 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete + +from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -12,4 +15,4 @@ def boykov_kolmogorov( residual: Graph[_Node] | None = None, value_only: bool = False, cutoff: float | None = None, -): ... +) -> DiGraph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi index 13b7ad6da8a1..08303e681bd2 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,4 +8,4 @@ __all__ = ["capacity_scaling"] @_dispatchable def capacity_scaling( G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight", heap: type = ... -): ... +) -> tuple[int, dict[Incomplete, Incomplete]]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi index 03136846c7d2..9b866da0d367 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete + +from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -12,4 +15,4 @@ def dinitz( residual: Graph[_Node] | None = None, value_only: bool = False, cutoff: float | None = None, -): ... +) -> DiGraph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi index c415d24327ab..e43617b2dc61 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete + +from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -12,4 +15,4 @@ def edmonds_karp( residual: Graph[_Node] | None = None, value_only: bool = False, cutoff: float | None = None, -): ... +) -> DiGraph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi index a1680ad0b727..08c65356dea4 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi @@ -10,4 +10,6 @@ __all__ = ["gomory_hu_tree"] default_flow_func = edmonds_karp @_dispatchable -def gomory_hu_tree(G: Graph[_Node], capacity: str = "capacity", flow_func: Callable[..., Incomplete] | None = None): ... +def gomory_hu_tree( + G: Graph[_Node], capacity: str = "capacity", flow_func: Callable[..., Incomplete] | None = None +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/maxflow.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/maxflow.pyi index a94415cfb00d..65ec771c6e55 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/maxflow.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/maxflow.pyi @@ -17,7 +17,7 @@ def maximum_flow( capacity: str = "capacity", flow_func: Callable[..., Incomplete] | None = None, **kwargs, -): ... +) -> tuple[int | float, dict[Incomplete, Incomplete]]: ... @_dispatchable def maximum_flow_value( flowG: Graph[_Node], @@ -26,7 +26,7 @@ def maximum_flow_value( capacity: str = "capacity", flow_func: Callable[..., Incomplete] | None = None, **kwargs, -): ... +) -> int | float: ... @_dispatchable def minimum_cut( flowG: Graph[_Node], @@ -35,7 +35,7 @@ def minimum_cut( capacity: str = "capacity", flow_func: Callable[..., Incomplete] | None = None, **kwargs, -): ... +) -> tuple[int | float, tuple[set[Incomplete], set[Incomplete]]]: ... @_dispatchable def minimum_cut_value( flowG: Graph[_Node], @@ -44,4 +44,4 @@ def minimum_cut_value( capacity: str = "capacity", flow_func: Callable[..., Incomplete] | None = None, **kwargs, -): ... +) -> int | float: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi index e3f5b5bed7e4..d31bbb22ac4e 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete + +from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -12,4 +15,4 @@ def preflow_push( residual: Graph[_Node] | None = None, global_relabel_freq: float = 1, value_only: bool = False, -): ... +) -> DiGraph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi index 643baf509cdd..62ec86a862c3 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete + +from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -13,4 +16,4 @@ def shortest_augmenting_path( value_only: bool = False, two_phase: bool = False, cutoff: float | None = None, -): ... +) -> DiGraph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/hybrid.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/hybrid.pyi index 84b18c083a60..2e6aff5d823a 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/hybrid.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/hybrid.pyi @@ -1,9 +1,13 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["kl_connected_subgraph", "is_kl_connected"] @_dispatchable -def kl_connected_subgraph(G: Graph[_Node], k: int, l: int, low_memory: bool = False, same_as_graph: bool = False): ... +def kl_connected_subgraph( + G: Graph[_Node], k: int, l: int, low_memory: bool = False, same_as_graph: bool = False +) -> Graph[Incomplete]: ... @_dispatchable def is_kl_connected(G: Graph[_Node], k: int, l: int, low_memory: bool = False) -> bool: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isolate.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isolate.pyi index 95a78fa04f4d..8c0c8bfe0315 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isolate.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isolate.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Iterator + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,6 +9,6 @@ __all__ = ["is_isolate", "isolates", "number_of_isolates"] @_dispatchable def is_isolate(G: Graph[_Node], n: _Node) -> bool: ... @_dispatchable -def isolates(G: Graph[_Node]): ... +def isolates(G: Graph[_Node]) -> Iterator[Incomplete]: ... @_dispatchable def number_of_isolates(G: Graph[_Node]) -> int: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi index ce35ad716eda..382cacbd7ec7 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Callable, Iterable, Sequence from types import FunctionType from networkx.utils.backends import _dispatchable @@ -16,25 +17,41 @@ __all__ = [ ] def copyfunc(f, name=None) -> FunctionType: ... -def allclose(x, y, rtol: float = 1.0000000000000001e-05, atol=1e-08) -> bool: ... +def allclose(x, y, rtol: float = 1.0000000000000001e-05, atol: float = 1e-08) -> bool: ... @_dispatchable -def categorical_node_match(attr, default): ... +def categorical_node_match( + attr: str | Iterable[Incomplete], default: Incomplete | Iterable[Incomplete] +) -> Callable[..., Incomplete]: ... categorical_edge_match: Incomplete @_dispatchable -def categorical_multiedge_match(attr, default): ... +def categorical_multiedge_match( + attr: str | Iterable[Incomplete], default: Incomplete | Iterable[Incomplete] +) -> Callable[..., Incomplete]: ... @_dispatchable -def numerical_node_match(attr, default, rtol: float = 1e-05, atol: float = 1e-08): ... +def numerical_node_match( + attr: str | Iterable[Incomplete], default: Incomplete | Iterable[Incomplete], rtol: float = 1e-05, atol: float = 1e-08 +) -> Callable[..., Incomplete]: ... numerical_edge_match: Incomplete @_dispatchable -def numerical_multiedge_match(attr, default, rtol: float = 1e-05, atol: float = 1e-08): ... +def numerical_multiedge_match( + attr: str | Iterable[Incomplete], default: Incomplete | Iterable[Incomplete], rtol: float = 1e-05, atol: float = 1e-08 +) -> Callable[..., Incomplete]: ... @_dispatchable -def generic_node_match(attr, default, op): ... +def generic_node_match( + attr: str | Iterable[Incomplete], + default: Incomplete | Iterable[Incomplete], + op: Callable[..., Incomplete] | Sequence[Incomplete], +) -> Callable[..., Incomplete]: ... generic_edge_match: Incomplete @_dispatchable -def generic_multiedge_match(attr, default, op): ... +def generic_multiedge_match( + attr: str | Iterable[Incomplete], + default: Incomplete | Iterable[Incomplete], + op: Callable[..., Incomplete] | Sequence[Incomplete], +) -> Callable[..., Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi index 858ac56d06e8..1b3d07cd6e14 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi @@ -8,6 +8,8 @@ __all__ = ["rooted_tree_isomorphism", "tree_isomorphism"] @_dispatchable def root_trees(t1, root1, t2, root2): ... @_dispatchable -def rooted_tree_isomorphism(t1, root1, t2, root2) -> list[tuple[Incomplete, Incomplete]]: ... +def rooted_tree_isomorphism( + t1: Graph[Incomplete], root1, t2: Graph[Incomplete], root2 +) -> list[tuple[Incomplete, Incomplete]]: ... @_dispatchable def tree_isomorphism(t1: Graph[_Node], t2: Graph[_Node]) -> list[tuple[Incomplete, Incomplete]]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi index 0ea2eff0b582..f5cbbc1516b2 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi @@ -29,11 +29,13 @@ class _StateParameters(NamedTuple): T2_tilde_in: Incomplete @_dispatchable -def vf2pp_isomorphism(G1: Graph[_Node], G2: Graph[_Node], node_label: str | None = None, default_label: float | None = None): ... +def vf2pp_isomorphism( + G1: Graph[_Node], G2: Graph[_Node], node_label: str | None = None, default_label: float | None = None +) -> dict[Incomplete, Incomplete] | None: ... @_dispatchable def vf2pp_is_isomorphic( G1: Graph[_Node], G2: Graph[_Node], node_label: str | None = None, default_label: float | None = None -): ... +) -> bool: ... @_dispatchable def vf2pp_all_isomorphisms( G1: Graph[_Node], G2: Graph[_Node], node_label: str | None = None, default_label: float | None = None diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/link_prediction.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/link_prediction.pyi index 9a9a815dc998..1a14f6609bb6 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/link_prediction.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/link_prediction.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Iterable, Iterator + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -13,18 +16,26 @@ __all__ = [ ] @_dispatchable -def resource_allocation_index(G: Graph[_Node], ebunch=None): ... +def resource_allocation_index(G: Graph[_Node], ebunch: Iterable[Incomplete] | None = None) -> Iterator[Incomplete]: ... @_dispatchable -def jaccard_coefficient(G: Graph[_Node], ebunch=None): ... +def jaccard_coefficient(G: Graph[_Node], ebunch: Iterable[Incomplete] | None = None) -> Iterator[Incomplete]: ... @_dispatchable -def adamic_adar_index(G: Graph[_Node], ebunch=None): ... +def adamic_adar_index(G: Graph[_Node], ebunch: Iterable[Incomplete] | None = None) -> Iterator[Incomplete]: ... @_dispatchable -def common_neighbor_centrality(G: Graph[_Node], ebunch=None, alpha=0.8): ... +def common_neighbor_centrality( + G: Graph[_Node], ebunch: Iterable[Incomplete] | None = None, alpha=0.8 +) -> Iterator[Incomplete]: ... @_dispatchable -def preferential_attachment(G: Graph[_Node], ebunch=None): ... +def preferential_attachment(G: Graph[_Node], ebunch: Iterable[Incomplete] | None = None) -> Iterator[Incomplete]: ... @_dispatchable -def cn_soundarajan_hopcroft(G: Graph[_Node], ebunch=None, community: str | None = "community"): ... +def cn_soundarajan_hopcroft( + G: Graph[_Node], ebunch: Iterable[Incomplete] | None = None, community: str | None = "community" +) -> Iterator[Incomplete]: ... @_dispatchable -def ra_index_soundarajan_hopcroft(G: Graph[_Node], ebunch=None, community: str | None = "community"): ... +def ra_index_soundarajan_hopcroft( + G: Graph[_Node], ebunch: Iterable[Incomplete] | None = None, community: str | None = "community" +) -> Iterator[Incomplete]: ... @_dispatchable -def within_inter_cluster(G: Graph[_Node], ebunch=None, delta: float | None = 0.001, community: str | None = "community"): ... +def within_inter_cluster( + G: Graph[_Node], ebunch: Iterable[Incomplete] | None = None, delta: float | None = 0.001, community: str | None = "community" +) -> Iterator[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi index 8e3e2a6e37df..ce589b95035d 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Generator, Iterable, Iterator from networkx.classes.digraph import DiGraph from networkx.classes.graph import _Node @@ -8,8 +8,10 @@ from networkx.utils.backends import _dispatchable __all__ = ["all_pairs_lowest_common_ancestor", "tree_all_pairs_lowest_common_ancestor", "lowest_common_ancestor"] @_dispatchable -def all_pairs_lowest_common_ancestor(G: DiGraph[_Node], pairs=None): ... +def all_pairs_lowest_common_ancestor(G: DiGraph[_Node], pairs: Iterable[Incomplete] | None = None): ... @_dispatchable def lowest_common_ancestor(G: DiGraph[_Node], node1, node2, default=None): ... @_dispatchable -def tree_all_pairs_lowest_common_ancestor(G: DiGraph[_Node], root: _Node | None = None, pairs=None) -> Generator[Incomplete]: ... +def tree_all_pairs_lowest_common_ancestor( + G: DiGraph[_Node], root: _Node | None = None, pairs: Iterator[Incomplete] | None = None +) -> Generator[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/minors/contraction.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/minors/contraction.pyi index 0d94d40a8e89..eb6df5761260 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/minors/contraction.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/minors/contraction.pyi @@ -11,18 +11,18 @@ def equivalence_classes(iterable: Iterable[_Node], relation: Callable[[_Node, _N @_dispatchable def quotient_graph( G: Graph[_Node], - partition, - edge_relation=None, + partition: Callable[..., Incomplete] | dict[Incomplete, Incomplete] | list[set[Incomplete]], + edge_relation: Callable[..., Incomplete] | None = None, node_data: Callable[..., Incomplete] | None = None, edge_data: Callable[..., Incomplete] | None = None, weight: str | None = "weight", relabel: bool = False, - create_using: Graph[_Node] | None = None, -): ... + create_using: Graph[_Node] | type[Graph[_Node]] | None = None, +) -> Graph[Incomplete]: ... @_dispatchable def contracted_nodes( G: Graph[_Node], u, v, self_loops: bool = True, copy: bool = True, *, store_contraction_as: str | None = "contraction" -): ... +) -> Graph[Incomplete]: ... identified_nodes = contracted_nodes @@ -34,4 +34,4 @@ def contracted_edge( copy: bool = True, *, store_contraction_as: str | None = "contraction", -): ... +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/moral.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/moral.pyi index 7727b2f68e54..60b07f0e3b4b 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/moral.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/moral.pyi @@ -1,7 +1,9 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["moral_graph"] @_dispatchable -def moral_graph(G: Graph[_Node]): ... +def moral_graph(G: Graph[_Node]) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/node_classification.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/node_classification.pyi index 8d5089104a36..d613a26ded63 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/node_classification.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/node_classification.pyi @@ -1,9 +1,13 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["harmonic_function", "local_and_global_consistency"] @_dispatchable -def harmonic_function(G: Graph[_Node], max_iter: int = 30, label_name: str = "label"): ... +def harmonic_function(G: Graph[_Node], max_iter: int = 30, label_name: str = "label") -> list[Incomplete]: ... @_dispatchable -def local_and_global_consistency(G: Graph[_Node], alpha: float = 0.99, max_iter: int = 30, label_name: str = "label"): ... +def local_and_global_consistency( + G: Graph[_Node], alpha: float = 0.99, max_iter: int = 30, label_name: str = "label" +) -> list[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/operators/all.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/operators/all.pyi index 9816017a7840..1283c534359c 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/operators/all.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/operators/all.pyi @@ -1,15 +1,16 @@ from _typeshed import Incomplete from collections.abc import Iterable +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable __all__ = ["union_all", "compose_all", "disjoint_union_all", "intersection_all"] @_dispatchable -def union_all(graphs: Iterable[Incomplete], rename: Iterable[Incomplete] | None = ()): ... +def union_all(graphs: Iterable[Incomplete], rename: Iterable[Incomplete] | None = ()) -> Graph[Incomplete]: ... @_dispatchable -def disjoint_union_all(graphs: Iterable[Incomplete]): ... +def disjoint_union_all(graphs: Iterable[Incomplete]) -> Graph[Incomplete]: ... @_dispatchable -def compose_all(graphs: Iterable[Incomplete]): ... +def compose_all(graphs: Iterable[Incomplete]) -> Graph[Incomplete]: ... @_dispatchable -def intersection_all(graphs: Iterable[Incomplete]): ... +def intersection_all(graphs: Iterable[Incomplete]) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/operators/binary.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/operators/binary.pyi index 069595330023..1b02515642a1 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/operators/binary.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/operators/binary.pyi @@ -9,13 +9,13 @@ from networkx.utils.backends import _dispatchable __all__ = ["union", "compose", "disjoint_union", "intersection", "difference", "symmetric_difference", "full_join"] @_dispatchable -def disjoint_union(G: Graph[_Node], H: Graph[_Node]): ... +def disjoint_union(G: Graph[_Node], H: Graph[_Node]) -> Graph[Incomplete]: ... @_dispatchable -def intersection(G: Graph[_Node], H: Graph[_Node]): ... +def intersection(G: Graph[_Node], H: Graph[_Node]) -> Graph[Incomplete]: ... @_dispatchable -def difference(G: Graph[_Node], H: Graph[_Node]): ... +def difference(G: Graph[_Node], H: Graph[_Node]) -> Graph[Incomplete]: ... @_dispatchable -def symmetric_difference(G: Graph[_Node], H: Graph[_Node]): ... +def symmetric_difference(G: Graph[_Node], H: Graph[_Node]) -> Graph[Incomplete]: ... _X_co = TypeVar("_X_co", bound=Hashable, covariant=True) _Y_co = TypeVar("_Y_co", bound=Hashable, covariant=True) @@ -23,6 +23,6 @@ _Y_co = TypeVar("_Y_co", bound=Hashable, covariant=True) @_dispatchable def compose(G: Graph[_X_co], H: Graph[_Y_co]) -> DiGraph[_X_co | _Y_co]: ... @_dispatchable -def full_join(G: Graph[_Node], H, rename=(None, None)): ... +def full_join(G: Graph[_Node], H, rename: tuple[Incomplete, Incomplete] = (None, None)) -> Graph[Incomplete]: ... @_dispatchable def union(G: Graph[_X_co], H: Graph[_Y_co], rename: Iterable[Incomplete] | None = ()) -> DiGraph[_X_co | _Y_co]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/operators/product.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/operators/product.pyi index fbd87802dbaf..2fa5b93a77c1 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/operators/product.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/operators/product.pyi @@ -28,7 +28,7 @@ def lexicographic_product(G: Graph[_X], H: Graph[_Y]) -> Graph[tuple[_X, _Y]]: . @_dispatchable def strong_product(G: Graph[_X], H: Graph[_Y]) -> Graph[tuple[_X, _Y]]: ... @_dispatchable -def power(G: Graph[_Node], k): ... +def power(G: Graph[_Node], k: int) -> Graph[Incomplete]: ... @_dispatchable def rooted_product(G: Graph[_X], H: Graph[_Y], root: _Y) -> Graph[tuple[_X, _Y]]: ... @_dispatchable diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/operators/unary.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/operators/unary.pyi index 0a42c013322d..11a8f76ae663 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/operators/unary.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/operators/unary.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Hashable from typing import TypeVar @@ -9,6 +10,6 @@ _G = TypeVar("_G", bound=Graph[Hashable]) __all__ = ["complement", "reverse"] @_dispatchable -def complement(G: Graph[_Node]): ... +def complement(G: Graph[_Node]) -> Graph[Incomplete]: ... @_dispatchable def reverse(G: _G, copy: bool = True) -> _G: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/planar_drawing.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/planar_drawing.pyi index d4c6164ed122..a40ab8611e12 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/planar_drawing.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/planar_drawing.pyi @@ -1,16 +1,21 @@ from _typeshed import Incomplete from collections.abc import Sequence +from networkx.algorithms.planarity import PlanarEmbedding from networkx.utils.backends import _dispatchable __all__ = ["combinatorial_embedding_to_pos"] @_dispatchable -def combinatorial_embedding_to_pos(embedding, fully_triangulate: bool = False) -> dict[Incomplete, Incomplete]: ... +def combinatorial_embedding_to_pos( + embedding: PlanarEmbedding[Incomplete], fully_triangulate: bool = False +) -> dict[Incomplete, Incomplete]: ... def set_position(parent, tree, remaining_nodes, delta_x, y_coordinate, pos): ... -def get_canonical_ordering(embedding, outer_face: Sequence[Incomplete]) -> list[Incomplete]: ... -def triangulate_face(embedding, v1, v2): ... -def triangulate_embedding(embedding, fully_triangulate: bool = True): ... +def get_canonical_ordering(embedding: PlanarEmbedding[Incomplete], outer_face: Sequence[Incomplete]) -> list[Incomplete]: ... +def triangulate_face(embedding: PlanarEmbedding[Incomplete], v1, v2): ... +def triangulate_embedding( + embedding: PlanarEmbedding[Incomplete], fully_triangulate: bool = True +) -> tuple[PlanarEmbedding[Incomplete], list[Incomplete]]: ... def make_bi_connected( - embedding, starting_node, outgoing_node, edges_counted: set[tuple[Incomplete, Incomplete]] + embedding: PlanarEmbedding[Incomplete], starting_node, outgoing_node, edges_counted: set[tuple[Incomplete, Incomplete]] ) -> list[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/planarity.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/planarity.pyi index b351c8f2c49f..082bfb94007b 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/planarity.pyi @@ -12,7 +12,7 @@ __all__ = ["check_planarity", "is_planar", "PlanarEmbedding"] @_dispatchable def is_planar(G: Graph[_Node]) -> bool: ... @_dispatchable -def check_planarity(G: Graph[_Node], counterexample: bool = False): ... +def check_planarity(G: Graph[_Node], counterexample: bool = False) -> tuple[bool, Graph[Incomplete]]: ... @_dispatchable def get_counterexample(G: Graph[_Node, _NodeData, _EdgeData]) -> Graph[_Node, _NodeData, _EdgeData]: ... @_dispatchable diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/regular.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/regular.pyi index 7505f6d5a521..063661966c6c 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/regular.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/regular.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -8,4 +10,4 @@ def is_regular(G: Graph[_Node]) -> bool: ... @_dispatchable def is_k_regular(G: Graph[_Node], k) -> bool: ... @_dispatchable -def k_factor(G: Graph[_Node], k, matching_weight: str | None = "weight"): ... +def k_factor(G: Graph[_Node], k: int, matching_weight: str | None = "weight") -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi index 96c6399f63cb..1290fe33c14c 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi @@ -2,13 +2,16 @@ from _typeshed import Incomplete, SupportsGetItem from collections import defaultdict from collections.abc import Collection +import numpy as np from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["floyd_warshall", "floyd_warshall_predecessor_and_distance", "reconstruct_path", "floyd_warshall_numpy"] @_dispatchable -def floyd_warshall_numpy(G: Graph[_Node], nodelist: Collection[_Node] | None = None, weight: str | None = "weight"): ... +def floyd_warshall_numpy( + G: Graph[_Node], nodelist: Collection[_Node] | None = None, weight: str | None = "weight" +) -> np.ndarray[Incomplete, Incomplete]: ... @_dispatchable def floyd_warshall_predecessor_and_distance( G: Graph[_Node], weight: str | None = "weight" diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi index d0561d85d4bc..636eb613875d 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi @@ -18,7 +18,9 @@ __all__ = [ @_dispatchable def single_source_shortest_path_length(G: Graph[_Node], source: _Node, cutoff: int | None = None) -> dict[Incomplete, int]: ... @_dispatchable -def single_target_shortest_path_length(G: Graph[_Node], target: _Node, cutoff: int | None = None): ... +def single_target_shortest_path_length( + G: Graph[_Node], target: _Node, cutoff: int | None = None +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def all_pairs_shortest_path_length(G: Graph[_Node], cutoff: int | None = None) -> Generator[Incomplete]: ... @_dispatchable @@ -38,4 +40,4 @@ def all_pairs_shortest_path( @_dispatchable def predecessor( G: Graph[_Node], source: _Node, target: _Node | None = None, cutoff: int | None = None, return_seen: bool | None = None -): ... +) -> dict[_Node, list[_Node]] | list[_Node] | tuple[dict[_Node, list[_Node]], dict[_Node, int]] | tuple[list[_Node], int]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/similarity.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/similarity.pyi index ccd60ca1c1ea..b0ba3bbe8797 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/similarity.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/similarity.pyi @@ -28,7 +28,7 @@ def graph_edit_distance( edge_subst_cost: Callable[..., Incomplete] | None = None, edge_del_cost: Callable[..., Incomplete] | None = None, edge_ins_cost: Callable[..., Incomplete] | None = None, - roots=None, + roots: tuple[Incomplete, Incomplete] | None = None, upper_bound: float | None = None, timeout: float | None = None, ): ... @@ -45,7 +45,7 @@ def optimal_edit_paths( edge_del_cost: Callable[..., Incomplete] | None = None, edge_ins_cost: Callable[..., Incomplete] | None = None, upper_bound: float | None = None, -): ... +) -> tuple[list[tuple[Incomplete, Incomplete]], float]: ... @_dispatchable def optimize_graph_edit_distance( G1: Graph[_Node], @@ -74,7 +74,7 @@ def optimize_edit_paths( edge_ins_cost: Callable[..., Incomplete] | None = None, upper_bound: float | None = None, strictly_decreasing: bool = True, - roots=None, + roots: tuple[Incomplete, Incomplete] | None = None, timeout: float | None = None, ) -> Generator[Incomplete, None, Incomplete]: ... @_dispatchable diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/smallworld.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/smallworld.pyi index 3e163c121c7c..0b6ae2986819 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/smallworld.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/smallworld.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete + +import numpy as np from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState @@ -5,11 +8,17 @@ from numpy.random import RandomState __all__ = ["random_reference", "lattice_reference", "sigma", "omega"] @_dispatchable -def random_reference(G: Graph[_Node], niter: int = 1, connectivity: bool = True, seed: int | RandomState | None = None): ... +def random_reference( + G: Graph[_Node], niter: int = 1, connectivity: bool = True, seed: int | RandomState | None = None +) -> Graph[Incomplete]: ... @_dispatchable def lattice_reference( - G: Graph[_Node], niter: int = 5, D=None, connectivity: bool = True, seed: int | RandomState | None = None -): ... + G: Graph[_Node], + niter: int = 5, + D: np.ndarray[Incomplete, Incomplete] | None = None, + connectivity: bool = True, + seed: int | RandomState | None = None, +) -> Graph[Incomplete]: ... @_dispatchable def sigma(G: Graph[_Node], niter: int = 100, nrand: int = 10, seed: int | RandomState | None = None) -> float: ... @_dispatchable diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/sparsifiers.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/sparsifiers.pyi index 67670ddcce21..e94ffe57f37a 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/sparsifiers.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/sparsifiers.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState @@ -5,4 +7,6 @@ from numpy.random import RandomState __all__ = ["spanner"] @_dispatchable -def spanner(G: Graph[_Node], stretch: float, weight: str | None = None, seed: int | RandomState | None = None): ... +def spanner( + G: Graph[_Node], stretch: float, weight: str | None = None, seed: int | RandomState | None = None +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/summarization.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/summarization.pyi index db044b9271f7..c2ec3253c28f 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/summarization.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/summarization.pyi @@ -7,13 +7,15 @@ from networkx.utils.backends import _dispatchable __all__ = ["dedensify", "snap_aggregation"] @_dispatchable -def dedensify(G: Graph[_Node], threshold: int, prefix=None, copy: bool | None = True): ... +def dedensify( + G: Graph[_Node], threshold: int, prefix: str | None = None, copy: bool | None = True +) -> tuple[Graph[Incomplete], set[Incomplete]]: ... @_dispatchable def snap_aggregation( G: Graph[_Node], - node_attributes, + node_attributes: Iterable[Incomplete], edge_attributes: Iterable[Incomplete] | None = (), prefix: str = "Supernode-", supernode_attribute: str = "group", superedge_attribute: str = "types", -): ... +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/swap.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/swap.pyi index 7378a13a814e..607e9ae99ee6 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/swap.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/swap.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,9 +8,13 @@ from numpy.random import RandomState __all__ = ["double_edge_swap", "connected_double_edge_swap", "directed_edge_swap"] @_dispatchable -def directed_edge_swap(G: DiGraph[_Node], *, nswap: int = 1, max_tries: int = 100, seed: int | RandomState | None = None): ... +def directed_edge_swap( + G: DiGraph[_Node], *, nswap: int = 1, max_tries: int = 100, seed: int | RandomState | None = None +) -> DiGraph[Incomplete]: ... @_dispatchable -def double_edge_swap(G: Graph[_Node], nswap: int = 1, max_tries: int = 100, seed: int | RandomState | None = None): ... +def double_edge_swap( + G: Graph[_Node], nswap: int = 1, max_tries: int = 100, seed: int | RandomState | None = None +) -> Graph[Incomplete]: ... @_dispatchable def connected_double_edge_swap( G: Graph[_Node], nswap: int = 1, _window_threshold: int = 3, seed: int | RandomState | None = None diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/threshold.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/threshold.pyi index b0edc50fa779..c66a43788026 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/threshold.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/threshold.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Sequence from networkx.classes.graph import Graph, _Node @@ -19,7 +20,7 @@ def threshold_graph(creation_sequence, create_using=None): ... @_dispatchable def find_alternating_4_cycle(G: Graph[_Node]): ... @_dispatchable -def find_threshold_graph(G: Graph[_Node], create_using: Graph[_Node] | None = None): ... +def find_threshold_graph(G: Graph[_Node], create_using: Graph[_Node] | type[Graph[_Node]] | None = None) -> Graph[Incomplete]: ... @_dispatchable def find_creation_sequence(G: Graph[_Node]): ... def triangles(creation_sequence): ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/time_dependent.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/time_dependent.pyi index 554159d1d4bf..abdd217acd5c 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/time_dependent.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/time_dependent.pyi @@ -1,7 +1,11 @@ +from datetime import timedelta + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["cd_index"] @_dispatchable -def cd_index(G: Graph[_Node], node: _Node, time_delta, *, time: str = "time", weight: str | None = None): ... +def cd_index( + G: Graph[_Node], node: _Node, time_delta: float | timedelta, *, time: str = "time", weight: str | None = None +) -> float: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/branchings.pyi index 16cfa6a6eeaf..c9444c109a8d 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -4,7 +4,7 @@ from typing import Final from typing_extensions import Self from networkx.classes.digraph import DiGraph -from networkx.classes.graph import _Node +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState @@ -25,29 +25,31 @@ INF: Final[float] def random_string(L=15, seed=None): ... @_dispatchable -def branching_weight(G: DiGraph[_Node], attr: str = "weight", default: float = 1): ... +def branching_weight(G: DiGraph[_Node], attr: str = "weight", default: float = 1) -> int | float: ... @_dispatchable def greedy_branching( G: DiGraph[_Node], attr: str = "weight", default: float = 1, kind: str = "max", seed: int | RandomState | None = None -): ... +) -> Graph[Incomplete]: ... @_dispatchable def maximum_branching( G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str | None = None -): ... +) -> DiGraph[Incomplete]: ... @_dispatchable def minimum_branching( G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str | None = None -): ... +) -> DiGraph[Incomplete]: ... @_dispatchable -def minimal_branching(G: DiGraph[_Node], /, *, attr="weight", default=1, preserve_attrs=False, partition=None): ... +def minimal_branching( + G: DiGraph[_Node], /, *, attr="weight", default=1, preserve_attrs=False, partition=None +) -> DiGraph[Incomplete]: ... @_dispatchable def maximum_spanning_arborescence( G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str | None = None -): ... +) -> DiGraph[Incomplete]: ... @_dispatchable def minimum_spanning_arborescence( G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str | None = None -): ... +) -> DiGraph[Incomplete]: ... class ArborescenceIterator: @dataclass(order=True) diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/coding.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/coding.pyi index 1559965dcded..7e6013a8526e 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/coding.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/coding.pyi @@ -10,10 +10,10 @@ __all__ = ["from_nested_tuple", "from_prufer_sequence", "NotATree", "to_nested_t class NotATree(NetworkXException): ... @_dispatchable -def to_nested_tuple(T: Graph[_Node], root: _Node, canonical_form: bool = False): ... +def to_nested_tuple(T: Graph[_Node], root: _Node, canonical_form: bool = False) -> tuple[Incomplete, ...]: ... @_dispatchable -def from_nested_tuple(sequence: tuple[Incomplete, ...], sensible_relabeling: bool = False): ... +def from_nested_tuple(sequence: tuple[Incomplete, ...], sensible_relabeling: bool = False) -> Graph[Incomplete]: ... @_dispatchable def to_prufer_sequence(T: Graph[_Node]) -> list[Incomplete]: ... @_dispatchable -def from_prufer_sequence(sequence: Iterable[Incomplete]): ... +def from_prufer_sequence(sequence: Iterable[Incomplete]) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/mst.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/mst.pyi index b8af58e53cff..dc175b1cb1f0 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/mst.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/mst.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Callable, Generator +from collections.abc import Callable, Generator, Iterator from dataclasses import dataclass from enum import Enum from typing import Final, Literal @@ -28,11 +28,23 @@ class EdgePartition(Enum): EXCLUDED = 2 @_dispatchable -def boruvka_mst_edges(G: Graph[_Node], minimum=True, weight="weight", keys=False, data=True, ignore_nan=False): ... +def boruvka_mst_edges( + G: Graph[_Node], minimum: bool = True, weight: str = "weight", keys: bool = False, data: bool = True, ignore_nan: bool = False +): ... @_dispatchable -def kruskal_mst_edges(G: Graph[_Node], minimum, weight="weight", keys=True, data=True, ignore_nan=False, partition=None): ... +def kruskal_mst_edges( + G: Graph[_Node], + minimum: bool, + weight: str = "weight", + keys: bool = True, + data: bool = True, + ignore_nan: bool = False, + partition: str | None = None, +): ... @_dispatchable -def prim_mst_edges(G: Graph[_Node], minimum, weight="weight", keys=True, data=True, ignore_nan=False): ... +def prim_mst_edges( + G: Graph[_Node], minimum: bool, weight: str = "weight", keys: bool = True, data: bool = True, ignore_nan: bool = False +): ... ALGORITHMS: Final[dict[str, Callable[..., Generator[Incomplete, Incomplete, Incomplete]]]] @@ -44,7 +56,7 @@ def minimum_spanning_edges( keys: bool = True, data: bool | None = True, ignore_nan: bool = False, -): ... +) -> Iterator[Incomplete]: ... @_dispatchable def maximum_spanning_edges( G: Graph[_Node], @@ -53,19 +65,23 @@ def maximum_spanning_edges( keys: bool = True, data: bool | None = True, ignore_nan: bool = False, -): ... +) -> Iterator[Incomplete]: ... @_dispatchable -def minimum_spanning_tree(G: Graph[_Node], weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False): ... +def minimum_spanning_tree( + G: Graph[_Node], weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False +) -> Graph[Incomplete]: ... @_dispatchable def partition_spanning_tree( G: Graph[_Node], minimum: bool = True, weight: str = "weight", partition: str = "partition", ignore_nan: bool = False -): ... +) -> Graph[Incomplete]: ... @_dispatchable -def maximum_spanning_tree(G: Graph[_Node], weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False): ... +def maximum_spanning_tree( + G: Graph[_Node], weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False +) -> Graph[Incomplete]: ... @_dispatchable def random_spanning_tree( G: Graph[_Node], weight: str | None = None, *, multiplicative=True, seed: int | RandomState | None = None -): ... +) -> Graph[Incomplete]: ... class SpanningTreeIterator: @dataclass(order=True) diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/operations.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/operations.pyi index 0388ce40d84b..b66207c5dfce 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/operations.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/tree/operations.pyi @@ -1,9 +1,12 @@ from _typeshed import Incomplete from collections.abc import Iterable +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable __all__ = ["join_trees"] @_dispatchable -def join_trees(rooted_trees: Iterable[Incomplete], *, label_attribute: str | None = None, first_label: int | None = 0): ... +def join_trees( + rooted_trees: Iterable[Incomplete], *, label_attribute: str | None = None, first_label: int | None = 0 +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/walks.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/walks.pyi index 7e296bd5129e..44a872420ab5 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/walks.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/walks.pyi @@ -1,7 +1,9 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["number_of_walks"] @_dispatchable -def number_of_walks(G: Graph[_Node], walk_length: int): ... +def number_of_walks(G: Graph[_Node], walk_length: int) -> dict[Incomplete, Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/wiener.pyi b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/wiener.pyi index 5673df94c04c..6920d3e7176d 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/algorithms/wiener.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/algorithms/wiener.pyi @@ -6,8 +6,8 @@ __all__ = ["wiener_index", "schultz_index", "gutman_index", "hyper_wiener_index" @_dispatchable def wiener_index(G: Graph[_Node], weight: str | None = None) -> float: ... @_dispatchable -def schultz_index(G: Graph[_Node], weight=None) -> float: ... +def schultz_index(G: Graph[_Node], weight: str | None = None) -> float: ... @_dispatchable -def gutman_index(G: Graph[_Node], weight=None) -> float: ... +def gutman_index(G: Graph[_Node], weight: str | None = None) -> float: ... @_dispatchable -def hyper_wiener_index(G: Graph[_Node], weight=None) -> float: ... +def hyper_wiener_index(G: Graph[_Node], weight: str | None = None) -> float: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/classes/function.pyi b/python/helpers/typeshed/stubs/networkx/networkx/classes/function.pyi index c9759528af9a..17d152c96157 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/classes/function.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/classes/function.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete, SupportsItems, SupportsKeysAndGetItem, Unused -from collections.abc import Callable, Generator, Hashable, Iterable, Iterator +from collections.abc import Callable, Collection, Generator, Hashable, Iterable, Iterator from typing import Literal, TypeVar, overload from networkx import _dispatchable @@ -71,13 +71,13 @@ def is_directed(G: Graph[Hashable]) -> Literal[False]: ... def freeze(G: Graph[_Node]): ... def is_frozen(G: Graph[Incomplete]) -> bool: ... -def add_star(G_to_add_to, nodes_for_star, **attr) -> None: ... -def add_path(G_to_add_to, nodes_for_path, **attr) -> None: ... -def add_cycle(G_to_add_to, nodes_for_cycle, **attr) -> None: ... -def subgraph(G: Graph[_Node], nbunch): ... +def add_star(G_to_add_to: Graph[Incomplete], nodes_for_star: Iterable[Incomplete], **attr) -> None: ... +def add_path(G_to_add_to: Graph[Incomplete], nodes_for_path: Iterable[Incomplete], **attr) -> None: ... +def add_cycle(G_to_add_to: Graph[Incomplete], nodes_for_cycle: Iterable[Incomplete], **attr) -> None: ... +def subgraph(G: Graph[_Node], nbunch: Iterable[Incomplete]): ... def induced_subgraph(G: Graph[_Node, _NodeData, _EdgeData], nbunch: _NBunch[_Node]) -> Graph[_Node, _NodeData, _EdgeData]: ... -def edge_subgraph(G: Graph[_Node], edges): ... -def restricted_view(G: Graph[_Node], nodes, edges): ... +def edge_subgraph(G: Graph[_Node], edges: Iterable[Incomplete]) -> Graph[Incomplete]: ... +def restricted_view(G: Graph[_Node], nodes: Iterable[Incomplete], edges: Iterable[Incomplete]) -> Graph[Incomplete]: ... def to_directed(graph): ... def to_undirected(graph): ... def create_empty_copy(G: Graph[_Node], with_data: bool = True): ... @@ -178,5 +178,5 @@ def selfloop_edges( @_dispatchable def number_of_selfloops(G: Graph[Hashable]) -> int: ... def is_path(G: Graph[_Node], path: Iterable[Incomplete]) -> bool: ... -def path_weight(G: Graph[_Node], path, weight) -> int: ... +def path_weight(G: Graph[_Node], path: Collection[Incomplete], weight: str) -> int: ... def describe(G: Graph[_Node], describe_hook: Callable[[Graph[_Node]], dict[str, Incomplete]] | None = None) -> None: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/convert.pyi b/python/helpers/typeshed/stubs/networkx/networkx/convert.pyi index 0d4ddfa929a5..b6bd41f09185 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/convert.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/convert.pyi @@ -22,13 +22,21 @@ def to_networkx_graph( @_dispatchable def to_dict_of_lists(G: Graph[_Node], nodelist: Collection[_Node] | None = None) -> dict[_Node, list[_Node]]: ... @_dispatchable -def from_dict_of_lists(d: dict[_Node, Iterable[_Node]], create_using=None) -> Graph[_Node]: ... +def from_dict_of_lists( + d: dict[_Node, Iterable[_Node]], create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None +) -> Graph[_Node]: ... def to_dict_of_dicts( - G: Graph[_Node], nodelist: Collection[_Node] | None = None, edge_data=None + G: Graph[_Node], nodelist: Collection[_Node] | None = None, edge_data: float | None = None ) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def from_dict_of_dicts(d, create_using=None, multigraph_input=False) -> Graph[Incomplete]: ... +def from_dict_of_dicts( + d: dict[Incomplete, Incomplete], + create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None, + multigraph_input: bool = False, +) -> Graph[Incomplete]: ... @_dispatchable def to_edgelist(G: Graph[_Node], nodelist: Collection[_Node] | None = None): ... @_dispatchable -def from_edgelist(edgelist, create_using=None) -> Graph[Incomplete]: ... +def from_edgelist( + edgelist: Iterable[Incomplete], create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/convert_matrix.pyi b/python/helpers/typeshed/stubs/networkx/networkx/convert_matrix.pyi index 2fbee5b51ffc..98179313bcea 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/convert_matrix.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/convert_matrix.pyi @@ -3,6 +3,7 @@ from collections.abc import Callable, Collection, Hashable, Iterable from typing import Literal, TypeAlias, TypeVar, overload import numpy +import numpy as np from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -83,9 +84,20 @@ def from_pandas_edgelist( ) -> Graph[Incomplete]: ... @_dispatchable -def to_scipy_sparse_array(G: Graph[_Node], nodelist=None, dtype=None, weight="weight", format="csr"): ... +def to_scipy_sparse_array( + G: Graph[_Node], + nodelist: Collection[_Node] | None = None, + dtype: np.dtype[Incomplete] | None = None, + weight: str | None = "weight", + format: str = "csr", +): ... @_dispatchable -def from_scipy_sparse_array(A, parallel_edges=False, create_using=None, edge_attribute="weight"): ... +def from_scipy_sparse_array( + A, + parallel_edges: bool = False, + create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None, + edge_attribute: str = "weight", +): ... @_dispatchable def to_numpy_array( G: Graph[_Node], diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/atlas.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/atlas.pyi index 7b89477ab253..a17a5a5b24d8 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/atlas.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/atlas.pyi @@ -17,6 +17,6 @@ NUM_GRAPHS: Final = 1253 ATLAS_FILE: Final[Traversable] @_dispatchable -def graph_atlas(i) -> Graph[Incomplete]: ... +def graph_atlas(i: int) -> Graph[Incomplete]: ... @_dispatchable def graph_atlas_g() -> list[Graph[Incomplete]]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/classic.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/classic.pyi index 5c46ad3a2add..bd070af62575 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/classic.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/classic.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Iterable from networkx.classes import Graph from networkx.utils.backends import _dispatchable @@ -28,44 +29,60 @@ __all__ = [ ] @_dispatchable -def full_rary_tree(r, n, create_using=None): ... +def full_rary_tree( + r: int, n: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None +) -> Graph[Incomplete]: ... @_dispatchable -def kneser_graph(n, k) -> Graph[Incomplete]: ... +def kneser_graph(n: int, k: int) -> Graph[Incomplete]: ... @_dispatchable -def balanced_tree(r, h, create_using=None): ... +def balanced_tree( + r: int, h: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None +) -> Graph[Incomplete]: ... @_dispatchable -def barbell_graph(m1, m2, create_using=None): ... +def barbell_graph( + m1: int, m2: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None +) -> Graph[Incomplete]: ... @_dispatchable -def binomial_tree(n, create_using=None): ... +def binomial_tree(n: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def complete_graph(n, create_using=None): ... +def complete_graph(n: int | Iterable[Incomplete], create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None): ... @_dispatchable def circular_ladder_graph(n, create_using=None): ... @_dispatchable -def circulant_graph(n, offsets, create_using=None): ... +def circulant_graph( + n: int, offsets: list[int], create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None +) -> Graph[Incomplete]: ... @_dispatchable -def cycle_graph(n, create_using=None): ... +def cycle_graph(n: int | Iterable[Incomplete], create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None): ... @_dispatchable -def dorogovtsev_goltsev_mendes_graph(n, create_using=None): ... +def dorogovtsev_goltsev_mendes_graph( + n: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None +) -> Graph[Incomplete]: ... @_dispatchable -def empty_graph(n: Incomplete | int = 0, create_using=None, default=...): ... +def empty_graph( + n: Incomplete | int = 0, + create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None, + default: type[Graph[Incomplete]] = ..., +): ... @_dispatchable def ladder_graph(n, create_using=None): ... @_dispatchable -def lollipop_graph(m, n, create_using=None): ... +def lollipop_graph(m, n, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable def null_graph(create_using=None): ... @_dispatchable -def path_graph(n, create_using=None): ... +def path_graph(n: int | Iterable[Incomplete], create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None): ... @_dispatchable -def star_graph(n, create_using=None): ... +def star_graph(n: int | Iterable[Incomplete], create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None): ... @_dispatchable -def tadpole_graph(m, n, create_using=None) -> Graph[Incomplete] | Incomplete: ... +def tadpole_graph( + m, n, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None +) -> Graph[Incomplete] | Incomplete: ... @_dispatchable def trivial_graph(create_using=None): ... @_dispatchable -def turan_graph(n, r): ... +def turan_graph(n: int, r: int): ... @_dispatchable -def wheel_graph(n, create_using=None): ... +def wheel_graph(n: int | Iterable[Incomplete], create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None): ... @_dispatchable -def complete_multipartite_graph(*subset_sizes): ... +def complete_multipartite_graph(*subset_sizes) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/cographs.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/cographs.pyi index ba2edca7a2b6..53238e9fe20a 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/cographs.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/cographs.pyi @@ -1,6 +1,9 @@ +from _typeshed import Incomplete + +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable __all__ = ["random_cograph"] @_dispatchable -def random_cograph(n, seed=None): ... +def random_cograph(n: int, seed=None) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/community.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/community.pyi index 706b03dbd544..e3c9f38ada20 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/community.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/community.pyi @@ -1,6 +1,8 @@ from _typeshed import Incomplete from collections.abc import Collection +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable __all__ = [ @@ -17,43 +19,49 @@ __all__ = [ ] @_dispatchable -def caveman_graph(l, k): ... +def caveman_graph(l: int, k: int) -> Graph[Incomplete]: ... @_dispatchable -def connected_caveman_graph(l, k): ... +def connected_caveman_graph(l: int, k: int) -> Graph[Incomplete]: ... @_dispatchable -def relaxed_caveman_graph(l, k, p, seed=None): ... +def relaxed_caveman_graph(l: int, k: int, p: float, seed=None) -> Graph[Incomplete]: ... @_dispatchable -def random_partition_graph(sizes, p_in, p_out, seed=None, directed: bool = False): ... +def random_partition_graph( + sizes: list[int], p_in: float, p_out: float, seed=None, directed: bool = False +) -> DiGraph[Incomplete]: ... @_dispatchable -def planted_partition_graph(l, k, p_in, p_out, seed=None, directed: bool = False): ... +def planted_partition_graph( + l: int, k: int, p_in: float, p_out: float, seed=None, directed: bool = False +) -> DiGraph[Incomplete]: ... @_dispatchable -def gaussian_random_partition_graph(n, s, v, p_in, p_out, directed: bool = False, seed=None): ... +def gaussian_random_partition_graph( + n: int, s: float, v: float, p_in: float, p_out: float, directed: bool = False, seed=None +) -> DiGraph[Incomplete]: ... @_dispatchable -def ring_of_cliques(num_cliques, clique_size): ... +def ring_of_cliques(num_cliques: int, clique_size: int) -> Graph[Incomplete]: ... @_dispatchable -def windmill_graph(n, k): ... +def windmill_graph(n: int, k: int) -> Graph[Incomplete]: ... @_dispatchable def stochastic_block_model( - sizes, - p, + sizes: list[int], + p: list[list[float]], nodelist: Collection[Incomplete] | None = None, seed=None, directed: bool = False, selfloops: bool = False, sparse: bool = True, -): ... +) -> DiGraph[Incomplete]: ... @_dispatchable def LFR_benchmark_graph( - n, - tau1, - tau2, - mu, - average_degree=None, - min_degree=None, - max_degree=None, - min_community=None, - max_community=None, + n: int, + tau1: float, + tau2: float, + mu: float, + average_degree: float | None = None, + min_degree: int | None = None, + max_degree: int | None = None, + min_community: int | None = None, + max_community: int | None = None, tol: float = 1e-07, max_iters: int = 500, seed=None, -): ... +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/degree_seq.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/degree_seq.pyi index 0378d273caaf..562806bed693 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/degree_seq.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/degree_seq.pyi @@ -18,21 +18,32 @@ __all__ = [ ] @_dispatchable -def configuration_model(deg_sequence, create_using=None, seed=None) -> MultiGraph[Incomplete]: ... +def configuration_model( + deg_sequence: list[int], create_using: MultiGraph[Incomplete] | type[MultiGraph[Incomplete]] | None = None, seed=None +) -> MultiGraph[Incomplete]: ... @_dispatchable def directed_configuration_model( - in_degree_sequence, out_degree_sequence, create_using=None, seed=None + in_degree_sequence: list[int], + out_degree_sequence: list[int], + create_using: MultiDiGraph[Incomplete] | type[MultiDiGraph[Incomplete]] | None = None, + seed=None, ) -> MultiDiGraph[Incomplete]: ... @_dispatchable -def expected_degree_graph(w, seed=None, selfloops: bool = True) -> Graph[Incomplete]: ... +def expected_degree_graph(w: list[Incomplete], seed=None, selfloops: bool = True) -> Graph[Incomplete]: ... @_dispatchable -def havel_hakimi_graph(deg_sequence, create_using=None): ... +def havel_hakimi_graph(deg_sequence: list[int], create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None): ... @_dispatchable -def directed_havel_hakimi_graph(in_deg_sequence, out_deg_sequence, create_using=None) -> DiGraph[Incomplete]: ... +def directed_havel_hakimi_graph( + in_deg_sequence: list[int], + out_deg_sequence: list[int], + create_using: DiGraph[Incomplete] | type[DiGraph[Incomplete]] | None = None, +) -> DiGraph[Incomplete]: ... @_dispatchable -def degree_sequence_tree(deg_sequence, create_using=None): ... +def degree_sequence_tree( + deg_sequence, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None +) -> Graph[Incomplete]: ... @_dispatchable -def random_degree_sequence_graph(sequence, seed=None, tries: int = 10) -> Graph[Incomplete]: ... +def random_degree_sequence_graph(sequence: list[int], seed=None, tries: int = 10) -> Graph[Incomplete]: ... class DegreeSequenceRandomGraph: rng: Incomplete diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/directed.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/directed.pyi index dbddbecf23c0..0d32d803d860 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/directed.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/directed.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from collections.abc import Callable +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable from ..classes import MultiDiGraph @@ -7,14 +10,16 @@ from ..classes import MultiDiGraph __all__ = ["gn_graph", "gnc_graph", "gnr_graph", "random_k_out_graph", "scale_free_graph"] @_dispatchable -def gn_graph(n, kernel=None, create_using=None, seed=None): ... +def gn_graph( + n: int, kernel: Callable[..., Incomplete] | None = None, create_using: DiGraph[Incomplete] | None = None, seed=None +): ... @_dispatchable -def gnr_graph(n, p, create_using=None, seed=None): ... +def gnr_graph(n: int, p: float, create_using: DiGraph[Incomplete] | type[DiGraph[Incomplete]] | None = None, seed=None): ... @_dispatchable -def gnc_graph(n, create_using=None, seed=None): ... +def gnc_graph(n: int, create_using: DiGraph[Incomplete] | type[DiGraph[Incomplete]] | None = None, seed=None): ... @_dispatchable def scale_free_graph( - n, + n: int, alpha: float = 0.41, beta: float = 0.54, gamma: float = 0.05, @@ -22,9 +27,11 @@ def scale_free_graph( delta_out: float = 0, create_using=None, seed=None, - initial_graph=None, -): ... + initial_graph: MultiDiGraph[Incomplete] | None = None, +) -> MultiDiGraph[Incomplete]: ... @_dispatchable -def random_uniform_k_out_graph(n: int, k: int, self_loops: bool = True, with_replacement: bool = True, seed=None): ... +def random_uniform_k_out_graph( + n: int, k: int, self_loops: bool = True, with_replacement: bool = True, seed=None +) -> Graph[Incomplete]: ... @_dispatchable -def random_k_out_graph(n, k, alpha, self_loops: bool = True, seed=None) -> MultiDiGraph[Incomplete]: ... +def random_k_out_graph(n: int, k: int, alpha: float, self_loops: bool = True, seed=None) -> MultiDiGraph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/duplication.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/duplication.pyi index 387f761bea60..0212e9c3b060 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/duplication.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/duplication.pyi @@ -7,6 +7,6 @@ from ..classes.graph import Graph __all__ = ["partial_duplication_graph", "duplication_divergence_graph"] @_dispatchable -def partial_duplication_graph(N, n, p, q, seed=None): ... +def partial_duplication_graph(N: int, n: int, p: float, q: float, seed=None): ... @_dispatchable -def duplication_divergence_graph(n, p, seed=None) -> Graph[Incomplete]: ... +def duplication_divergence_graph(n: int, p: float, seed=None) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/expanders.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/expanders.pyi index 6a6eb131b9f0..72d061145a1a 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/expanders.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/expanders.pyi @@ -1,6 +1,8 @@ +from _typeshed import Incomplete from typing_extensions import deprecated from networkx.classes.graph import Graph, _Node +from networkx.classes.multigraph import MultiGraph from networkx.utils.backends import _dispatchable __all__ = [ @@ -14,13 +16,15 @@ __all__ = [ ] @_dispatchable -def margulis_gabber_galil_graph(n, create_using=None): ... +def margulis_gabber_galil_graph( + n: int, create_using: MultiGraph[Incomplete] | type[MultiGraph[Incomplete]] | None = None +) -> Graph[Incomplete]: ... @_dispatchable -def chordal_cycle_graph(p, create_using=None): ... +def chordal_cycle_graph(p: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def paley_graph(p, create_using=None): ... +def paley_graph(p: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def maybe_regular_expander_graph(n, d, *, create_using=None, max_tries: int = 100, seed=None): ... +def maybe_regular_expander_graph(n: int, d: int, *, create_using=None, max_tries: int = 100, seed=None) -> Graph[Incomplete]: ... @deprecated( "`maybe_regular_expander` is a deprecated alias for `maybe_regular_expander_graph`. " "Use `maybe_regular_expander_graph` instead." @@ -29,4 +33,4 @@ def maybe_regular_expander(n, d, *, create_using=None, max_tries: int = 100, see @_dispatchable def is_regular_expander(G: Graph[_Node], *, epsilon: float = 0) -> bool: ... @_dispatchable -def random_regular_expander_graph(n, d, *, epsilon=0, create_using=None, max_tries=100, seed=None): ... +def random_regular_expander_graph(n: int, d: int, *, epsilon=0, create_using=None, max_tries=100, seed=None): ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/geometric.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/geometric.pyi index fcc25a9fd93e..1d12fb9c17be 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/geometric.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/geometric.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Callable, Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -15,23 +16,62 @@ __all__ = [ ] @_dispatchable -def geometric_edges(G: Graph[_Node], radius, p: float = 2): ... +def geometric_edges(G: Graph[_Node], radius: float, p: float = 2) -> list[Incomplete]: ... @_dispatchable -def random_geometric_graph(n, radius, dim: int = 2, pos=None, p: float = 2, seed=None): ... +def random_geometric_graph( + n: int | Iterable[Incomplete], + radius: float, + dim: int = 2, + pos: dict[Incomplete, Incomplete] | None = None, + p: float = 2, + seed=None, +) -> Graph[Incomplete]: ... @_dispatchable -def soft_random_geometric_graph(n, radius, dim: int = 2, pos=None, p: float = 2, p_dist=None, seed=None): ... +def soft_random_geometric_graph( + n: int | Iterable[Incomplete], + radius: float, + dim: int = 2, + pos: dict[Incomplete, Incomplete] | None = None, + p: float = 2, + p_dist: Callable[..., Incomplete] | None = None, + seed=None, +) -> Graph[Incomplete]: ... @_dispatchable -def geographical_threshold_graph(n, theta, dim: int = 2, pos=None, weight=None, metric=None, p_dist=None, seed=None): ... +def geographical_threshold_graph( + n: int | Iterable[Incomplete], + theta: float, + dim: int = 2, + pos: dict[Incomplete, Incomplete] | None = None, + weight: dict[Incomplete, Incomplete] | None = None, + metric: Callable[..., Incomplete] | None = None, + p_dist: Callable[..., Incomplete] | None = None, + seed=None, +) -> Graph[Incomplete]: ... @_dispatchable def waxman_graph( - n, beta: float = 0.4, alpha: float = 0.1, L=None, domain=(0, 0, 1, 1), metric=None, seed=None + n: int | Iterable[Incomplete], + beta: float = 0.4, + alpha: float = 0.1, + L: float | None = None, + domain: tuple[float, float, float, float] = (0, 0, 1, 1), + metric: Callable[..., Incomplete] | None = None, + seed=None, ) -> Graph[Incomplete]: ... # docstring marks p as int, but it still works with floats. So I think it's better for consistency @_dispatchable -def navigable_small_world_graph(n, p: float = 1, q: int = 1, r: float = 2, dim: int = 2, seed=None): ... +def navigable_small_world_graph(n: int, p: float = 1, q: int = 1, r: float = 2, dim: int = 2, seed=None): ... @_dispatchable -def thresholded_random_geometric_graph(n, radius, theta, dim: int = 2, pos=None, weight=None, p: float = 2, seed=None): ... +def thresholded_random_geometric_graph( + n: int | Iterable[Incomplete], + radius: float, + theta: float, + dim: int = 2, + pos: dict[Incomplete, Incomplete] | None = None, + weight: dict[Incomplete, Incomplete] | None = None, + p: float = 2, + seed=None, +) -> Graph[Incomplete]: ... @_dispatchable def geometric_soft_configuration_graph( *, beta, n=None, gamma=None, mean_degree=None, kappas=None, seed=None diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/harary_graph.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/harary_graph.pyi index 2f709f2c94bd..bf2d609225a0 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/harary_graph.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/harary_graph.pyi @@ -1,8 +1,15 @@ +from _typeshed import Incomplete + +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable __all__ = ["hnm_harary_graph", "hkn_harary_graph"] @_dispatchable -def hnm_harary_graph(n, m, create_using=None): ... +def hnm_harary_graph( + n: int, m: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None +) -> Graph[Incomplete]: ... @_dispatchable -def hkn_harary_graph(k, n, create_using=None): ... +def hkn_harary_graph( + k: int, n: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/internet_as_graphs.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/internet_as_graphs.pyi index 05932bf9e32d..eb120b1fd7d5 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/internet_as_graphs.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/internet_as_graphs.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Mapping +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable __all__ = ["random_internet_as_graph"] @@ -25,21 +26,21 @@ class AS_graph_generator: t_c: float def __init__(self, n, seed) -> None: ... G: Incomplete - def t_graph(self): ... + def t_graph(self) -> Graph[Incomplete]: ... def add_edge(self, i, j, kind) -> None: ... def choose_peer_pref_attach(self, node_list): ... def choose_node_pref_attach(self, node_list): ... def add_customer(self, i, j) -> None: ... - def add_node(self, i, kind, reg2prob, avg_deg, t_edge_prob): ... - def add_m_peering_link(self, m, to_kind) -> bool: ... - def add_cp_peering_link(self, cp, to_kind) -> bool: ... + def add_node(self, i, kind: str, reg2prob: float, avg_deg: float, t_edge_prob: float): ... + def add_m_peering_link(self, m, to_kind: str) -> bool: ... + def add_cp_peering_link(self, cp, to_kind: str) -> bool: ... regions: Incomplete - def graph_regions(self, rn) -> None: ... + def graph_regions(self, rn: int) -> None: ... def add_peering_links(self, from_kind, to_kind) -> None: ... customers: Incomplete providers: Incomplete nodes: Incomplete - def generate(self): ... + def generate(self) -> Graph[Incomplete]: ... @_dispatchable -def random_internet_as_graph(n, seed=None): ... +def random_internet_as_graph(n: int, seed=None) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/intersection.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/intersection.pyi index 271deaec7bc4..b631d2b1e31c 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/intersection.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/intersection.pyi @@ -3,8 +3,8 @@ from networkx.utils.backends import _dispatchable __all__ = ["uniform_random_intersection_graph", "k_random_intersection_graph", "general_random_intersection_graph"] @_dispatchable -def uniform_random_intersection_graph(n, m, p, seed=None): ... +def uniform_random_intersection_graph(n: int, m: int, p: float, seed=None): ... @_dispatchable -def k_random_intersection_graph(n, m, k, seed=None): ... +def k_random_intersection_graph(n: int, m: int, k: float, seed=None): ... @_dispatchable -def general_random_intersection_graph(n, m, p, seed=None): ... +def general_random_intersection_graph(n: int, m: int, p: list[float], seed=None): ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/interval_graph.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/interval_graph.pyi index 2901b87d003b..89857e689d47 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/interval_graph.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/interval_graph.pyi @@ -1,6 +1,10 @@ +from _typeshed import Incomplete +from collections.abc import Iterable + +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable __all__ = ["interval_graph"] @_dispatchable -def interval_graph(intervals): ... +def interval_graph(intervals: Iterable[Incomplete]) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/lattice.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/lattice.pyi index e82eb72ae6da..1b365e7815b3 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/lattice.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/lattice.pyi @@ -1,14 +1,32 @@ +from _typeshed import Incomplete +from collections.abc import Iterable + +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable __all__ = ["grid_2d_graph", "grid_graph", "hypercube_graph", "triangular_lattice_graph", "hexagonal_lattice_graph"] @_dispatchable -def grid_2d_graph(m, n, periodic: bool = False, create_using=None): ... +def grid_2d_graph( + m, n, periodic: bool = False, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None +) -> Graph[Incomplete]: ... @_dispatchable -def grid_graph(dim, periodic: bool = False): ... +def grid_graph(dim: list[float] | tuple[float, ...] | Iterable[Incomplete], periodic: bool = False) -> Graph[Incomplete]: ... @_dispatchable -def hypercube_graph(n): ... +def hypercube_graph(n: int) -> Graph[Incomplete]: ... @_dispatchable -def triangular_lattice_graph(m, n, periodic: bool = False, with_positions: bool = True, create_using=None): ... +def triangular_lattice_graph( + m: int, + n: int, + periodic: bool = False, + with_positions: bool = True, + create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None, +) -> Graph[Incomplete]: ... @_dispatchable -def hexagonal_lattice_graph(m, n, periodic: bool = False, with_positions: bool = True, create_using=None): ... +def hexagonal_lattice_graph( + m: int, + n: int, + periodic: bool = False, + with_positions: bool = True, + create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None, +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/line.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/line.pyi index 3d2ba771c60c..a9cd56c23186 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/line.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/line.pyi @@ -1,9 +1,11 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["line_graph", "inverse_line_graph"] @_dispatchable -def line_graph(G: Graph[_Node], create_using=None): ... +def line_graph(G: Graph[_Node], create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def inverse_line_graph(G: Graph[_Node]): ... +def inverse_line_graph(G: Graph[_Node]) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/mycielski.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/mycielski.pyi index 24b24f026bd8..ba383edc6ed0 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/mycielski.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/mycielski.pyi @@ -1,9 +1,11 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["mycielskian", "mycielski_graph"] @_dispatchable -def mycielskian(G: Graph[_Node], iterations: int = 1): ... +def mycielskian(G: Graph[_Node], iterations: int = 1) -> Graph[Incomplete]: ... @_dispatchable -def mycielski_graph(n): ... +def mycielski_graph(n: int) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi index 281382b32d23..d8bd5a19ee29 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi @@ -6,6 +6,6 @@ from networkx.utils.backends import _dispatchable __all__ = ["nonisomorphic_trees", "number_of_nonisomorphic_trees"] @_dispatchable -def nonisomorphic_trees(order) -> Generator[list[Incomplete]]: ... +def nonisomorphic_trees(order: int) -> Generator[list[Incomplete]]: ... @_dispatchable -def number_of_nonisomorphic_trees(order): ... +def number_of_nonisomorphic_trees(order: int) -> int: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/random_graphs.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/random_graphs.pyi index 3345d07afce6..d9e1d6c05571 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/random_graphs.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/random_graphs.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Callable, Iterable from typing_extensions import deprecated from networkx.utils.backends import _dispatchable @@ -29,43 +30,54 @@ __all__ = [ ] @_dispatchable -def fast_gnp_random_graph(n, p, seed=None, directed: bool = False, *, create_using=None): ... +def fast_gnp_random_graph(n: int, p: float, seed=None, directed: bool = False, *, create_using=None): ... @_dispatchable -def gnp_random_graph(n, p, seed=None, directed: bool = False, *, create_using=None): ... +def gnp_random_graph(n: int, p: float, seed=None, directed: bool = False, *, create_using=None): ... binomial_graph = gnp_random_graph erdos_renyi_graph = gnp_random_graph @_dispatchable -def dense_gnm_random_graph(n, m, seed=None, *, create_using=None): ... +def dense_gnm_random_graph(n: int, m: int, seed=None, *, create_using=None): ... @_dispatchable -def gnm_random_graph(n, m, seed=None, directed: bool = False, *, create_using=None): ... +def gnm_random_graph(n: int, m: int, seed=None, directed: bool = False, *, create_using=None): ... @_dispatchable -def newman_watts_strogatz_graph(n, k, p, seed=None, *, create_using=None): ... +def newman_watts_strogatz_graph(n: int, k: int, p: float, seed=None, *, create_using=None): ... @_dispatchable -def watts_strogatz_graph(n, k, p, seed=None, *, create_using=None): ... +def watts_strogatz_graph(n: int, k: int, p: float, seed=None, *, create_using=None): ... @_dispatchable -def connected_watts_strogatz_graph(n, k, p, tries: int = 100, seed=None, *, create_using=None): ... +def connected_watts_strogatz_graph(n: int, k: int, p: float, tries: int = 100, seed=None, *, create_using=None): ... @_dispatchable -def random_regular_graph(d, n, seed=None, *, create_using=None): ... +def random_regular_graph(d: int, n: int, seed=None, *, create_using=None): ... @_dispatchable -def barabasi_albert_graph(n, m, seed=None, initial_graph=None, *, create_using=None) -> Graph[Incomplete]: ... +def barabasi_albert_graph( + n: int, m: int, seed=None, initial_graph: Graph[Incomplete] | None = None, *, create_using=None +) -> Graph[Incomplete]: ... @_dispatchable -def dual_barabasi_albert_graph(n, m1, m2, p, seed=None, initial_graph=None, *, create_using=None) -> Graph[Incomplete]: ... +def dual_barabasi_albert_graph( + n: int, m1: int, m2: int, p: float, seed=None, initial_graph: Graph[Incomplete] | None = None, *, create_using=None +) -> Graph[Incomplete]: ... @_dispatchable -def extended_barabasi_albert_graph(n, m, p, q, seed=None, *, create_using=None) -> Graph[Incomplete]: ... +def extended_barabasi_albert_graph(n: int, m: int, p: float, q: float, seed=None, *, create_using=None) -> Graph[Incomplete]: ... @_dispatchable -def powerlaw_cluster_graph(n, m, p, seed=None, *, create_using=None): ... +def powerlaw_cluster_graph(n: int, m: int, p: float, seed=None, *, create_using=None): ... @_dispatchable -def random_lobster_graph(n, p1, p2, seed=None, *, create_using=None): ... +def random_lobster_graph(n: int, p1: float, p2: float, seed=None, *, create_using=None): ... @_dispatchable @deprecated("`random_lobster` is a deprecated alias for `random_lobster_graph`. Use `random_lobster_graph` instead.") def random_lobster(n, p1, p2, seed=None, *, create_using=None): ... @_dispatchable -def random_shell_graph(constructor, seed=None, *, create_using=None): ... +def random_shell_graph(constructor: Iterable[tuple[int, int, float]], seed=None, *, create_using=None): ... @_dispatchable -def random_powerlaw_tree(n, gamma: float = 3, seed=None, tries: int = 100, *, create_using=None): ... +def random_powerlaw_tree(n: int, gamma: float = 3, seed=None, tries: int = 100, *, create_using=None): ... @_dispatchable -def random_powerlaw_tree_sequence(n, gamma: float = 3, seed=None, tries: int = 100): ... +def random_powerlaw_tree_sequence(n: int, gamma: float = 3, seed=None, tries: int = 100): ... @_dispatchable -def random_kernel_graph(n, kernel_integral, kernel_root=None, seed=None, *, create_using=None): ... +def random_kernel_graph( + n: int, + kernel_integral: Callable[..., Incomplete], + kernel_root: Callable[..., Incomplete] | None = None, + seed=None, + *, + create_using=None, +): ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/small.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/small.pyi index d9a242eb19f8..c440b1d46c74 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/small.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/small.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete + +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable __all__ = [ @@ -28,50 +31,50 @@ __all__ = [ ] @_dispatchable -def LCF_graph(n, shift_list, repeats, create_using=None): ... +def LCF_graph(n: int, shift_list: list[Incomplete], repeats: int, create_using=None) -> Graph[Incomplete]: ... @_dispatchable -def bull_graph(create_using=None): ... +def bull_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def chvatal_graph(create_using=None): ... +def chvatal_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def cubical_graph(create_using=None): ... +def cubical_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def desargues_graph(create_using=None): ... +def desargues_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def diamond_graph(create_using=None): ... +def diamond_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def dodecahedral_graph(create_using=None): ... +def dodecahedral_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def frucht_graph(create_using=None): ... +def frucht_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def heawood_graph(create_using=None): ... +def heawood_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def hoffman_singleton_graph(): ... +def hoffman_singleton_graph() -> Graph[Incomplete]: ... @_dispatchable -def house_graph(create_using=None): ... +def house_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def house_x_graph(create_using=None): ... +def house_x_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def icosahedral_graph(create_using=None): ... +def icosahedral_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def krackhardt_kite_graph(create_using=None): ... +def krackhardt_kite_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def moebius_kantor_graph(create_using=None): ... +def moebius_kantor_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def octahedral_graph(create_using=None): ... +def octahedral_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def pappus_graph(): ... +def pappus_graph() -> Graph[Incomplete]: ... @_dispatchable -def petersen_graph(create_using=None): ... +def petersen_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def generalized_petersen_graph(n: int, k: int, *, create_using=None): ... +def generalized_petersen_graph(n: int, k: int, *, create_using=None) -> Graph[Incomplete]: ... @_dispatchable -def sedgewick_maze_graph(create_using=None): ... +def sedgewick_maze_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def tetrahedral_graph(create_using=None): ... +def tetrahedral_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def truncated_cube_graph(create_using=None): ... +def truncated_cube_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def truncated_tetrahedron_graph(create_using=None): ... +def truncated_tetrahedron_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... @_dispatchable -def tutte_graph(create_using=None): ... +def tutte_graph(create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/spectral_graph_forge.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/spectral_graph_forge.pyi index 7321e2ab7e21..2822fc3544a7 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/spectral_graph_forge.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/spectral_graph_forge.pyi @@ -6,4 +6,4 @@ from networkx.utils.backends import _dispatchable __all__ = ["spectral_graph_forge"] @_dispatchable -def spectral_graph_forge(G: Graph[_Node], alpha, transformation: str = "identity", seed=None) -> Graph[Incomplete]: ... +def spectral_graph_forge(G: Graph[_Node], alpha: float, transformation: str = "identity", seed=None) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/sudoku.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/sudoku.pyi index 4538521973cc..89a44087d4be 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/sudoku.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/sudoku.pyi @@ -1,6 +1,9 @@ +from _typeshed import Incomplete + +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable __all__ = ["sudoku_graph"] @_dispatchable -def sudoku_graph(n: int = 3): ... +def sudoku_graph(n: int = 3) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/time_series.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/time_series.pyi index b240695b18c4..aa9a3b755384 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/time_series.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/time_series.pyi @@ -1,6 +1,10 @@ +from _typeshed import Incomplete +from collections.abc import Sequence + +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable __all__ = ["visibility_graph"] @_dispatchable -def visibility_graph(series): ... +def visibility_graph(series: Sequence[float]) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/trees.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/trees.pyi index 9ebd32f0d81f..eb63cdb49e94 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/trees.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/trees.pyi @@ -1,5 +1,7 @@ from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable from ..classes.digraph import DiGraph @@ -16,18 +18,18 @@ __all__ = [ ] @_dispatchable -def prefix_tree(paths) -> DiGraph[Incomplete]: ... +def prefix_tree(paths: Iterable[Incomplete]) -> DiGraph[Incomplete]: ... @_dispatchable -def prefix_tree_recursive(paths) -> DiGraph[Incomplete]: ... +def prefix_tree_recursive(paths: Iterable[Incomplete]) -> DiGraph[Incomplete]: ... @_dispatchable -def random_labeled_tree(n, *, seed=None): ... +def random_labeled_tree(n: int, *, seed=None): ... @_dispatchable -def random_labeled_rooted_tree(n, *, seed=None): ... +def random_labeled_rooted_tree(n: int, *, seed=None) -> Graph[Incomplete]: ... @_dispatchable -def random_unlabeled_rooted_tree(n, *, number_of_trees=None, seed=None) -> Incomplete | list[Incomplete]: ... +def random_unlabeled_rooted_tree(n: int, *, number_of_trees=None, seed=None) -> Incomplete | list[Incomplete]: ... @_dispatchable -def random_labeled_rooted_forest(n, *, seed=None): ... +def random_labeled_rooted_forest(n: int, *, seed=None) -> Graph[Incomplete]: ... @_dispatchable -def random_unlabeled_rooted_forest(n, *, q=None, number_of_forests=None, seed=None) -> Incomplete | list[Incomplete]: ... +def random_unlabeled_rooted_forest(n: int, *, q=None, number_of_forests=None, seed=None) -> Incomplete | list[Incomplete]: ... @_dispatchable -def random_unlabeled_tree(n, *, number_of_trees=None, seed=None) -> Incomplete | list[Incomplete]: ... +def random_unlabeled_tree(n: int, *, number_of_trees=None, seed=None) -> Incomplete | list[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/generators/triads.pyi b/python/helpers/typeshed/stubs/networkx/networkx/generators/triads.pyi index 4e85d0677afa..66fb47f93757 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/generators/triads.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/generators/triads.pyi @@ -9,4 +9,4 @@ __all__ = ["triad_graph"] TRIAD_EDGES: Final[dict[str, list[str]]] @_dispatchable -def triad_graph(triad_name) -> DiGraph[Incomplete]: ... +def triad_graph(triad_name: str) -> DiGraph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/lazy_imports.pyi b/python/helpers/typeshed/stubs/networkx/networkx/lazy_imports.pyi index c5bc64e495c0..f806469927aa 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/lazy_imports.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/lazy_imports.pyi @@ -1,11 +1,14 @@ import types +from _typeshed import Incomplete __all__ = ["attach", "_lazy_import"] -def attach(module_name, submodules=None, submod_attrs=None): ... +def attach( + module_name: str, submodules: set[Incomplete] | None = None, submod_attrs: dict[Incomplete, Incomplete] | None = None +): ... class DelayedImportErrorModule(types.ModuleType): def __init__(self, frame_data, *args, **kwargs) -> None: ... def __getattr__(self, x) -> None: ... -def _lazy_import(fullname) -> types.ModuleType | DelayedImportErrorModule: ... +def _lazy_import(fullname: str) -> types.ModuleType | DelayedImportErrorModule: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/adjlist.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/adjlist.pyi index d1013ef80255..f416e8f891f4 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/adjlist.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/adjlist.pyi @@ -1,4 +1,5 @@ -from collections.abc import Generator +from _typeshed import Incomplete, StrPath, SupportsRead, SupportsWrite +from collections.abc import Generator, Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,8 +7,23 @@ from networkx.utils.backends import _dispatchable __all__ = ["generate_adjlist", "write_adjlist", "parse_adjlist", "read_adjlist"] def generate_adjlist(G: Graph[_Node], delimiter: str = " ") -> Generator[str]: ... -def write_adjlist(G: Graph[_Node], path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8") -> None: ... +def write_adjlist( + G: Graph[_Node], path: StrPath | SupportsWrite[bytes], comments: str = "#", delimiter: str = " ", encoding: str = "utf-8" +) -> None: ... @_dispatchable -def parse_adjlist(lines, comments: str = "#", delimiter=None, create_using=None, nodetype=None): ... +def parse_adjlist( + lines: Iterable[str], + comments: str = "#", + delimiter: str | None = None, + create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None, + nodetype: type[Incomplete] | None = None, +) -> Graph[Incomplete]: ... @_dispatchable -def read_adjlist(path, comments: str = "#", delimiter=None, create_using=None, nodetype=None, encoding: str = "utf-8"): ... +def read_adjlist( + path: StrPath | SupportsRead[bytes], + comments: str = "#", + delimiter: str | None = None, + create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None, + nodetype: type[Incomplete] | None = None, + encoding: str = "utf-8", +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/edgelist.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/edgelist.pyi index feb3ab0587b3..8c2983fc3efc 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/edgelist.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/edgelist.pyi @@ -1,5 +1,5 @@ -from _typeshed import Incomplete -from collections.abc import Generator +from _typeshed import Incomplete, StrPath, SupportsRead, SupportsWrite +from collections.abc import Generator, Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -15,25 +15,42 @@ __all__ = [ def generate_edgelist(G: Graph[_Node], delimiter: str = " ", data: bool = True) -> Generator[Incomplete]: ... def write_edgelist( - G: Graph[_Node], path, comments: str = "#", delimiter: str = " ", data: bool = True, encoding: str = "utf-8" + G: Graph[_Node], + path: StrPath | SupportsWrite[bytes], + comments: str = "#", + delimiter: str = " ", + data: bool = True, + encoding: str = "utf-8", ) -> None: ... @_dispatchable -def parse_edgelist(lines, comments: str = "#", delimiter=None, create_using=None, nodetype=None, data: bool = True): ... +def parse_edgelist( + lines: Iterable[str], + comments: str = "#", + delimiter: str | None = None, + create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None, + nodetype: type[Incomplete] | None = None, + data: bool = True, +) -> Graph[Incomplete]: ... @_dispatchable def read_edgelist( - path, + path: StrPath | SupportsRead[bytes], comments: str = "#", - delimiter=None, - create_using=None, + delimiter: str | None = None, + create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None, nodetype=None, data: bool = True, edgetype=None, encoding: str = "utf-8", -): ... +) -> Graph[Incomplete]: ... def write_weighted_edgelist( - G: Graph[_Node], path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8" + G: Graph[_Node], path: StrPath | SupportsWrite[bytes], comments: str = "#", delimiter: str = " ", encoding: str = "utf-8" ) -> None: ... @_dispatchable def read_weighted_edgelist( - path, comments: str = "#", delimiter=None, create_using=None, nodetype=None, encoding: str = "utf-8" -): ... + path: StrPath | SupportsRead[bytes], + comments: str = "#", + delimiter: str | None = None, + create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None, + nodetype=None, + encoding: str = "utf-8", +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/gexf.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/gexf.pyi index dee0838cf004..bebb998dfe93 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/gexf.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/gexf.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, StrPath, SupportsRead, SupportsWrite from collections.abc import Generator from typing import Final, Literal @@ -7,12 +7,23 @@ from networkx.utils.backends import _dispatchable __all__ = ["write_gexf", "read_gexf", "relabel_gexf_graph", "generate_gexf"] -def write_gexf(G: Graph[_Node], path, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft") -> None: ... +def write_gexf( + G: Graph[_Node], + path: StrPath | SupportsWrite[bytes], + encoding: str = "utf-8", + prettyprint: bool = True, + version: str = "1.2draft", +) -> None: ... def generate_gexf( G: Graph[_Node], encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft" ) -> Generator[Incomplete, Incomplete]: ... @_dispatchable -def read_gexf(path, node_type=None, relabel: bool = False, version: str = "1.2draft"): ... +def read_gexf( + path: StrPath | SupportsRead[bytes], + node_type: type[Incomplete] | None = None, + relabel: bool = False, + version: str = "1.2draft", +) -> Graph[Incomplete]: ... class GEXF: versions: Incomplete @@ -69,4 +80,4 @@ class GEXFReader(GEXF): def decode_attr_elements(self, gexf_keys, obj_xml): ... def find_gexf_attributes(self, attributes_element): ... -def relabel_gexf_graph(G: Graph[_Node]): ... +def relabel_gexf_graph(G: Graph[_Node]) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/gml.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/gml.pyi index 23817841dc6d..3a9e321d4edf 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/gml.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/gml.pyi @@ -1,5 +1,5 @@ -from _typeshed import Incomplete -from collections.abc import Generator +from _typeshed import Incomplete, StrPath, SupportsRead, SupportsWrite +from collections.abc import Callable, Generator, Iterable from enum import Enum from typing import Final, Generic, NamedTuple, TypeVar @@ -14,9 +14,13 @@ def escape(text): ... def unescape(text): ... def literal_destringizer(rep: str): ... @_dispatchable -def read_gml(path, label: str = "label", destringizer=None): ... +def read_gml( + path: StrPath | SupportsRead[bytes], label: str = "label", destringizer: Callable[..., Incomplete] | None = None +) -> Graph[Incomplete]: ... @_dispatchable -def parse_gml(lines, label: str = "label", destringizer=None): ... +def parse_gml( + lines: str | Iterable[str], label: str = "label", destringizer: Callable[..., Incomplete] | None = None +) -> Graph[Incomplete]: ... class Pattern(Enum): KEYS = 0 @@ -37,5 +41,7 @@ LIST_START_VALUE: Final = "_networkx_list_start" def parse_gml_lines(lines, label, destringizer): ... def literal_stringizer(value) -> str: ... -def generate_gml(G: Graph[_Node], stringizer=None) -> Generator[Incomplete, Incomplete]: ... -def write_gml(G: Graph[_Node], path, stringizer=None) -> None: ... +def generate_gml(G: Graph[_Node], stringizer: Callable[..., Incomplete] | None = None) -> Generator[Incomplete, Incomplete]: ... +def write_gml( + G: Graph[_Node], path: StrPath | SupportsWrite[bytes], stringizer: Callable[..., Incomplete] | None = None +) -> None: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/graph6.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/graph6.pyi index 31445344352e..17cd91d94b58 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/graph6.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/graph6.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, StrPath, SupportsRead, SupportsWrite from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -7,11 +7,13 @@ from networkx.utils.backends import _dispatchable __all__ = ["from_graph6_bytes", "read_graph6", "to_graph6_bytes", "write_graph6"] @_dispatchable -def from_graph6_bytes(bytes_in) -> Graph[Incomplete]: ... -def to_graph6_bytes(G: Graph[_Node], nodes=None, header: bool = True): ... +def from_graph6_bytes(bytes_in: bytes) -> Graph[Incomplete]: ... +def to_graph6_bytes(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, header: bool = True): ... @_dispatchable -def read_graph6(path): ... -def write_graph6(G: Graph[_Node], path, nodes=None, header: bool = True): ... +def read_graph6(path: StrPath | SupportsRead[bytes]) -> Graph[Incomplete]: ... +def write_graph6( + G: Graph[_Node], path: StrPath | SupportsWrite[bytes], nodes: Iterable[Incomplete] | None = None, header: bool = True +): ... def write_graph6_file(G: Graph[_Node], f, nodes: Iterable[Incomplete] | None = None, header: bool = True): ... def data_to_n(data): ... def n_to_data(n): ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/graphml.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/graphml.pyi index f2395a328f8e..4beb539a4ca7 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/graphml.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/graphml.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, StrPath, SupportsRead, SupportsWrite from collections.abc import Generator from typing import Final, Literal @@ -18,29 +18,40 @@ __all__ = [ def write_graphml_xml( G: Graph[_Node], - path, + path: StrPath | SupportsWrite[bytes], encoding: str = "utf-8", prettyprint: bool = True, infer_numeric_types: bool = False, named_key_ids: bool = False, - edge_id_from_attribute=None, + edge_id_from_attribute: str | None = None, ) -> None: ... def write_graphml_lxml( G: Graph[_Node], - path, + path: StrPath | SupportsWrite[bytes], encoding: str = "utf-8", prettyprint: bool = True, infer_numeric_types: bool = False, named_key_ids: bool = False, - edge_id_from_attribute=None, + edge_id_from_attribute: str | None = None, ): ... def generate_graphml( - G: Graph[_Node], encoding: str = "utf-8", prettyprint: bool = True, named_key_ids: bool = False, edge_id_from_attribute=None + G: Graph[_Node], + encoding: str = "utf-8", + prettyprint: bool = True, + named_key_ids: bool = False, + edge_id_from_attribute: str | None = None, ) -> Generator[Incomplete, Incomplete]: ... @_dispatchable -def read_graphml(path, node_type=..., edge_key_type=..., force_multigraph: bool = False): ... +def read_graphml( + path: StrPath | SupportsRead[bytes], + node_type: type[Incomplete] = ..., + edge_key_type: type[Incomplete] = ..., + force_multigraph: bool = False, +) -> Graph[Incomplete]: ... @_dispatchable -def parse_graphml(graphml_string, node_type=..., edge_key_type=..., force_multigraph: bool = False): ... +def parse_graphml( + graphml_string: str, node_type: type[Incomplete] = ..., edge_key_type: type[Incomplete] = ..., force_multigraph: bool = False +) -> Graph[Incomplete]: ... class GraphML: NS_GRAPHML: Final[str] diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi index 0fb7df4efe64..e1728b1cc49f 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from typing import Any from networkx.classes.graph import Graph, _Node @@ -6,6 +7,11 @@ from networkx.utils.backends import _dispatchable __all__ = ["adjacency_data", "adjacency_graph"] # Any: Complex type union -def adjacency_data(G: Graph[_Node], attrs={"id": "id", "key": "key"}) -> dict[str, Any]: ... +def adjacency_data(G: Graph[_Node], attrs: dict[Incomplete, Incomplete] = {"id": "id", "key": "key"}) -> dict[str, Any]: ... @_dispatchable -def adjacency_graph(data, directed: bool = False, multigraph: bool = True, attrs={"id": "id", "key": "key"}): ... +def adjacency_graph( + data: dict[Incomplete, Incomplete], + directed: bool = False, + multigraph: bool = True, + attrs: dict[Incomplete, Incomplete] = {"id": "id", "key": "key"}, +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi index 7fb98fa14ca8..959ffb3b2ed5 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from typing import Any from networkx.classes.graph import Graph, _Node @@ -8,4 +9,4 @@ __all__ = ["cytoscape_data", "cytoscape_graph"] # Any: Complex type union def cytoscape_data(G: Graph[_Node], name: str = "name", ident: str = "id") -> dict[str, Any]: ... @_dispatchable -def cytoscape_graph(data, name: str = "name", ident: str = "id"): ... +def cytoscape_graph(data: dict[Incomplete, Incomplete], name: str = "name", ident: str = "id") -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi index 57f07ceddd77..15c7da4e2da3 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -12,10 +14,10 @@ def node_link_data( key: str = "key", edges: str = "edges", nodes: str = "nodes", -): ... +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def node_link_graph( - data, + data: dict[Incomplete, Incomplete], directed: bool = False, multigraph: bool = True, attrs=None, @@ -26,4 +28,4 @@ def node_link_graph( key: str = "key", edges: str = "edges", nodes: str = "nodes", -): ... +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/tree.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/tree.pyi index 8b389c5bf242..052e8b5fb2b5 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/tree.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/json_graph/tree.pyi @@ -1,9 +1,11 @@ +from _typeshed import Incomplete + from networkx.classes.digraph import DiGraph from networkx.classes.graph import _Node from networkx.utils.backends import _dispatchable __all__ = ["tree_data", "tree_graph"] -def tree_data(G: DiGraph[_Node], root, ident: str = "id", children: str = "children"): ... +def tree_data(G: DiGraph[_Node], root, ident: str = "id", children: str = "children") -> dict[Incomplete, Incomplete]: ... @_dispatchable -def tree_graph(data, ident: str = "id", children: str = "children"): ... +def tree_graph(data: dict[Incomplete, Incomplete], ident: str = "id", children: str = "children") -> DiGraph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/leda.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/leda.pyi index 733005d1ce64..ddec97493fe4 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/leda.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/leda.pyi @@ -1,8 +1,12 @@ +from _typeshed import Incomplete, StrPath, SupportsRead +from collections.abc import Iterable + +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable __all__ = ["read_leda", "parse_leda"] @_dispatchable -def read_leda(path, encoding: str = "UTF-8"): ... +def read_leda(path: StrPath | SupportsRead[bytes], encoding: str = "UTF-8") -> Graph[Incomplete]: ... @_dispatchable -def parse_leda(lines): ... +def parse_leda(lines: str | Iterable[str]) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi index 6de1e02a4e8b..ae269ad60fb1 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi @@ -1,4 +1,5 @@ -from collections.abc import Generator +from _typeshed import Incomplete, StrPath, SupportsRead, SupportsWrite +from collections.abc import Generator, Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,10 +7,25 @@ from networkx.utils.backends import _dispatchable __all__ = ["generate_multiline_adjlist", "write_multiline_adjlist", "parse_multiline_adjlist", "read_multiline_adjlist"] def generate_multiline_adjlist(G: Graph[_Node], delimiter: str = " ") -> Generator[str]: ... -def write_multiline_adjlist(G: Graph[_Node], path, delimiter=" ", comments="#", encoding="utf-8") -> None: ... +def write_multiline_adjlist( + G: Graph[_Node], path: StrPath | SupportsWrite[bytes], delimiter: str = " ", comments: str = "#", encoding: str = "utf-8" +) -> None: ... @_dispatchable -def parse_multiline_adjlist(lines, comments: str = "#", delimiter=None, create_using=None, nodetype=None, edgetype=None): ... +def parse_multiline_adjlist( + lines: Iterable[str], + comments: str = "#", + delimiter: str | None = None, + create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None, + nodetype: type[Incomplete] | None = None, + edgetype: type[Incomplete] | None = None, +) -> Graph[Incomplete]: ... @_dispatchable def read_multiline_adjlist( - path, comments: str = "#", delimiter=None, create_using=None, nodetype=None, edgetype=None, encoding: str = "utf-8" -): ... + path: StrPath | SupportsRead[bytes], + comments: str = "#", + delimiter: str | None = None, + create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None, + nodetype: type[Incomplete] | None = None, + edgetype: type[Incomplete] | None = None, + encoding: str = "utf-8", +) -> Graph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/p2g.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/p2g.pyi index 0855b0e0c39b..22d670a68c16 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/p2g.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/p2g.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, StrPath, SupportsRead from networkx.classes.graph import Graph, _Node from networkx.classes.multidigraph import MultiDiGraph @@ -6,6 +6,6 @@ from networkx.utils.backends import _dispatchable def write_p2g(G: Graph[_Node], path, encoding: str = "utf-8") -> None: ... @_dispatchable -def read_p2g(path, encoding: str = "utf-8") -> MultiDiGraph[Incomplete]: ... +def read_p2g(path: StrPath | SupportsRead[str], encoding: str = "utf-8") -> MultiDiGraph[Incomplete]: ... @_dispatchable def parse_p2g(lines) -> MultiDiGraph[Incomplete]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/pajek.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/pajek.pyi index ec6d1d0d68b9..efc593fb2122 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/pajek.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/pajek.pyi @@ -1,15 +1,16 @@ -from _typeshed import Incomplete -from collections.abc import Generator +from _typeshed import Incomplete, StrPath, SupportsRead, SupportsWrite +from collections.abc import Generator, Iterable from networkx.classes.graph import Graph, _Node +from networkx.classes.multidigraph import MultiDiGraph from networkx.utils.backends import _dispatchable __all__ = ["read_pajek", "parse_pajek", "generate_pajek", "write_pajek"] def generate_pajek(G: Graph[_Node]) -> Generator[Incomplete]: ... -def write_pajek(G: Graph[_Node], path, encoding: str = "UTF-8") -> None: ... +def write_pajek(G: Graph[_Node], path: StrPath | SupportsWrite[bytes], encoding: str = "UTF-8") -> None: ... @_dispatchable -def read_pajek(path, encoding: str = "UTF-8"): ... +def read_pajek(path: StrPath | SupportsRead[bytes], encoding: str = "UTF-8") -> MultiDiGraph[Incomplete]: ... @_dispatchable -def parse_pajek(lines): ... +def parse_pajek(lines: str | Iterable[str]) -> Graph[Incomplete]: ... def make_qstr(t): ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/sparse6.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/sparse6.pyi index 68ba4718d743..0e65988decab 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/sparse6.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/sparse6.pyi @@ -1,13 +1,17 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, StrPath, SupportsRead, SupportsWrite +from collections.abc import Iterable from networkx.classes.graph import Graph, _Node +from networkx.classes.multigraph import MultiGraph from networkx.utils.backends import _dispatchable __all__ = ["from_sparse6_bytes", "read_sparse6", "to_sparse6_bytes", "write_sparse6"] @_dispatchable -def from_sparse6_bytes(string) -> Graph[Incomplete]: ... -def to_sparse6_bytes(G: Graph[_Node], nodes=None, header: bool = True): ... +def from_sparse6_bytes(string: str) -> Graph[Incomplete]: ... +def to_sparse6_bytes(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, header: bool = True): ... @_dispatchable -def read_sparse6(path): ... -def write_sparse6(G: Graph[_Node], path, nodes=None, header: bool = True) -> None: ... +def read_sparse6(path: StrPath | SupportsRead[bytes]) -> MultiGraph[Incomplete]: ... +def write_sparse6( + G: Graph[_Node], path: StrPath | SupportsWrite[bytes], nodes: Iterable[Incomplete] | None = None, header: bool = True +) -> None: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/text.pyi b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/text.pyi index 3a1fe2e87e48..9a91460b0f54 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/readwrite/text.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/readwrite/text.pyi @@ -1,7 +1,9 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Callable, Collection, Generator from typing import ClassVar +from networkx.classes.graph import Graph + __all__ = ["generate_network_text", "write_network_text"] class BaseGlyphs: @@ -49,15 +51,20 @@ class UtfUndirectedGlyphs(UtfBaseGlyphs): vertical_edge: ClassVar[str] def generate_network_text( - graph, with_labels: bool = True, sources=None, max_depth=None, ascii_only: bool = False, vertical_chains: bool = False + graph: Graph[Incomplete], + with_labels: bool = True, + sources: Collection[Incomplete] | None = None, + max_depth: int | None = None, + ascii_only: bool = False, + vertical_chains: bool = False, ) -> Generator[Incomplete, None, Incomplete]: ... def write_network_text( - graph, - path=None, + graph: Graph[Incomplete], + path: Callable[..., Incomplete] | None = None, with_labels: bool = True, - sources=None, - max_depth=None, + sources: Collection[Incomplete] | None = None, + max_depth: int | None = None, ascii_only: bool = False, end: str = "\n", - vertical_chains=False, + vertical_chains: bool = False, ) -> None: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/relabel.pyi b/python/helpers/typeshed/stubs/networkx/networkx/relabel.pyi index 432bea7608b3..5607b6e08149 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/relabel.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/relabel.pyi @@ -26,5 +26,5 @@ def convert_node_labels_to_integers( G: Graph[Hashable], first_label: int = 0, ordering: Literal["default", "sorted", "increasing degree", "decreasing degree"] = "default", - label_attribute=None, + label_attribute: str | None = None, ) -> Graph[int]: ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/utils/decorators.pyi b/python/helpers/typeshed/stubs/networkx/networkx/utils/decorators.pyi index c12cc5421171..66d2cd8121d5 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/utils/decorators.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/utils/decorators.pyi @@ -1,22 +1,22 @@ from _typeshed import Incomplete -from collections.abc import Callable +from collections.abc import Callable, Sequence from typing import NamedTuple __all__ = ["not_implemented_for", "open_file", "nodes_or_number", "np_random_state", "py_random_state", "argmap"] -def not_implemented_for(*graph_types): ... -def open_file(path_arg, mode: str = "r"): ... -def nodes_or_number(which_args): ... -def np_random_state(random_state_argument): ... -def py_random_state(random_state_argument): ... +def not_implemented_for(*graph_types) -> Callable[..., Incomplete]: ... +def open_file(path_arg: str | int, mode: str = "r") -> Callable[..., Incomplete]: ... +def nodes_or_number(which_args: str | int | Sequence[str | int]) -> Callable[..., Incomplete]: ... +def np_random_state(random_state_argument: str | int) -> Callable[..., Incomplete]: ... +def py_random_state(random_state_argument: str | int) -> Callable[..., Incomplete]: ... class argmap: def __init__(self, func, *args, try_finally: bool = False) -> None: ... def __call__(self, f) -> Callable[..., Incomplete]: ... - def compile(self, f) -> Callable[..., Incomplete]: ... - def assemble(self, f): ... + def compile(self, f: Callable[..., Incomplete]) -> Callable[..., Incomplete]: ... + def assemble(self, f: Callable[..., Incomplete]): ... @classmethod - def signature(cls, f): ... + def signature(cls, f: Callable[..., Incomplete]): ... class Signature(NamedTuple): name: Incomplete diff --git a/python/helpers/typeshed/stubs/networkx/networkx/utils/misc.pyi b/python/helpers/typeshed/stubs/networkx/networkx/utils/misc.pyi index b87ff7572956..cc14f1bff944 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/utils/misc.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/utils/misc.pyi @@ -1,4 +1,6 @@ import random +from _typeshed import Incomplete +from collections.abc import Iterable, Iterator from types import ModuleType from typing import TypeAlias @@ -30,8 +32,8 @@ _RandomState: TypeAlias = int | _RandomNumberGenerator | None def flatten(obj, result=None): ... def make_list_of_ints(sequence): ... def dict_to_numpy_array(d, mapping=None): ... -def arbitrary_element(iterable): ... -def pairwise(iterable, cyclic: bool = False): ... +def arbitrary_element(iterable: Iterable[Incomplete]) -> Iterable[Incomplete]: ... +def pairwise(iterable: Iterable[Incomplete], cyclic: bool = False) -> Iterator[Incomplete]: ... def groups(many_to_one): ... def create_random_state(random_state=None): ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/utils/random_sequence.pyi b/python/helpers/typeshed/stubs/networkx/networkx/utils/random_sequence.pyi index 7bcca8b6d4b7..1092bf7ab0c0 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/utils/random_sequence.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/utils/random_sequence.pyi @@ -13,7 +13,7 @@ __all__ = [ def powerlaw_sequence(n, exponent: float = 2.0, seed=None): ... def is_valid_tree_degree_sequence(degree_sequence: Iterable[Incomplete]) -> tuple[bool, str]: ... -def zipf_rv(alpha, xmin: int = 1, seed=None) -> int: ... +def zipf_rv(alpha: float, xmin: int = 1, seed=None) -> int: ... def cumulative_distribution(distribution): ... def discrete_sequence(n, distribution=None, cdistribution=None, seed=None): ... def random_weighted_sample(mapping, k, seed=None): ... diff --git a/python/helpers/typeshed/stubs/networkx/networkx/utils/rcm.pyi b/python/helpers/typeshed/stubs/networkx/networkx/utils/rcm.pyi index ec892f2f6712..0f4f4ed838e3 100644 --- a/python/helpers/typeshed/stubs/networkx/networkx/utils/rcm.pyi +++ b/python/helpers/typeshed/stubs/networkx/networkx/utils/rcm.pyi @@ -1,11 +1,15 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Callable, Generator from networkx.classes.graph import Graph, _Node __all__ = ["cuthill_mckee_ordering", "reverse_cuthill_mckee_ordering"] -def cuthill_mckee_ordering(G: Graph[_Node], heuristic=None) -> Generator[Incomplete, Incomplete]: ... -def reverse_cuthill_mckee_ordering(G: Graph[_Node], heuristic=None): ... +def cuthill_mckee_ordering( + G: Graph[_Node], heuristic: Callable[..., Incomplete] | None = None +) -> Generator[Incomplete, Incomplete]: ... +def reverse_cuthill_mckee_ordering( + G: Graph[_Node], heuristic: Callable[..., Incomplete] | None = None +) -> Generator[Incomplete, Incomplete, Incomplete]: ... def connected_cuthill_mckee_ordering(G: Graph[_Node], heuristic=None): ... def pseudo_peripheral_node(G: Graph[_Node]): ... diff --git a/python/helpers/typeshed/stubs/peewee/METADATA.toml b/python/helpers/typeshed/stubs/peewee/METADATA.toml index 391b04704b37..c273586ad9dc 100644 --- a/python/helpers/typeshed/stubs/peewee/METADATA.toml +++ b/python/helpers/typeshed/stubs/peewee/METADATA.toml @@ -1,4 +1,4 @@ -version = "4.2.6" +version = "4.3.0" upstream-repository = "https://github.com/coleifer/peewee" # We're not providing stubs for all playhouse modules right now # https://github.com/python/typeshed/pull/11731#issuecomment-2065729058 diff --git a/python/helpers/typeshed/stubs/peewee/peewee.pyi b/python/helpers/typeshed/stubs/peewee/peewee.pyi index fbd003f762df..df34d586f5bb 100644 --- a/python/helpers/typeshed/stubs/peewee/peewee.pyi +++ b/python/helpers/typeshed/stubs/peewee/peewee.pyi @@ -74,6 +74,10 @@ SCOPE_COLUMN: Final = 16 CSQ_PARENTHESES_NEVER: Final = 0 CSQ_PARENTHESES_ALWAYS: Final = 1 CSQ_PARENTHESES_UNNESTED: Final = 2 +CSQ_PARENTHESES_GROUPED: Final = 3 +CSQ_FLAT: Final = 0 +CSQ_PARENS: Final = 1 +CSQ_WRAP: Final = 2 SNAKE_CASE_STEP1: Final[re.Pattern[str]] SNAKE_CASE_STEP2: Final[re.Pattern[str]] IDENTIFIER_RE: Final[re.Pattern[str]] @@ -946,7 +950,6 @@ class SqliteDatabase(Database): def unload_extension(self, extension) -> None: ... def attach(self, filename, name) -> bool: ... def detach(self, name) -> bool: ... - def last_insert_id(self, cursor, query_type=None): ... def begin(self, lock_type=None) -> None: ... def get_tables(self, schema: str | None = None) -> list[str]: ... def get_views(self, schema: str | None = None) -> list[ViewMetadata]: ... @@ -1027,7 +1030,6 @@ class PostgresqlDatabase(Database): **kwargs, ) -> None: ... def is_connection_usable(self) -> bool: ... - def last_insert_id(self, cursor, query_type=None): ... def begin(self, isolation_level: str | None = None) -> None: ... def get_tables(self, schema: str | None = None) -> list[str]: ... def get_views(self, schema: str | None = None) -> list[ViewMetadata]: ... @@ -1228,7 +1230,8 @@ class Field(ColumnBase, Generic[_V]): def adapt(self, value): ... def db_value(self, value): ... def python_value(self, value): ... - def to_value(self, value, case: bool = False) -> Value: ... + def to_value(self, value) -> Value: ... + def case_value(self, value) -> Value: ... def get_sort_key(self, ctx) -> tuple[Incomplete, ...]: ... def __sql__(self, ctx): ... def get_modifiers(self) -> list[int] | None: ... @@ -1597,8 +1600,10 @@ class ForeignKeyField(Field[_V]): cls, model: type[_M], *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FKKwargs] ) -> ForeignKeyField[_M]: ... @overload - # Untyped fallback: model given as a name/"self"/deferred ref, so the related type isn't known. - def __new__(cls, model: Any = ..., *args: Any, **kwargs: Unpack[_FKKwargs]) -> ForeignKeyField[Any]: ... + # Self-reference, the only string peewee accepts. Named refs use DeferredForeignKey. + def __new__( + cls, model: Literal["self"] = ..., *args: Any, null: bool = ..., **kwargs: Unpack[_FKKwargs] + ) -> ForeignKeyField[Any]: ... @property def field_type(self): ... # type: ignore[override] @@ -1616,7 +1621,8 @@ class ForeignKeyField(Field[_V]): class DeferredForeignKey(Field): field_kwargs: Incomplete rel_model_name: Incomplete - def __init__(self, rel_model_name, **kwargs) -> None: ... + # Model named by string, so the related type isn't knowable and null can't refine it. + def __init__(self, rel_model_name: str, *, null: bool = ..., **kwargs: Unpack[_FKKwargs]) -> None: ... __hash__ = object.__hash__ def __deepcopy__(self, memo=None) -> DeferredForeignKey: ... def set_model(self, rel_model) -> None: ... diff --git a/python/helpers/typeshed/stubs/pika/METADATA.toml b/python/helpers/typeshed/stubs/pika/METADATA.toml index 87c644180e73..217f389fcdcd 100644 --- a/python/helpers/typeshed/stubs/pika/METADATA.toml +++ b/python/helpers/typeshed/stubs/pika/METADATA.toml @@ -1,10 +1,6 @@ version = "1.4.*" upstream-repository = "https://github.com/pika/pika" stub-distribution = "types-pika-ts" # https://github.com/python/typeshed/issues/9246 -extra-description = """\ -The `types-pika` package contains alternate, more complete type stubs, that \ -are maintained outside of typeshed.\ -""" optional-dependencies = ["types-gevent"] [tool.stubtest] diff --git a/python/helpers/typeshed/stubs/pika/pika/adapters/asyncio_connection.pyi b/python/helpers/typeshed/stubs/pika/pika/adapters/asyncio_connection.pyi index 7789841db6a9..b4f5b7d3b656 100644 --- a/python/helpers/typeshed/stubs/pika/pika/adapters/asyncio_connection.pyi +++ b/python/helpers/typeshed/stubs/pika/pika/adapters/asyncio_connection.pyi @@ -2,6 +2,7 @@ import asyncio from _typeshed import Incomplete from collections.abc import Callable, Sequence from logging import Logger +from typing_extensions import Self from pika.adapters.base_connection import BaseConnection from pika.adapters.utils import io_services_utils @@ -12,7 +13,7 @@ from pika.adapters.utils.nbio_interface import ( AbstractIOServices, AbstractTimerReference, ) -from pika.connection import Connection, Parameters +from pika.connection import Parameters LOGGER: Logger @@ -20,9 +21,9 @@ class AsyncioConnection(BaseConnection[asyncio.AbstractEventLoop]): def __init__( self, parameters: Parameters | None = None, - on_open_callback: Callable[[Connection], object] | None = None, - on_open_error_callback: Callable[[Connection, BaseException], object] | None = None, - on_close_callback: Callable[[Connection, BaseException], object] | None = None, + on_open_callback: Callable[[Self], object] | None = None, + on_open_error_callback: Callable[[Self, BaseException], object] | None = None, + on_close_callback: Callable[[Self, BaseException], object] | None = None, custom_ioloop: asyncio.AbstractEventLoop | AbstractIOServices | None = None, internal_connection_workflow: bool = True, ) -> None: ... @@ -30,7 +31,7 @@ class AsyncioConnection(BaseConnection[asyncio.AbstractEventLoop]): def create_connection( cls, connection_configs: Sequence[Parameters], - on_done: Callable[[Connection | AMQPConnectorException], object], + on_done: Callable[[Self | AMQPConnectorException], object], custom_ioloop: asyncio.AbstractEventLoop | None = None, workflow: AbstractAMQPConnectionWorkflow | None = None, ) -> AbstractAMQPConnectionWorkflow: ... diff --git a/python/helpers/typeshed/stubs/pika/pika/adapters/base_connection.pyi b/python/helpers/typeshed/stubs/pika/pika/adapters/base_connection.pyi index ab9b4dc94ac1..2766489ec660 100644 --- a/python/helpers/typeshed/stubs/pika/pika/adapters/base_connection.pyi +++ b/python/helpers/typeshed/stubs/pika/pika/adapters/base_connection.pyi @@ -21,9 +21,9 @@ class BaseConnection(Connection, Generic[_IOLoop], metaclass=abc.ABCMeta): def __init__( self, parameters: Parameters | None, - on_open_callback: Callable[[Connection], object] | None, - on_open_error_callback: Callable[[Connection, BaseException], object] | None, - on_close_callback: Callable[[Connection, BaseException], object] | None, + on_open_callback: Callable[[Self], object] | None, + on_open_error_callback: Callable[[Self, BaseException], object] | None, + on_close_callback: Callable[[Self, BaseException], object] | None, nbio: AbstractIOServices, internal_connection_workflow: bool = True, ) -> None: ... @@ -104,7 +104,7 @@ class _StreamingProtocolShim(AbstractStreamProtocol, Generic[_IOLoop]): def create_connection( cls, connection_configs: Sequence[Parameters], - on_done: Callable[[Connection | AMQPConnectorException], object], + on_done: Callable[[Self | AMQPConnectorException], object], custom_ioloop: _IOLoop | None = None, workflow: AbstractAMQPConnectionWorkflow | None = None, ) -> AbstractAMQPConnectionWorkflow: ... diff --git a/python/helpers/typeshed/stubs/pika/pika/adapters/gevent_connection.pyi b/python/helpers/typeshed/stubs/pika/pika/adapters/gevent_connection.pyi index 1f323796d6c1..995579bf4991 100644 --- a/python/helpers/typeshed/stubs/pika/pika/adapters/gevent_connection.pyi +++ b/python/helpers/typeshed/stubs/pika/pika/adapters/gevent_connection.pyi @@ -1,6 +1,7 @@ from collections.abc import Callable, Sequence from logging import Logger from typing import Final +from typing_extensions import Self from gevent._types import _Loop, _TimerWatcher from gevent.hub import Hub @@ -8,7 +9,7 @@ from pika.adapters.base_connection import BaseConnection from pika.adapters.utils.connection_workflow import AbstractAMQPConnectionWorkflow, AMQPConnectorException from pika.adapters.utils.nbio_interface import AbstractIOReference, AbstractIOServices from pika.adapters.utils.selector_ioloop_adapter import AbstractSelectorIOLoop, SelectorIOServicesAdapter, _SupportsCancel -from pika.connection import Connection, Parameters +from pika.connection import Parameters LOGGER: Logger @@ -16,9 +17,9 @@ class GeventConnection(BaseConnection[_Loop]): def __init__( self, parameters: Parameters | None = None, - on_open_callback: Callable[[Connection], object] | None = None, - on_open_error_callback: Callable[[Connection, BaseException], object] | None = None, - on_close_callback: Callable[[Connection, BaseException], object] | None = None, + on_open_callback: Callable[[Self], object] | None = None, + on_open_error_callback: Callable[[Self, BaseException], object] | None = None, + on_close_callback: Callable[[Self, BaseException], object] | None = None, custom_ioloop: _Loop | AbstractIOServices | None = None, internal_connection_workflow: bool = True, ) -> None: ... @@ -26,7 +27,7 @@ class GeventConnection(BaseConnection[_Loop]): def create_connection( cls, connection_configs: Sequence[Parameters], - on_done: Callable[[Connection | AMQPConnectorException], object], + on_done: Callable[[Self | AMQPConnectorException], object], custom_ioloop: _Loop | None = None, workflow: AbstractAMQPConnectionWorkflow | None = None, ) -> AbstractAMQPConnectionWorkflow: ... diff --git a/python/helpers/typeshed/stubs/pika/pika/adapters/select_connection.pyi b/python/helpers/typeshed/stubs/pika/pika/adapters/select_connection.pyi index d1309477191c..09d88fde568b 100644 --- a/python/helpers/typeshed/stubs/pika/pika/adapters/select_connection.pyi +++ b/python/helpers/typeshed/stubs/pika/pika/adapters/select_connection.pyi @@ -3,13 +3,14 @@ import select from collections.abc import Callable, Sequence from logging import Logger from typing import ClassVar, Final, Literal, TypeAlias, TypedDict +from typing_extensions import Self import pika.compat from pika.adapters.base_connection import BaseConnection from pika.adapters.utils.connection_workflow import AbstractAMQPConnectionWorkflow, AMQPConnectorException from pika.adapters.utils.nbio_interface import AbstractIOServices from pika.adapters.utils.selector_ioloop_adapter import AbstractSelectorIOLoop -from pika.connection import Connection, Parameters +from pika.connection import Parameters SELECT_ERROR_T: TypeAlias = OSError | IOError | InterruptedError | select.error @@ -24,9 +25,9 @@ class SelectConnection(BaseConnection[IOLoop]): def __init__( self, parameters: Parameters | None = None, - on_open_callback: Callable[[Connection], object] | None = None, - on_open_error_callback: Callable[[Connection, BaseException], object] | None = None, - on_close_callback: Callable[[Connection, BaseException], object] | None = None, + on_open_callback: Callable[[Self], object] | None = None, + on_open_error_callback: Callable[[Self, BaseException], object] | None = None, + on_close_callback: Callable[[Self, BaseException], object] | None = None, custom_ioloop: IOLoop | AbstractIOServices | None = None, internal_connection_workflow: bool = True, ) -> None: ... @@ -34,7 +35,7 @@ class SelectConnection(BaseConnection[IOLoop]): def create_connection( cls, connection_configs: Sequence[Parameters], - on_done: Callable[[Connection | AMQPConnectorException], object], + on_done: Callable[[Self | AMQPConnectorException], object], custom_ioloop: IOLoop | None = None, workflow: AbstractAMQPConnectionWorkflow | None = None, ) -> AbstractAMQPConnectionWorkflow: ... diff --git a/python/helpers/typeshed/stubs/pika/pika/adapters/tornado_connection.pyi b/python/helpers/typeshed/stubs/pika/pika/adapters/tornado_connection.pyi index 31ac6c9518d9..7a32602a0798 100644 --- a/python/helpers/typeshed/stubs/pika/pika/adapters/tornado_connection.pyi +++ b/python/helpers/typeshed/stubs/pika/pika/adapters/tornado_connection.pyi @@ -2,11 +2,12 @@ from _typeshed import Incomplete from collections.abc import Callable, Sequence from logging import Logger from typing import TypeAlias +from typing_extensions import Self from pika.adapters.base_connection import BaseConnection from pika.adapters.utils.connection_workflow import AbstractAMQPConnectionWorkflow, AMQPConnectorException from pika.adapters.utils.nbio_interface import AbstractIOServices -from pika.connection import Connection, Parameters +from pika.connection import Parameters _IOLoop: TypeAlias = Incomplete # actual type is tornado.ioloop.IOLoop @@ -16,9 +17,9 @@ class TornadoConnection(BaseConnection[_IOLoop]): def __init__( self, parameters: Parameters | None = None, - on_open_callback: Callable[[Connection], object] | None = None, - on_open_error_callback: Callable[[Connection, BaseException], object] | None = None, - on_close_callback: Callable[[Connection, BaseException], object] | None = None, + on_open_callback: Callable[[Self], object] | None = None, + on_open_error_callback: Callable[[Self, BaseException], object] | None = None, + on_close_callback: Callable[[Self, BaseException], object] | None = None, custom_ioloop: _IOLoop | AbstractIOServices | None = None, internal_connection_workflow: bool = True, ) -> None: ... @@ -26,7 +27,7 @@ class TornadoConnection(BaseConnection[_IOLoop]): def create_connection( cls, connection_configs: Sequence[Parameters], - on_done: Callable[[Connection | AMQPConnectorException], object], + on_done: Callable[[Self | AMQPConnectorException], object], custom_ioloop: _IOLoop | None = None, workflow: AbstractAMQPConnectionWorkflow | None = None, ) -> AbstractAMQPConnectionWorkflow: ... diff --git a/python/helpers/typeshed/stubs/pika/pika/adapters/twisted_connection.pyi b/python/helpers/typeshed/stubs/pika/pika/adapters/twisted_connection.pyi index 204fc2d61603..5fcaa6835c90 100644 --- a/python/helpers/typeshed/stubs/pika/pika/adapters/twisted_connection.pyi +++ b/python/helpers/typeshed/stubs/pika/pika/adapters/twisted_connection.pyi @@ -5,6 +5,7 @@ from _typeshed import Incomplete from collections.abc import Callable, Iterable, Mapping from logging import Logger from typing import Generic, NamedTuple, TypeVar +from typing_extensions import Self from pika import amqp_object from pika.adapters.utils.nbio_interface import AbstractTimerReference @@ -137,9 +138,9 @@ class _TwistedConnectionAdapter(Connection): def __init__( self, parameters: Parameters | None, - on_open_callback: Callable[[Connection], object] | None, - on_open_error_callback: Callable[[Connection, BaseException], object] | None, - on_close_callback: Callable[[Connection, Exception], object] | None, + on_open_callback: Callable[[Self], object] | None, + on_open_error_callback: Callable[[Self, BaseException], object] | None, + on_close_callback: Callable[[Self, Exception], object] | None, custom_reactor: ReactorBase | None = None, ) -> None: ... def connection_made(self, transport: ITransport) -> None: ... diff --git a/python/helpers/typeshed/stubs/pony/METADATA.toml b/python/helpers/typeshed/stubs/pony/METADATA.toml index a5975306faa8..517628fd01cf 100644 --- a/python/helpers/typeshed/stubs/pony/METADATA.toml +++ b/python/helpers/typeshed/stubs/pony/METADATA.toml @@ -1,3 +1,3 @@ version = "0.7.*" upstream-repository = "https://github.com/ponyorm/pony" -dependencies = ["types-psycopg2", "types-PyMySQL"] +optional-dependencies = ["types-psycopg2", "types-PyMySQL"] diff --git a/python/helpers/typeshed/stubs/pyogrio/METADATA.toml b/python/helpers/typeshed/stubs/pyogrio/METADATA.toml index 1e79131a702c..a5b8927e9444 100644 --- a/python/helpers/typeshed/stubs/pyogrio/METADATA.toml +++ b/python/helpers/typeshed/stubs/pyogrio/METADATA.toml @@ -1,4 +1,5 @@ version = "0.13.*" -# Requires a version of numpy with a `py.typed` file -dependencies = ["numpy>=1.20", "types-geopandas"] upstream-repository = "https://github.com/geopandas/pyogrio" +# Requires a version of numpy with a `py.typed` file +dependencies = ["numpy>=1.20"] +optional-dependencies = ["types-geopandas"] diff --git a/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/doctemplate.pyi b/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/doctemplate.pyi index 328125f42bae..ca2ec31b2fe3 100644 --- a/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/doctemplate.pyi +++ b/python/helpers/typeshed/stubs/reportlab/reportlab/platypus/doctemplate.pyi @@ -1,8 +1,8 @@ from _typeshed import Incomplete from abc import abstractmethod from collections.abc import Callable -from typing import IO, Any, Literal, Protocol, TypeAlias, type_check_only -from typing_extensions import Self +from typing import IO, Any, Literal, Protocol, TypeAlias, TypedDict, type_check_only +from typing_extensions import Self, Unpack from reportlab.pdfgen.canvas import Canvas from reportlab.platypus.flowables import Flowable @@ -181,6 +181,54 @@ class PageAccumulator: def pageEndAction(self, canv: Canvas, doc: BaseDocTemplate) -> None: ... def onDrawStr(self, value: object, *args) -> _OnDrawStr: ... +@type_check_only +class _DocTemplateKwargs(TypedDict, total=False): + pagesize: Incomplete + pageTemplates: list[PageTemplate] + showBoundary: Incomplete + width: float + height: float + leftMargin: float + rightMargin: float + topMargin: float + bottomMargin: float + allowSplitting: Incomplete + title: Incomplete | None + author: Incomplete | None + subject: Incomplete | None + creator: Incomplete | None + producer: Incomplete | None + keywords: list[Incomplete] + invariant: Incomplete | None + pageCompression: Incomplete | None + rotation: Incomplete + encrypt: Incomplete | None + cropMarks: Incomplete | None + enforceColorSpace: Incomplete | None + displayDocTitle: Incomplete | None + lang: Incomplete | None + initialFontName: Incomplete | None + initialFontSize: Incomplete | None + initialLeading: Incomplete | None + cropBox: Incomplete | None + artBox: Incomplete | None + trimBox: Incomplete | None + bleedBox: Incomplete | None + keepTogetherClass: type[Flowable] + hideToolbar: Incomplete | None + hideMenubar: Incomplete | None + hideWindowUI: Incomplete | None + fitWindow: Incomplete | None + centerWindow: Incomplete | None + nonFullScreenPageMode: Incomplete | None + direction: Incomplete | None + viewArea: Incomplete | None + viewClip: Incomplete | None + printArea: Incomplete | None + printClip: Incomplete | None + printScaling: Incomplete | None + duplex: Incomplete | None + class BaseDocTemplate: filename: Incomplete pagesize: Incomplete @@ -233,8 +281,7 @@ class BaseDocTemplate: page: int frame: Frame canv: Canvas - # TODO: Use TypedDict with Unpack for **kw - def __init__(self, filename: str | IO[bytes], **kw) -> None: ... + def __init__(self, filename: str | IO[bytes], **kw: Unpack[_DocTemplateKwargs]) -> None: ... def setPageCallBack(self, func: Callable[[int], object] | None) -> None: ... def setProgressCallBack(self, func: Callable[[str, int], object] | None) -> None: ... def clean_hanging(self) -> None: ... diff --git a/python/helpers/typeshed/stubs/seaborn/METADATA.toml b/python/helpers/typeshed/stubs/seaborn/METADATA.toml index 58706ffb3aa3..960160f52d9c 100644 --- a/python/helpers/typeshed/stubs/seaborn/METADATA.toml +++ b/python/helpers/typeshed/stubs/seaborn/METADATA.toml @@ -1,4 +1,4 @@ version = "0.13.2" +upstream-repository = "https://github.com/mwaskom/seaborn" # Requires a version of numpy and matplotlib with a `py.typed` file dependencies = ["matplotlib>=3.8", "numpy>=1.20", "pandas-stubs"] -upstream-repository = "https://github.com/mwaskom/seaborn" diff --git a/python/helpers/typeshed/stubs/shapely/METADATA.toml b/python/helpers/typeshed/stubs/shapely/METADATA.toml index 3d6e72d54ecf..326a70f2733c 100644 --- a/python/helpers/typeshed/stubs/shapely/METADATA.toml +++ b/python/helpers/typeshed/stubs/shapely/METADATA.toml @@ -1,4 +1,4 @@ version = "2.1.*" +upstream-repository = "https://github.com/shapely/shapely" # Requires a version of numpy with a `py.typed` file dependencies = ["numpy>=1.20"] -upstream-repository = "https://github.com/shapely/shapely" diff --git a/python/helpers/typeshed/stubs/tensorflow/tensorflow/__init__.pyi b/python/helpers/typeshed/stubs/tensorflow/tensorflow/__init__.pyi index d4cf842f817f..a8961b022b87 100644 --- a/python/helpers/typeshed/stubs/tensorflow/tensorflow/__init__.pyi +++ b/python/helpers/typeshed/stubs/tensorflow/tensorflow/__init__.pyi @@ -1,7 +1,7 @@ import abc from _typeshed import Incomplete, Unused from abc import ABC, ABCMeta, abstractmethod -from builtins import bool as _bool +from builtins import bool as _bool, slice as _slice from collections.abc import Callable, Generator, Iterable, Iterator, Sequence from contextlib import contextmanager from enum import Enum @@ -12,8 +12,10 @@ from typing_extensions import Self from google.protobuf.message import Message from tensorflow import ( data as data, + debugging as debugging, experimental as experimental, feature_column as feature_column, + image as image, initializers as initializers, io as io, keras as keras, @@ -26,12 +28,15 @@ from tensorflow._aliases import ( AnyArray, DTypeLike, IntArray, + IntTensorCompatible, RaggedTensorLike, ScalarTensorCompatible, ShapeLike, + Signature, Slice, SparseTensorCompatible, TensorCompatible, + TensorLike, UIntTensorCompatible, ) from tensorflow.autodiff import GradientTape as GradientTape @@ -234,7 +239,7 @@ class TensorShape(metaclass=ABCMeta): @overload def __getitem__(self, key: int) -> int | None: ... @overload - def __getitem__(self, key: slice) -> TensorShape: ... + def __getitem__(self, key: _slice) -> TensorShape: ... def __iter__(self) -> Iterator[int | None]: ... def __len__(self) -> int: ... @@ -375,6 +380,8 @@ class RaggedTensorSpec(TypeSpec[struct_pb2.TypeSpecProto]): @classmethod def from_value(cls, value: RaggedTensor) -> Self: ... +newaxis: None + def convert_to_tensor( value: TensorCompatible | IndexedSlices, dtype: DTypeLike | None = None, @@ -399,6 +406,7 @@ def squeeze( @overload def squeeze(input: RaggedTensor, axis: int | tuple[int, ...] | list[int], name: str | None = None) -> RaggedTensor: ... +def slice(input_: TensorCompatible, begin: IntTensorCompatible, size: IntTensorCompatible, name: str | None = None) -> Tensor: ... def split( value: TensorCompatible, num_or_size_splits: int | TensorCompatible, @@ -406,6 +414,7 @@ def split( num: int | None = None, name: str | None = "split", ) -> list[Tensor]: ... +def stack(values: TensorCompatible, axis: int = 0, name: str | None = "stack") -> Tensor: ... def tensor_scatter_nd_update( tensor: TensorCompatible, indices: TensorCompatible, updates: TensorCompatible, name: str | None = None ) -> Tensor: ... @@ -442,6 +451,36 @@ def ones_like( ) -> RaggedTensor: ... def reshape(tensor: TensorCompatible, shape: ShapeLike | Tensor, name: str | None = None) -> Tensor: ... +def reverse(tensor: TensorCompatible, axis: IntTensorCompatible, name: str | None = None) -> Tensor: ... + +_ElemT = TypeVar("_ElemT", bound=TensorLike) +_RetT = TypeVar("_RetT", bound=TensorLike) + +@overload +def map_fn( + fn: Callable[[_ElemT], _RetT], + elems: _ElemT, + dtype: DTypeLike | None = None, + parallel_iterations: int | None = None, + back_prop: _bool = True, + swap_memory: _bool = False, + infer_shape: _bool = True, + name: str | None = None, + fn_output_signature: Signature | None = None, +) -> _RetT: ... +@overload +def map_fn( + fn: Callable[[Tensor], _RetT], + elems: TensorCompatible, + dtype: DTypeLike | None = None, + parallel_iterations: int | None = None, + back_prop: _bool = True, + swap_memory: _bool = False, + infer_shape: _bool = True, + name: str | None = None, + fn_output_signature: Signature | None = None, +) -> _RetT: ... + def pad( tensor: TensorCompatible, paddings: Tensor | IntArray | Iterable[Iterable[int]], @@ -467,4 +506,18 @@ def clip_by_value( t: Tensor | IndexedSlices, clip_value_min: TensorCompatible, clip_value_max: TensorCompatible, name: str | None = None ) -> Tensor: ... def tile(input: RaggedTensorLike, multiples: Tensor | Sequence[int], name: str | None = None) -> Tensor: ... + +@overload +def range( + limit: int | Tensor, /, *, delta: int | Tensor = 1, dtype: DTypeLike | None = None, name: str | None = "range" +) -> Tensor: ... +@overload +def range( + start: int | Tensor = 0, + limit: int | Tensor = 0, + delta: int | Tensor = 1, + dtype: DTypeLike | None = None, + name: str | None = "range", +) -> Tensor: ... + def __getattr__(name: str): ... # incomplete module diff --git a/python/helpers/typeshed/stubs/tensorflow/tensorflow/_aliases.pyi b/python/helpers/typeshed/stubs/tensorflow/tensorflow/_aliases.pyi index a63f19431717..a3ac8f423437 100644 --- a/python/helpers/typeshed/stubs/tensorflow/tensorflow/_aliases.pyi +++ b/python/helpers/typeshed/stubs/tensorflow/tensorflow/_aliases.pyi @@ -39,6 +39,7 @@ StrDataSequence: TypeAlias = Sequence[str] | Sequence[StrDataSequence] DataSequence: TypeAlias = FloatDataSequence | StrDataSequence | IntDataSequence ScalarTensorCompatible: TypeAlias = tf.Tensor | str | float | np.ndarray[Any, Any] | np.number[Any] UIntTensorCompatible: TypeAlias = tf.Tensor | int | UIntArray +IntTensorCompatible: TypeAlias = tf.Tensor | int | IntArray | Sequence[IntTensorCompatible] FloatTensorCompatible: TypeAlias = tf.Tensor | int | IntArray | float | FloatArray | np.number[Any] StringTensorCompatible: TypeAlias = tf.Tensor | str | npt.NDArray[np.str_] | Sequence[StringTensorCompatible] @@ -56,6 +57,7 @@ TensorOrArray: TypeAlias = tf.Tensor | AnyArray ShapeLike: TypeAlias = tf.TensorShape | Iterable[ScalarTensorCompatible | None] | int | tf.Tensor DTypeLike: TypeAlias = DType | str | np.dtype[Any] | int +Signature: TypeAlias = DType | tf.RaggedTensorSpec | tf.SparseTensorSpec | Sequence[Signature] ContainerTensors: TypeAlias = ContainerGeneric[tf.Tensor] ContainerTensorsLike: TypeAlias = ContainerGeneric[TensorLike] diff --git a/python/helpers/typeshed/stubs/tensorflow/tensorflow/debugging.pyi b/python/helpers/typeshed/stubs/tensorflow/tensorflow/debugging.pyi new file mode 100644 index 000000000000..0f48b5e1213d --- /dev/null +++ b/python/helpers/typeshed/stubs/tensorflow/tensorflow/debugging.pyi @@ -0,0 +1,10 @@ +from tensorflow._aliases import FloatTensorCompatible + +def assert_greater_equal( + x: FloatTensorCompatible, + y: FloatTensorCompatible, + message: str | None = None, + summarize: int | None = None, + name: str | None = None, +) -> None: ... +def __getattr__(name: str): ... # incomplete module diff --git a/python/helpers/typeshed/stubs/tensorflow/tensorflow/image.pyi b/python/helpers/typeshed/stubs/tensorflow/tensorflow/image.pyi new file mode 100644 index 000000000000..38fdc40aa059 --- /dev/null +++ b/python/helpers/typeshed/stubs/tensorflow/tensorflow/image.pyi @@ -0,0 +1,7 @@ +import tensorflow as tf +from tensorflow._aliases import IntTensorCompatible, TensorCompatible + +def random_crop( + value: TensorCompatible, size: IntTensorCompatible, seed: int | None = None, name: str | None = None +) -> tf.Tensor: ... +def __getattr__(name: str): ... # incomplete module diff --git a/python/helpers/typeshed/stubs/tqdm/@tests/stubtest_allowlist.txt b/python/helpers/typeshed/stubs/tqdm/@tests/stubtest_allowlist.txt index 6eb696d3f060..8887707780b2 100644 --- a/python/helpers/typeshed/stubs/tqdm/@tests/stubtest_allowlist.txt +++ b/python/helpers/typeshed/stubs/tqdm/@tests/stubtest_allowlist.txt @@ -1,10 +1,6 @@ # Cannot import in stubtest tqdm.__main__ -# TODO: Reenable when tensorflow supports Python 3.13 and is added to the -# stubtest dependencies in METADATA.toml. -tqdm.keras - # Fails to import as of v4.68.0 since it attempts to re-export functions that were # removed from 'tqdm.utils' (e.g. _screen_shape_linux). tqdm._utils diff --git a/python/helpers/typeshed/stubs/tqdm/METADATA.toml b/python/helpers/typeshed/stubs/tqdm/METADATA.toml index 246d120917bb..911213ce5f75 100644 --- a/python/helpers/typeshed/stubs/tqdm/METADATA.toml +++ b/python/helpers/typeshed/stubs/tqdm/METADATA.toml @@ -1,10 +1,7 @@ -version = "4.69.*" +version = "4.70.*" upstream-repository = "https://github.com/tqdm/tqdm" -dependencies = ["types-requests"] +optional-dependencies = ["types-requests", "types-tensorflow"] [tool.stubtest] extras = ["slack", "telegram"] -# Add `"tensorflow"` to this list when there's a tensorflow release supporting -# Python 3.13: https://github.com/tensorflow/tensorflow/issues/78774. -# Also remove tqdm.keras from @tests/stubtest_allowlist.txt. -stubtest-dependencies = ["dask", "pandas", "rich"] +stubtest-dependencies = ["dask", "pandas", "rich", "tensorflow"] diff --git a/python/helpers/typeshed/stubs/tqdm/tqdm/contrib/concurrent.pyi b/python/helpers/typeshed/stubs/tqdm/tqdm/contrib/concurrent.pyi index 982a359416cd..44622ae76d36 100644 --- a/python/helpers/typeshed/stubs/tqdm/tqdm/contrib/concurrent.pyi +++ b/python/helpers/typeshed/stubs/tqdm/tqdm/contrib/concurrent.pyi @@ -1,11 +1,14 @@ +import sys from _typeshed import SupportsWrite -from collections.abc import Callable, Iterable, Mapping +from collections.abc import Callable, Generator, Iterable, Mapping +from contextlib import contextmanager +from multiprocessing.context import BaseContext from typing import Any, TypedDict, TypeVar, overload, type_check_only from typing_extensions import Unpack from ..std import tqdm -__all__ = ["thread_map", "process_map"] +__all__ = ["thread_map", "process_map", "interpreter_map"] _R = TypeVar("_R") _T1 = TypeVar("_T1") @@ -15,12 +18,11 @@ _T4 = TypeVar("_T4") _T5 = TypeVar("_T5") @type_check_only -class _TqdmKwargs(TypedDict, total=False): +class _TqdmCommonKwargs(TypedDict, total=False): # Concurrent-specific parameters tqdm_class: type[tqdm[object]] max_workers: int | None chunksize: int - lock_name: str # Standard tqdm parameters desc: str | None total: float | None @@ -47,11 +49,34 @@ class _TqdmKwargs(TypedDict, total=False): colour: str | None delay: float | None +# TODO: refactor this, when `TypedDict` will support conditional fields +if sys.version_info >= (3, 14): + @type_check_only + class _TqdmKwargs(_TqdmCommonKwargs, total=False): + buffersize: int | None + +else: + _TqdmKwargs = _TqdmCommonKwargs + +@type_check_only +class _TqdmProcessKwargs(_TqdmKwargs, total=False): + mp_context: BaseContext | None + max_tasks_per_child: int | None + +@type_check_only +class _TqdmThreadKwargs(_TqdmKwargs, total=False): + thread_name_prefix: str | None + # Not techically for threading, but just a signature difference: + lock_name: str + +@contextmanager +def ensure_lock(tqdm_class: type[tqdm[object]], lock_name: str = "", lock=None) -> Generator[None]: ... + @overload -def thread_map(fn: Callable[[_T1], _R], iter1: Iterable[_T1], **tqdm_kwargs: Unpack[_TqdmKwargs]) -> list[_R]: ... +def thread_map(fn: Callable[[_T1], _R], iter1: Iterable[_T1], **tqdm_kwargs: Unpack[_TqdmThreadKwargs]) -> list[_R]: ... @overload def thread_map( - fn: Callable[[_T1, _T2], _R], iter1: Iterable[_T1], iter2: Iterable[_T2], /, **tqdm_kwargs: Unpack[_TqdmKwargs] + fn: Callable[[_T1, _T2], _R], iter1: Iterable[_T1], iter2: Iterable[_T2], /, **tqdm_kwargs: Unpack[_TqdmThreadKwargs] ) -> list[_R]: ... @overload def thread_map( @@ -59,7 +84,7 @@ def thread_map( iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], - **tqdm_kwargs: Unpack[_TqdmKwargs], + **tqdm_kwargs: Unpack[_TqdmThreadKwargs], ) -> list[_R]: ... @overload def thread_map( @@ -68,7 +93,7 @@ def thread_map( iter2: Iterable[_T2], iter3: Iterable[_T3], iter4: Iterable[_T4], - **tqdm_kwargs: Unpack[_TqdmKwargs], + **tqdm_kwargs: Unpack[_TqdmThreadKwargs], ) -> list[_R]: ... @overload def thread_map( @@ -78,7 +103,7 @@ def thread_map( iter3: Iterable[_T3], iter4: Iterable[_T4], iter5: Iterable[_T5], - **tqdm_kwargs: Unpack[_TqdmKwargs], + **tqdm_kwargs: Unpack[_TqdmThreadKwargs], ) -> list[_R]: ... @overload def thread_map( @@ -90,14 +115,21 @@ def thread_map( iter5: Iterable[Any], iter6: Iterable[Any], *iterables: Iterable[Any], - **tqdm_kwargs: Unpack[_TqdmKwargs], + **tqdm_kwargs: Unpack[_TqdmThreadKwargs], ) -> list[_R]: ... @overload -def process_map(fn: Callable[[_T1], _R], iter1: Iterable[_T1], **tqdm_kwargs: Unpack[_TqdmKwargs]) -> list[_R]: ... +def process_map( + fn: Callable[[_T1], _R], iter1: Iterable[_T1], *, lock_name: str = "mp_lock", **tqdm_kwargs: Unpack[_TqdmProcessKwargs] +) -> list[_R]: ... @overload def process_map( - fn: Callable[[_T1, _T2], _R], iter1: Iterable[_T1], iter2: Iterable[_T2], **tqdm_kwargs: Unpack[_TqdmKwargs] + fn: Callable[[_T1, _T2], _R], + iter1: Iterable[_T1], + iter2: Iterable[_T2], + *, + lock_name: str = "mp_lock", + **tqdm_kwargs: Unpack[_TqdmProcessKwargs], ) -> list[_R]: ... @overload def process_map( @@ -105,7 +137,9 @@ def process_map( iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], - **tqdm_kwargs: Unpack[_TqdmKwargs], + *, + lock_name: str = "mp_lock", + **tqdm_kwargs: Unpack[_TqdmProcessKwargs], ) -> list[_R]: ... @overload def process_map( @@ -114,7 +148,9 @@ def process_map( iter2: Iterable[_T2], iter3: Iterable[_T3], iter4: Iterable[_T4], - **tqdm_kwargs: Unpack[_TqdmKwargs], + *, + lock_name: str = "mp_lock", + **tqdm_kwargs: Unpack[_TqdmProcessKwargs], ) -> list[_R]: ... @overload def process_map( @@ -124,7 +160,9 @@ def process_map( iter3: Iterable[_T3], iter4: Iterable[_T4], iter5: Iterable[_T5], - **tqdm_kwargs: Unpack[_TqdmKwargs], + *, + lock_name: str = "mp_lock", + **tqdm_kwargs: Unpack[_TqdmProcessKwargs], ) -> list[_R]: ... @overload def process_map( @@ -136,5 +174,52 @@ def process_map( iter5: Iterable[Any], iter6: Iterable[Any], *iterables: Iterable[Any], - **tqdm_kwargs: Unpack[_TqdmKwargs], + lock_name: str = "mp_lock", + **tqdm_kwargs: Unpack[_TqdmProcessKwargs], +) -> list[_R]: ... + +@overload +def interpreter_map(fn: Callable[[_T1], _R], iter1: Iterable[_T1], **tqdm_kwargs: Unpack[_TqdmThreadKwargs]) -> list[_R]: ... +@overload +def interpreter_map( + fn: Callable[[_T1, _T2], _R], iter1: Iterable[_T1], iter2: Iterable[_T2], /, **tqdm_kwargs: Unpack[_TqdmThreadKwargs] +) -> list[_R]: ... +@overload +def interpreter_map( + fn: Callable[[_T1, _T2, _T3], _R], + iter1: Iterable[_T1], + iter2: Iterable[_T2], + iter3: Iterable[_T3], + **tqdm_kwargs: Unpack[_TqdmThreadKwargs], +) -> list[_R]: ... +@overload +def interpreter_map( + fn: Callable[[_T1, _T2, _T3, _T4], _R], + iter1: Iterable[_T1], + iter2: Iterable[_T2], + iter3: Iterable[_T3], + iter4: Iterable[_T4], + **tqdm_kwargs: Unpack[_TqdmThreadKwargs], +) -> list[_R]: ... +@overload +def interpreter_map( + fn: Callable[[_T1, _T2, _T3, _T4, _T5], _R], + iter1: Iterable[_T1], + iter2: Iterable[_T2], + iter3: Iterable[_T3], + iter4: Iterable[_T4], + iter5: Iterable[_T5], + **tqdm_kwargs: Unpack[_TqdmThreadKwargs], +) -> list[_R]: ... +@overload +def interpreter_map( + fn: Callable[..., _R], + iter1: Iterable[Any], + iter2: Iterable[Any], + iter3: Iterable[Any], + iter4: Iterable[Any], + iter5: Iterable[Any], + iter6: Iterable[Any], + *iterables: Iterable[Any], + **tqdm_kwargs: Unpack[_TqdmThreadKwargs], ) -> list[_R]: ... diff --git a/python/helpers/typeshed/stubs/tqdm/tqdm/keras.pyi b/python/helpers/typeshed/stubs/tqdm/tqdm/keras.pyi index 7548952fb794..b23ef91c7c95 100644 --- a/python/helpers/typeshed/stubs/tqdm/tqdm/keras.pyi +++ b/python/helpers/typeshed/stubs/tqdm/tqdm/keras.pyi @@ -1,33 +1,10 @@ from _typeshed import Incomplete +from tensorflow import keras + __all__ = ["TqdmCallback"] -# keras.callbacks.Callback -class _Callback: - validation_data: Incomplete | None - model: Incomplete | None - params: Incomplete - def __init__(self) -> None: ... - def set_params(self, params) -> None: ... - def set_model(self, model) -> None: ... - def on_batch_begin(self, batch, logs: Incomplete | None = ...) -> None: ... - def on_batch_end(self, batch, logs: Incomplete | None = ...) -> None: ... - def on_epoch_begin(self, epoch, logs: Incomplete | None = ...) -> None: ... - def on_epoch_end(self, epoch, logs: Incomplete | None = ...) -> None: ... - def on_train_batch_begin(self, batch, logs: Incomplete | None = ...) -> None: ... - def on_train_batch_end(self, batch, logs: Incomplete | None = ...) -> None: ... - def on_test_batch_begin(self, batch, logs: Incomplete | None = ...) -> None: ... - def on_test_batch_end(self, batch, logs: Incomplete | None = ...) -> None: ... - def on_predict_batch_begin(self, batch, logs: Incomplete | None = ...) -> None: ... - def on_predict_batch_end(self, batch, logs: Incomplete | None = ...) -> None: ... - def on_train_begin(self, logs: Incomplete | None = ...) -> None: ... - def on_train_end(self, logs: Incomplete | None = ...) -> None: ... - def on_test_begin(self, logs: Incomplete | None = ...) -> None: ... - def on_test_end(self, logs: Incomplete | None = ...) -> None: ... - def on_predict_begin(self, logs: Incomplete | None = ...) -> None: ... - def on_predict_end(self, logs: Incomplete | None = ...) -> None: ... - -class TqdmCallback(_Callback): +class TqdmCallback(keras.callbacks.Callback): @staticmethod def bar2callback(bar, pop=None, delta=...): ... tqdm_class: Incomplete diff --git a/python/helpers/typeshed/tests/stubtest_third_party.py b/python/helpers/typeshed/tests/stubtest_third_party.py index fa7d2906cab3..91d46678b54d 100644 --- a/python/helpers/typeshed/tests/stubtest_third_party.py +++ b/python/helpers/typeshed/tests/stubtest_third_party.py @@ -149,7 +149,7 @@ def run_stubtest(dist: Path, *, verbose: bool = False, ci_platforms_only: bool = subprocess.run(stubtest_cmd, env=stubtest_env, check=True, capture_output=True) except subprocess.CalledProcessError as e: print_time(time() - t) - print_error("fail") + print_error(f"failed with exit code {e.returncode}") print_divider() print("Commands run:")