Benefit from mypy 0.930
This commit is contained in:
parent
6ec85dc5ea
commit
3ea9e434ad
4 changed files with 9 additions and 10 deletions
|
|
@ -30,7 +30,7 @@ test = [
|
||||||
"pytest-mock",
|
"pytest-mock",
|
||||||
]
|
]
|
||||||
mypy = [
|
mypy = [
|
||||||
"mypy",
|
"mypy>=0.930",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# frozen requirements generated by pip-deepfreeze
|
# frozen requirements generated by pip-deepfreeze
|
||||||
mypy==0.910
|
mypy==0.930
|
||||||
mypy-extensions==0.4.3
|
mypy-extensions==0.4.3
|
||||||
toml==0.10.2
|
tomli==1.2.2
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ from kubernetes.client.exceptions import ApiException
|
||||||
from kubernetes.client.models.v1_deployment import V1Deployment
|
from kubernetes.client.models.v1_deployment import V1Deployment
|
||||||
from kubernetes.client.models.v1_job import V1Job
|
from kubernetes.client.models.v1_job import V1Job
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
from typing_extensions import NotRequired
|
||||||
|
|
||||||
from .github import CommitInfo
|
from .github import CommitInfo
|
||||||
from .settings import BuildSettings, settings
|
from .settings import BuildSettings, settings
|
||||||
|
|
@ -56,10 +57,10 @@ def delete_deployment(deployment_name: str) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class PatchOperation(TypedDict, total=False):
|
class PatchOperation(TypedDict):
|
||||||
op: str
|
op: str
|
||||||
path: str
|
path: str
|
||||||
value: str | int # maybe absent, hence total=False above
|
value: NotRequired[str | int]
|
||||||
|
|
||||||
|
|
||||||
@sync_to_async
|
@sync_to_async
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,12 @@ def slugify(s: str | int) -> str:
|
||||||
return re.sub(r"[^a-z0-9]", "-", str(s).lower())
|
return re.sub(r"[^a-z0-9]", "-", str(s).lower())
|
||||||
|
|
||||||
|
|
||||||
# TODO replace ... with P below when mypy supports PEP 612
|
|
||||||
# (https://github.com/python/mypy/issues/8645)
|
|
||||||
P = ParamSpec("P")
|
P = ParamSpec("P")
|
||||||
R = TypeVar("R")
|
R = TypeVar("R")
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
|
|
||||||
|
|
||||||
def sync_to_async(func: Callable[..., R]) -> Callable[..., Awaitable[R]]:
|
def sync_to_async(func: Callable[P, R]) -> Callable[P, Awaitable[R]]:
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
async def inner(*args: Any, **kwargs: Any) -> R:
|
async def inner(*args: Any, **kwargs: Any) -> R:
|
||||||
f = functools.partial(func, *args, **kwargs)
|
f = functools.partial(func, *args, **kwargs)
|
||||||
|
|
@ -38,8 +36,8 @@ def sync_to_async(func: Callable[..., R]) -> Callable[..., Awaitable[R]]:
|
||||||
|
|
||||||
|
|
||||||
def sync_to_async_iterator(
|
def sync_to_async_iterator(
|
||||||
iterator_func: Callable[..., Generator[R, None, None]]
|
iterator_func: Callable[P, Generator[R, None, None]]
|
||||||
) -> Callable[..., AsyncGenerator[R, None]]:
|
) -> Callable[P, AsyncGenerator[R, None]]:
|
||||||
@sync_to_async
|
@sync_to_async
|
||||||
def async_next(iterator: Iterator[R]) -> R:
|
def async_next(iterator: Iterator[R]) -> R:
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue