Skip to content

Commit 82cfe62

Browse files
authored
Merge branch 'main' into modernize-cookies
2 parents 20701ac + ce2b37d commit 82cfe62

File tree

8 files changed

+66
-13
lines changed

8 files changed

+66
-13
lines changed

stdlib/cmath.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ nan: Final[float]
99
nanj: Final[complex]
1010
tau: Final[float]
1111

12+
_F: TypeAlias = SupportsFloat | SupportsIndex
1213
_C: TypeAlias = SupportsFloat | SupportsComplex | SupportsIndex | complex
1314

1415
def acos(z: _C, /) -> complex: ...
@@ -27,7 +28,7 @@ def log(z: _C, base: _C = ..., /) -> complex: ...
2728
def log10(z: _C, /) -> complex: ...
2829
def phase(z: _C, /) -> float: ...
2930
def polar(z: _C, /) -> tuple[float, float]: ...
30-
def rect(r: float, phi: float, /) -> complex: ...
31+
def rect(r: _F, phi: _F, /) -> complex: ...
3132
def sin(z: _C, /) -> complex: ...
3233
def sinh(z: _C, /) -> complex: ...
3334
def sqrt(z: _C, /) -> complex: ...

stdlib/http/cookies.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import SupportsItems, SupportsKeysAndGetItem
1+
from _typeshed import MaybeNone, SupportsItems, SupportsKeysAndGetItem
22
from collections.abc import Container, Iterable
33
from types import GenericAlias
44
from typing import Any, Generic, TypeVar, overload
@@ -20,11 +20,11 @@ class CookieError(Exception): ...
2020

2121
class Morsel(dict[str, Any], Generic[_T]):
2222
@property
23-
def value(self) -> str: ...
23+
def value(self) -> str | MaybeNone: ...
2424
@property
25-
def coded_value(self) -> _T: ...
25+
def coded_value(self) -> _T | MaybeNone: ...
2626
@property
27-
def key(self) -> str: ...
27+
def key(self) -> str | MaybeNone: ...
2828
def __init__(self) -> None: ...
2929
def set(self, key: str, val: str, coded_val: _T) -> None: ...
3030
def setdefault(self, key: str, val: str | None = None) -> str: ...

stubs/django-import-export/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "4.3.*"
1+
version = "4.4.*"
22
upstream_repository = "https://github.com/django-import-export/django-import-export"
33
requires = ["django-stubs"] # Add tablib when typed, and update _Incomplete aliases in stubs
44

stubs/django-import-export/import_export/widgets.pyi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,19 @@ class ForeignKeyWidget(Widget, Generic[_ModelT]):
6565
self, model: _ModelT, field: str = "pk", use_natural_foreign_keys: bool = False, key_is_id: bool = False, **kwargs: Any
6666
) -> None: ...
6767
def get_queryset(self, value: Any, row: Mapping[str, Any], *args: Any, **kwargs: Any) -> QuerySet[_ModelT]: ...
68+
def get_instance_by_natural_key(self, value: str | bytes | bytearray) -> _ModelT: ...
69+
def get_instance_by_lookup_fields(self, value: Any, row: Mapping[str, Any], **kwargs: Any) -> _ModelT: ...
6870
def get_lookup_kwargs(self, value: Any, row: Mapping[str, Any] | None = None, **kwargs: Any) -> dict[str, Any]: ...
6971

72+
class _CachedQuerySetWrapper(Generic[_ModelT]):
73+
queryset: QuerySet[_ModelT]
74+
model: type[_ModelT]
75+
def __init__(self, queryset: QuerySet[_ModelT]) -> None: ...
76+
def get(self, **lookup_fields: Any) -> _ModelT: ... # instance can have different fields
77+
78+
class CachedForeignKeyWidget(ForeignKeyWidget[_ModelT]):
79+
def get_instance_by_lookup_fields(self, value: Any, row: Mapping[str, Any], **kwargs: Any) -> _ModelT: ...
80+
7081
class ManyToManyWidget(Widget, Generic[_ModelT]):
7182
model: _ModelT
7283
separator: str

stubs/tensorflow/tensorflow/__init__.pyi

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ from tensorflow import (
1818
io as io,
1919
keras as keras,
2020
math as math,
21+
nn as nn,
2122
random as random,
2223
types as types,
2324
)
@@ -37,7 +38,7 @@ from tensorflow.core.protobuf import struct_pb2
3738
from tensorflow.dtypes import *
3839
from tensorflow.experimental.dtensor import Layout
3940
from tensorflow.keras import losses as losses
40-
from tensorflow.linalg import eye as eye
41+
from tensorflow.linalg import eye as eye, matmul as matmul
4142

4243
# Most tf.math functions are exported as tf, but sadly not all are.
4344
from tensorflow.math import (
@@ -385,6 +386,13 @@ def squeeze(
385386
) -> Tensor: ...
386387
@overload
387388
def squeeze(input: RaggedTensor, axis: int | tuple[int, ...] | list[int], name: str | None = None) -> RaggedTensor: ...
389+
def split(
390+
value: TensorCompatible,
391+
num_or_size_splits: int | TensorCompatible,
392+
axis: int | Tensor = 0,
393+
num: int | None = None,
394+
name: str | None = "split",
395+
) -> list[Tensor]: ...
388396
def tensor_scatter_nd_update(
389397
tensor: TensorCompatible, indices: TensorCompatible, updates: TensorCompatible, name: str | None = None
390398
) -> Tensor: ...
@@ -434,4 +442,10 @@ def gather_nd(
434442
name: str | None = None,
435443
bad_indices_policy: Literal["", "DEFAULT", "ERROR", "IGNORE"] = "",
436444
) -> Tensor: ...
445+
def transpose(
446+
a: Tensor, perm: Sequence[int] | IntArray | None = None, conjugate: _bool = False, name: str = "transpose"
447+
) -> Tensor: ...
448+
def clip_by_value(
449+
t: Tensor | IndexedSlices, clip_value_min: TensorCompatible, clip_value_max: TensorCompatible, name: str | None = None
450+
) -> Tensor: ...
437451
def __getattr__(name: str): ... # incomplete module

stubs/tensorflow/tensorflow/keras/metrics.pyi

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
from _typeshed import Incomplete
12
from abc import ABCMeta, abstractmethod
23
from collections.abc import Callable, Iterable, Sequence
3-
from typing import Any, Literal
4+
from enum import Enum
5+
from typing import Any, Literal, type_check_only
46
from typing_extensions import Self, TypeAlias
57

68
import tensorflow as tf
@@ -107,6 +109,25 @@ class SparseTopKCategoricalAccuracy(MeanMetricWrapper):
107109
self, k: int = 5, name: str | None = "sparse_top_k_categorical_accuracy", dtype: DTypeLike | None = None
108110
) -> None: ...
109111

112+
# TODO: Actually tensorflow.python.keras.utils.metrics_utils.Reduction, but that module
113+
# is currently missing from the stub.
114+
@type_check_only
115+
class _Reduction(Enum):
116+
SUM = "sum"
117+
SUM_OVER_BATCH_SIZE = "sum_over_batch_size"
118+
WEIGHTED_MEAN = "weighted_mean"
119+
120+
class Reduce(Metric):
121+
reduction: _Reduction
122+
total: Incomplete
123+
count: Incomplete # only defined for some reductions
124+
def __init__(self, reduction: _Reduction, name: str | None, dtype: DTypeLike | None = None) -> None: ...
125+
def update_state(self, values, sample_weight=None): ... # type: ignore[override]
126+
def result(self) -> Tensor: ...
127+
128+
class Mean(Reduce):
129+
def __init__(self, name: str | None = "mean", dtype: DTypeLike | None = None) -> None: ...
130+
110131
def serialize(metric: KerasSerializable) -> dict[str, Any]: ...
111132
def binary_crossentropy(
112133
y_true: TensorCompatible, y_pred: TensorCompatible, from_logits: bool = False, label_smoothing: float = 0.0, axis: int = -1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from __future__ import annotations
2+
3+
import xmltodict
4+
5+
ns: dict[str, None] = {"http://example.com/": None}
6+
xmltodict.parse("<a/>", namespaces=ns)

stubs/xmltodict/xmltodict.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class _DictSAXHandler:
2525
dict_constructor: type
2626
strip_whitespace: bool
2727
namespace_separator: str
28-
namespaces: dict[str, str] | None
28+
namespaces: Mapping[str, str | None] | None
2929
namespace_declarations: dict[str, str]
3030
force_list: bool | Container[str] | Callable[[tuple[str, _AttrDict | None], str, str], bool] | None
3131
comment_key: str
@@ -42,7 +42,7 @@ class _DictSAXHandler:
4242
dict_constructor: type = ...,
4343
strip_whitespace: bool = True,
4444
namespace_separator: str = ":",
45-
namespaces: dict[str, str] | None = None,
45+
namespaces: Mapping[str, str | None] | None = None,
4646
force_list: bool | Container[str] | Callable[[tuple[str, _AttrDict | None], str, str], bool] | None = None,
4747
comment_key: str = "#comment",
4848
) -> None: ...
@@ -72,7 +72,7 @@ def parse(
7272
postprocessor: Callable[[list[tuple[str, _AttrDict | None]], str, _AttrValue], tuple[str, _AttrValue]] | None = None,
7373
dict_constructor: type = ...,
7474
strip_whitespace: bool = True,
75-
namespaces: dict[str, str] | None = None,
75+
namespaces: Mapping[str, str | None] | None = None,
7676
force_list: bool | Container[str] | Callable[[tuple[str, _AttrDict | None], str, str], bool] | None = None,
7777
comment_key: str = "#comment",
7878
) -> dict[str, Any]: ...
@@ -95,7 +95,7 @@ def unparse(
9595
newl: str = "\n",
9696
indent: str | int = "\t",
9797
namespace_separator: str = ":",
98-
namespaces: Mapping[str, str] | None = None,
98+
namespaces: Mapping[str, str | None] | None = None,
9999
expand_iter: str | None = None,
100100
) -> None: ...
101101
@overload
@@ -117,6 +117,6 @@ def unparse(
117117
newl: str = "\n",
118118
indent: str | int = "\t",
119119
namespace_separator: str = ":",
120-
namespaces: Mapping[str, str] | None = None,
120+
namespaces: Mapping[str, str | None] | None = None,
121121
expand_iter: str | None = None,
122122
) -> str: ...

0 commit comments

Comments
 (0)