Skip to content

Commit

Permalink
Replace quoted types with typing.Self introduced in python3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
SRv6d committed Dec 4, 2023
1 parent fe2bb36 commit b94449a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/anycastd/healthcheck/_cabourotte/result.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
from typing import Self

import httpx
from pydantic import BaseModel, Field
Expand All @@ -16,7 +17,7 @@ class Result(BaseModel):
source: str

@classmethod
def from_json(cls, data: str | bytes | bytearray) -> "Result":
def from_json(cls, data: str | bytes | bytearray) -> Self:
"""Create a result from JSON returned by the cabourotte API."""
return cls.model_validate_json(data)

Expand Down
8 changes: 4 additions & 4 deletions src/anycastd/prefix/_frrouting/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from contextlib import suppress
from ipaddress import IPv4Network, IPv6Network
from pathlib import Path
from typing import cast
from typing import Self, cast

from anycastd._executor import Executor
from anycastd.prefix._frrouting.exceptions import (
Expand Down Expand Up @@ -141,7 +141,7 @@ async def _run_vtysh_commands(self, commands: Sequence[str]) -> str:

return stdout.decode("utf-8")

async def validate(self) -> "FRRoutingPrefix":
async def validate(self) -> Self:
"""Validate the prefix, raising an error on invalid configuration.
Checks if the required VRF and BGP configuration exists.
Expand Down Expand Up @@ -172,7 +172,7 @@ async def new(
vrf: VRF = None,
vtysh: Path = Path("/usr/bin/vtysh"),
executor: Executor,
) -> "FRRoutingPrefix":
) -> Self:
"""Create a new validated FRRoutingPrefix.
Creates a new FRRoutingPrefix instance while validating it against the
Expand All @@ -182,7 +182,7 @@ async def new(
A subclass of FRRConfigurationError if there is an issue with the
FRRouting configuration.
"""
return await FRRoutingPrefix(
return await cls(
prefix=prefix, vrf=vrf, vtysh=vtysh, executor=executor
).validate()

Expand Down

0 comments on commit b94449a

Please sign in to comment.