Skip to content

Commit 3b09b66

Browse files
authored
chore: Run pycodestyle fixes, add some docstrings (#285)
1 parent 2b2aadb commit 3b09b66

27 files changed

+224
-61
lines changed

tests/pyzabbix/test_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ def test_login_fails(zabbix_client_mock_version: ZabbixAPI) -> None:
9999

100100
def test_logout_fails(zabbix_client_mock_version: ZabbixAPI) -> None:
101101
"""Test that we get the correct exception type when login fails
102-
due to a connection error."""
102+
due to a connection error.
103+
"""
103104
client = zabbix_client_mock_version
104105
client.set_url("http://some-url-that-will-fail.gg")
105106
assert client.url == snapshot("http://some-url-that-will-fail.gg/api_jsonrpc.php")

tests/test_auth.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def test_get_auth_token_file_paths_override(tmp_path: Path, config: Config) -> N
8383
@pytest.fixture
8484
def table_renderable_mock(monkeypatch) -> type[TableRenderable]:
8585
"""Replace TableRenderable class in zabbix_cli.models with mock class
86-
so that tests can mutate it without affecting other tests."""
86+
so that tests can mutate it without affecting other tests.
87+
"""
8788
from zabbix_cli.models import TableRenderable
8889

8990
class MockTableRenderable(TableRenderable):

tests/test_config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def remove_path_options(config_path: Path, tmp_path: Path) -> None:
5858
"""Remove all path options from a TOML config file.
5959
6060
Some config options require a directory or file to exist, which is not always
61-
possible or desirable in a test environment."""
61+
possible or desirable in a test environment.
62+
"""
6263
contents = config_path.read_text()
6364
new_contents = "\n".join(
6465
line for line in contents.splitlines() if "/path/to" not in line
@@ -531,7 +532,8 @@ def test_load_deprecated_config_with_new_and_old_options(tmp_path: Path) -> None
531532
"""Test loading a config file where both new and deprecated options are present.
532533
533534
The deprecated options should _not_ be assigned to the new options, as the new options
534-
are already set"""
535+
are already set
536+
"""
535537
conf = tmp_path / "zabbix-cli.toml"
536538
conf.write_text(
537539
"""

tests/test_models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class TestTableRenderable(TableRenderable):
6868

6969
def test_rows_with_unknown_base_model(caplog: LogCaptureFixture) -> None:
7070
"""Test that we log when we try to render a BaseModel
71-
instance that does not inherit from TableRenderable."""
71+
instance that does not inherit from TableRenderable.
72+
"""
7273

7374
class FooModel(BaseModel):
7475
foo: str

zabbix_cli/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ def login_with_any(self) -> tuple[ZabbixAPI, LoginInfo]:
252252
7. Session ID in legacy auth token file (if `use_session_file=true`)
253253
8. Username and password from prompt
254254
"""
255-
256255
for credentials in self._iter_all_credentials():
257256
if not credentials.is_valid():
258257
logger.debug("No valid credentials found with %s", credentials)
@@ -562,7 +561,8 @@ def _get_session_file(self) -> Optional[Credentials]:
562561
def _get_auth_token_file_legacy(self) -> Optional[Credentials]:
563562
"""Get auth token (session ID) from a legacy auth token file.
564563
565-
From Zabbix-CLI 3.5.0 onwards, we use a new session file."""
564+
From Zabbix-CLI 3.5.0 onwards, we use a new session file.
565+
"""
566566
if not self.config.app.use_session_file:
567567
logger.debug("Not configured to use auth token file.")
568568
return

zabbix_cli/bulk.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ def run_bulk(self) -> Counter[CommandResult]:
170170
CommandFileError: If command file cannot be parsed or a command fails (in STRICT mode)
171171
172172
Example:
173-
174173
```bash
175174
$ cat /tmp/commands.txt
176175

zabbix_cli/commands/cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ def update_config(
365365
) -> None:
366366
"""Update the config file with the current application state.
367367
368-
Adds missing fields and updates deprecated fields to their new values."""
368+
Adds missing fields and updates deprecated fields to their new values.
369+
"""
369370
from zabbix_cli.output.prompts import bool_prompt
370371

371372
config_file = config_file or app.state.config.config_path
@@ -385,7 +386,8 @@ def update_application(ctx: typer.Context) -> None:
385386
"""Update the application to the latest version.
386387
387388
Primarily intended for use with PyInstaller builds, but can also be
388-
used for updating other installations (except Homebrew)."""
389+
used for updating other installations (except Homebrew).
390+
"""
389391
from zabbix_cli.__about__ import __version__
390392
from zabbix_cli.update import update
391393

zabbix_cli/commands/hostgroup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ def show_hostgroups(
422422
) -> None:
423423
"""Show details for host groups.
424424
425-
Limits results to 20 by default. Fetching all host groups with hosts can be extremely slow."""
425+
Limits results to 20 by default. Fetching all host groups with hosts can be extremely slow.
426+
"""
426427
from zabbix_cli.commands.results.hostgroup import HostGroupResult
427428
from zabbix_cli.models import AggregateResult
428429

zabbix_cli/commands/user.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ def show_users(
330330
) -> None:
331331
"""Show all users.
332332
333-
Users can be filtered by name, ID, or role."""
333+
Users can be filtered by name, ID, or role.
334+
"""
334335
from zabbix_cli.models import AggregateResult
335336
from zabbix_cli.pyzabbix.compat import user_name
336337

zabbix_cli/commands/usergroup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def sort_ugroups(
4949
5050
I.e. we have some custom types that all share the samse attributes
5151
`name` and `usrgrpid`. This function sorts them based on the given
52-
sorting method."""
52+
sorting method.
53+
"""
5354
if sort == UsergroupSorting.NAME:
5455
return sorted(ugroups, key=lambda ug: ug.name)
5556
elif sort == UsergroupSorting.ID:
@@ -330,7 +331,8 @@ def show_usergroups(
330331
) -> None:
331332
"""Show all suser groups.
332333
333-
Can be filtered by name or ID."""
334+
Can be filtered by name or ID.
335+
"""
334336
_do_show_usergroups(usergroup, sort=sort, limit=limit)
335337

336338

0 commit comments

Comments
 (0)