Skip to content

Commit

Permalink
fix: remove kw_only argument introduced in 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Zane committed Oct 18, 2024
1 parent 9be9e01 commit fc0d0f1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion schemachange/config/BaseConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
T = TypeVar("T", bound="BaseConfig")


@dataclasses.dataclass(frozen=True, kw_only=True)
@dataclasses.dataclass(frozen=True)
class BaseConfig(ABC):
default_config_file_name: ClassVar[str] = "schemachange-config.yml"

Expand Down
2 changes: 1 addition & 1 deletion schemachange/config/DeployConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from schemachange.config.utils import get_snowflake_identifier_string


@dataclasses.dataclass(frozen=True, kw_only=True)
@dataclasses.dataclass(frozen=True)
class DeployConfig(BaseConfig):
subcommand: Literal["deploy"] = "deploy"
snowflake_account: str | None = None
Expand Down
10 changes: 8 additions & 2 deletions schemachange/config/RenderConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
from schemachange.config.utils import validate_file_path


@dataclasses.dataclass(frozen=True, kw_only=True)
@dataclasses.dataclass(frozen=True)
class RenderConfig(BaseConfig):
script_path: Path | None = None
subcommand: Literal["render"] = "render"
script_path: Path

@classmethod
def factory(
Expand All @@ -31,3 +31,9 @@ def factory(
script_path=validate_file_path(file_path=script_path),
**kwargs,
)

def __post_init__(self):
if self.script_path is None:
raise TypeError(
"RenderConfig is missing 1 required argument: 'script_path'"
)
34 changes: 14 additions & 20 deletions schemachange/session/Credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import dataclasses
import os
from abc import ABC
from typing import Literal, Union

import structlog
Expand All @@ -14,37 +13,32 @@
)


@dataclasses.dataclass(kw_only=True, frozen=True)
class Credential(ABC):
authenticator: str


@dataclasses.dataclass(kw_only=True, frozen=True)
class OauthCredential(Credential):
authenticator: Literal["oauth"] = "oauth"
@dataclasses.dataclass(frozen=True)
class OauthCredential:
token: str
authenticator: Literal["oauth"] = "oauth"


@dataclasses.dataclass(kw_only=True, frozen=True)
class PasswordCredential(Credential):
authenticator: Literal["snowflake"] = "snowflake"
@dataclasses.dataclass(frozen=True)
class PasswordCredential:
password: str
authenticator: Literal["snowflake"] = "snowflake"


@dataclasses.dataclass(kw_only=True, frozen=True)
class PrivateKeyCredential(Credential):
authenticator: Literal["snowflake"] = "snowflake"
@dataclasses.dataclass(frozen=True)
class PrivateKeyCredential:
private_key: bytes
authenticator: Literal["snowflake"] = "snowflake"


@dataclasses.dataclass(kw_only=True, frozen=True)
class ExternalBrowserCredential(Credential):
authenticator: Literal["externalbrowser"] = "externalbrowser"
@dataclasses.dataclass(frozen=True)
class ExternalBrowserCredential:
password: str | None = None
authenticator: Literal["externalbrowser"] = "externalbrowser"


@dataclasses.dataclass(kw_only=True, frozen=True)
class OktaCredential(Credential):
@dataclasses.dataclass(frozen=True)
class OktaCredential:
authenticator: str
password: str

Expand Down
8 changes: 4 additions & 4 deletions schemachange/session/Script.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
T = TypeVar("T", bound="Script")


@dataclasses.dataclass(kw_only=True, frozen=True)
@dataclasses.dataclass(frozen=True)
class Script(ABC):
pattern: ClassVar[Pattern[str]]
type: ClassVar[Literal["V", "R", "A"]]
Expand Down Expand Up @@ -47,7 +47,7 @@ def from_path(cls, file_path: Path, **kwargs) -> T:
)


@dataclasses.dataclass(kw_only=True, frozen=True)
@dataclasses.dataclass(frozen=True)
class VersionedScript(Script):
pattern: ClassVar[re.Pattern[str]] = re.compile(
r"^(V)(?P<version>.+?)?__(?P<description>.+?)\.", re.IGNORECASE
Expand All @@ -64,15 +64,15 @@ def from_path(cls: T, file_path: Path, **kwargs) -> T:
)


@dataclasses.dataclass(kw_only=True, frozen=True)
@dataclasses.dataclass(frozen=True)
class RepeatableScript(Script):
pattern: ClassVar[re.Pattern[str]] = re.compile(
r"^(R)__(?P<description>.+?)\.", re.IGNORECASE
)
type: ClassVar[Literal["R"]] = "R"


@dataclasses.dataclass(kw_only=True, frozen=True)
@dataclasses.dataclass(frozen=True)
class AlwaysScript(Script):
pattern: ClassVar[re.Pattern[str]] = re.compile(
r"^(A)__(?P<description>.+?)\.", re.IGNORECASE
Expand Down

0 comments on commit fc0d0f1

Please sign in to comment.