Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update black version #119

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions sambacc/commands/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ class Fail(ValueError):


class Parser(typing.Protocol):
"""Minimal protocol for wrapping argument parser or similar."""

def set_defaults(self, **kwargs: typing.Any) -> None:
"""Set a default value for an argument parser."""
... # pragma: no cover

def add_argument(
self, *args: typing.Any, **kwargs: typing.Any
) -> typing.Any:
"""Add an argument to be parsed."""
... # pragma: no cover


Expand Down Expand Up @@ -133,18 +137,22 @@ class Context(typing.Protocol):

@property
def cli(self) -> argparse.Namespace:
"""Return a parsed command line namespace object."""
... # pragma: no cover

@property
def instance_config(self) -> config.InstanceConfig:
"""Return an instance config based on cli params and env."""
... # pragma: no cover

@property
def require_validation(self) -> typing.Optional[bool]:
"""Return true if configuration needs validation."""
... # pragma: no cover

@property
def opener(self) -> opener.Opener:
"""Return an appropriate opener object for this instance."""
... # pragma: no cover


Expand Down
4 changes: 4 additions & 0 deletions sambacc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,14 @@ def read_config_files(


class SambaConfig(typing.Protocol):
"""Minimal samba configuration protocol."""

def global_options(self) -> typing.Iterable[typing.Tuple[str, str]]:
"""Return global options for Samba."""
... # pragma: no cover

def shares(self) -> typing.Iterable[ShareConfig]:
"""Return share configurations for Samba."""
... # pragma: no cover


Expand Down
13 changes: 10 additions & 3 deletions sambacc/ctdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,25 @@


class ClusterMetaObject(typing.Protocol):
"A Cluster Meta Object can load or dump persistent cluster descriptions."

def load(self) -> typing.Any:
...
"""Load a JSON-compatible object."""
... # pragma: no cover

def dump(self, data: typing.Any) -> None:
...
"""Dump (save) a JSON-compatible object."""
... # pragma: no cover


class ClusterMeta(typing.Protocol):
"""ClusterMeta manages access to persistent cluster descriptions."""

def open(
self, *, read: bool = True, write: bool = False, locked: bool = False
) -> typing.ContextManager[ClusterMetaObject]:
...
"""Return a context manager with access to a cluster meta object."""
... # pragma: no cover


class NodeState(str, enum.Enum):
Expand Down
3 changes: 3 additions & 0 deletions sambacc/leader.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class LeaderStatus(typing.Protocol):
"""Fetches information about the current cluster leader."""

def is_leader(self) -> bool:
"""Return true if the current node is the leader."""
... # pragma: no cover


Expand All @@ -35,9 +36,11 @@ class LeaderLocator(typing.Protocol):
"""

def __enter__(self) -> LeaderStatus:
"""Enter context manager. Returns LeaderStatus."""
... # pragma: no cover

def __exit__(
self, exc_type: ExcType, exc_val: ExcValue, exc_tb: ExcTraceback
) -> bool:
"""Exit context manager."""
... # pragma: no cover
1 change: 1 addition & 0 deletions sambacc/opener.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Opener(typing.Protocol):
"""

def open(self, path_or_uri: str) -> typing.IO:
"""Open a specified resource by path or (pseudo) URI."""
... # pragma: no cover


Expand Down
1 change: 1 addition & 0 deletions sambacc/simple_waiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Waiter(typing.Protocol):
"""Waiter protocol - interfaces common to all waiters."""

def wait(self) -> None:
"""Pause execution for a time."""
... # pragma: no cover

def acted(self) -> None:
Expand Down
3 changes: 3 additions & 0 deletions sambacc/smbconf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@

class ConfigStore(typing.Protocol):
def __getitem__(self, name: str) -> list[tuple[str, str]]:
"""Get an item, returning a config section."""
... # pragma: no cover

def __setitem__(self, name: str, value: list[tuple[str, str]]) -> None:
"""Set a new config section."""
... # pragma: no cover

def __iter__(self) -> typing.Iterator[str]:
"""Iterate over config sections in the store."""
... # pragma: no cover


Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,23 @@ allowlist_externals =
description = Check the formatting for the source files
deps =
flake8
black>=23, <24
black>=24, <25
commands =
flake8 sambacc tests
black --check -v .

[testenv:schemacheck]
description = Check the JSON Schema files are valid
deps =
black>=23, <24
black>=24, <25
PyYAML
commands =
python -m sambacc.schema.tool

[testenv:schemaupdate]
description = Regenerate source files from JSON Schema file(s)
deps =
black>=23, <24
black>=24, <25
PyYAML
commands =
python -m sambacc.schema.tool --update
Expand Down
Loading