Skip to content

Commit ee91c93

Browse files
committed
test: fixes after bumping deps
1 parent 04e2f43 commit ee91c93

21 files changed

+54
-33
lines changed

mac_cleanup/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Mocking HomeBrew entrypoint."""
2+
23
# -*- coding: utf-8 -*-
34
import re
45
import sys

mac_cleanup/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
try: # For gh-actions
22
from importlib.metadata import version
33

4-
__version__ = version(__package__)
4+
__version__ = version(__package__) # pyright: ignore [reportArgumentType]
55
except ModuleNotFoundError: # pragma: no cover
66
__version__ = "source"

mac_cleanup/config.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Config handler."""
2+
23
from inspect import getmembers, isfunction
34
from pathlib import Path
45
from typing import Callable, Final, Optional, TypedDict, final
@@ -34,8 +35,10 @@ def __init__(self, config_path_: Path):
3435
self.__load_default()
3536

3637
# Load config
38+
self.__config_data: Final[ConfigFile]
39+
3740
try:
38-
self.__config_data: Final[ConfigFile] = self.__read()
41+
self.__config_data = self.__read()
3942
except FileNotFoundError:
4043
console.print("[danger]Modules not configured, opening configuration screen...[/danger]")
4144

@@ -175,12 +178,12 @@ def __configure(self, *, all_modules: list[str], enabled_modules: list[str]) ->
175178
title="[info]Controls",
176179
)
177180

178-
questions = inquirer.Checkbox( # pyright: ignore [reportUnknownVariableType, reportUnknownMemberType]
181+
questions = inquirer.Checkbox( # pyright: ignore [reportUnknownMemberType]
179182
"modules", message="Active modules", choices=all_modules, default=enabled_modules, carousel=True
180183
)
181184

182185
# Get user answers
183-
answers = inquirer.prompt( # pyright: ignore [reportUnknownMemberType]
186+
answers = inquirer.prompt( # pyright: ignore [reportUnknownVariableType, reportUnknownMemberType]
184187
questions=[questions], raise_keyboard_interrupt=True
185188
)
186189

mac_cleanup/console.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Configuration of Rich console."""
2+
23
from typing import Optional
34

45
from rich.console import Console

mac_cleanup/core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Core for collecting all unit modules."""
2+
23
from functools import partial
34
from itertools import chain
45
from pathlib import Path as Path_

mac_cleanup/core_modules.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""All core modules."""
2+
23
from abc import ABC, abstractmethod
34
from pathlib import Path as Path_
45
from typing import Final, Optional, TypeVar, final
@@ -32,11 +33,11 @@ def with_prompt(self: T, message_: Optional[str] = None) -> T:
3233
return self
3334

3435
# Can't be solved without typing.Self
35-
self.__prompt = True # pyright: ignore [reportGeneralTypeIssues]
36+
self.__prompt = True # pyright: ignore [reportAttributeAccessIssue]
3637

3738
if message_:
3839
# Can't be solved without typing.Self
39-
self.__prompt_message = message_ # pyright: ignore [reportGeneralTypeIssues]
40+
self.__prompt_message = message_ # pyright: ignore [reportAttributeAccessIssue]
4041

4142
return self
4243

mac_cleanup/default_modules.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ def yarn():
337337
unit.add(Command("yarn cache clean --force"))
338338
unit.add(Path("~/Library/Caches/yarn").dry_run_only())
339339

340+
340341
def bun():
341342
from mac_cleanup.utils import cmd
342343

@@ -346,6 +347,7 @@ def bun():
346347
unit.add(Command("bun pm cache rm"))
347348
unit.add(Path("~/.bun/install/cache").dry_run_only())
348349

350+
349351
def pod():
350352
from mac_cleanup.utils import cmd
351353

@@ -449,12 +451,13 @@ def telegram():
449451
if reopen_telegram:
450452
unit.add(Command("open /Applications/Telegram.app"))
451453

452-
def conan():
454+
455+
def conan():
453456
with clc as unit:
454457
unit.message("Clearing conan cache")
455458
unit.add(Command("""conan remove "*" -c"""))
456459
unit.add(Path("~/.conan2/p/"))
457-
460+
458461

459462
def nuget_cache():
460463
with clc as unit:

mac_cleanup/error_handling.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Wrapper for handling all errors in entry point."""
2+
23
from functools import wraps
34
from typing import Any, Callable, Iterable, Optional, Type, TypeVar, overload
45

@@ -76,15 +77,15 @@ def wrapper(*args: Any, **kwargs: Any) -> Optional[T]:
7677

7778

7879
@overload
79-
def catch_exception(func: T, exception: Optional[_exception] = ..., exit_on_exception: bool = ...) -> T:
80-
... # pragma: no cover (coverage marks line as untested)
80+
def catch_exception(
81+
func: T, exception: Optional[_exception] = ..., exit_on_exception: bool = ...
82+
) -> T: ... # pragma: no cover (coverage marks line as untested)
8183

8284

8385
@overload
8486
def catch_exception(
8587
func: None = ..., exception: Optional[_exception] = ..., exit_on_exception: bool = ...
86-
) -> ErrorHandler:
87-
... # pragma: no cover (coverage marks line as untested)
88+
) -> ErrorHandler: ... # pragma: no cover (coverage marks line as untested)
8889

8990

9091
def catch_exception(

mac_cleanup/main.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from os import environ
2-
from os import statvfs
1+
from os import environ, statvfs
32
from pathlib import Path
43

54
from mac_cleanup.config import Config
@@ -12,7 +11,7 @@
1211

1312
class EntryPoint:
1413
if (config_home := environ.get("XDG_CONFIG_HOME")) is not None:
15-
config_path = Path(config_home).expanduser().joinpath("mac_cleanup_py").joinpath("config.toml")
14+
config_path = Path(config_home).expanduser().joinpath("mac_cleanup_py").joinpath("config.toml")
1615
else:
1716
config_path = Path.home().joinpath(".mac_cleanup_py")
1817

@@ -43,8 +42,7 @@ def cleanup(self) -> None:
4342

4443
# Print results
4544
print_panel(
46-
text=f"Removed - [success]{bytes_to_human(free_space_after - free_space_before)}",
47-
title="[info]Success",
45+
text=f"Removed - [success]{bytes_to_human(free_space_after - free_space_before)}", title="[info]Success"
4846
)
4947

5048
@catch_exception

mac_cleanup/parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Console argument parser configuration."""
2+
23
from argparse import ArgumentParser, RawTextHelpFormatter
34
from typing import final
45

mac_cleanup/progress.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Modified rich progress bar."""
2+
23
from typing import Iterable, Optional, Sequence
34

45
from rich.progress import (

mac_cleanup/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def check_deletable(path: Path | str) -> bool:
9797
if any(path_posix.startswith(protected_path) for protected_path in list(map(expanduser, sip_list + user_list))):
9898
return False
9999

100-
return "com.apple.rootless" not in xattr(path_posix).keys()
100+
return "com.apple.rootless" not in xattr(path_posix)
101101

102102

103103
@beartype

module_template.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Custom module template example."""
2+
23
from mac_cleanup import *
34

45
# Do not import any functions at the top level

tests/test_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""All tests for mac_cleanup_py.config."""
2+
23
import tempfile
34
from pathlib import Path
45
from typing import IO, Callable, Optional

tests/test_core.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""All tests for mac_cleanup_py.core."""
2+
23
import os
34
import tempfile
45
from pathlib import Path as Pathlib
@@ -33,10 +34,10 @@ def test_create_unit(self):
3334

3435
# Check errors
3536
with pytest.raises(TypeError):
36-
Unit(message=message, modules=[123]) # pyright: ignore [reportGeneralTypeIssues] # noqa
37+
Unit(message=message, modules=[123]) # pyright: ignore [reportArgumentType] # noqa
3738

3839
with pytest.raises(TypeError):
39-
Unit(message=message, modules=123) # pyright: ignore [reportGeneralTypeIssues] # noqa
40+
Unit(message=message, modules=123) # pyright: ignore [reportArgumentType] # noqa
4041

4142

4243
class TestCollector:
@@ -56,7 +57,7 @@ def test_errors_on_exit(self, raised_error: Type[BaseException]):
5657
raise raised_error
5758

5859
@staticmethod
59-
@pytest.fixture()
60+
@pytest.fixture
6061
def base_collector() -> _Collector:
6162
"""Get main collector instance - :class:`mac_cleanup.core._Collector`"""
6263

@@ -121,9 +122,10 @@ def test_get_size(self, size_multiplier: int, base_collector: _Collector):
121122
# Get size in bytes
122123
size = 1024 * size_multiplier
123124

124-
with tempfile.TemporaryDirectory() as dir_name, tempfile.NamedTemporaryFile(
125-
mode="w+b", dir=dir_name, prefix="test_get_size", suffix=".test"
126-
) as f:
125+
with (
126+
tempfile.TemporaryDirectory() as dir_name,
127+
tempfile.NamedTemporaryFile(mode="w+b", dir=dir_name, prefix="test_get_size", suffix=".test") as f,
128+
):
127129
# Write random bytes with specified size
128130
f.write(os.urandom(size))
129131

tests/test_core_modules.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""All tests for mac_cleanup_py.config."""
2+
23
import tempfile
34
from pathlib import Path as Pathlib
45
from typing import IO, Callable, Optional, cast

tests/test_error_handling.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test global error handler."""
2+
23
from typing import Iterable, Type
34

45
import pytest

tests/test_main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test main script in mac_cleanup_py.main."""
2+
23
from pathlib import Path as Pathlib
34
from typing import Any, Callable
45

@@ -59,9 +60,9 @@ def dummy_count_free_space(entry_self: EntryPoint) -> float: # noqa
5960
if not hasattr(dummy_count_free_space, "called"):
6061
dummy_count_free_space.called = True # pyright: ignore [reportFunctionMemberAccess]
6162

62-
return 1024**2 * size_multiplier / 2
63+
return 1024**3 * size_multiplier / 2
6364
else:
64-
return 1024**2 * size_multiplier
65+
return 1024**3 * size_multiplier
6566

6667
# Dummy module execution (empty one)
6768
dummy_module_execute: Callable[[BaseModule], None] = lambda md_self: None
@@ -150,7 +151,7 @@ def dummy_config_call(config_path_: Pathlib, configuration_prompted: bool) -> No
150151
if not cleanup_prompted:
151152
assert "Exiting..." in captured_stdout
152153

153-
def test_test_dry_run_prompt_error(self, capsys: CaptureFixture[str], monkeypatch: MonkeyPatch):
154+
def test_dry_run_prompt_error(self, capsys: CaptureFixture[str], monkeypatch: MonkeyPatch):
154155
"""Test errors in dry_run in :class:`mac_cleanup.main.EntryPoint`"""
155156

156157
# Dummy count_dry returning 1 GB

tests/test_parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
"""All tests for mac_cleanup_py.parser."""
2+
23
from argparse import Action
34

45
import pytest
56

67
from mac_cleanup.parser import Args, parser
78

89

9-
@pytest.fixture()
10+
@pytest.fixture
1011
def get_namespace() -> Args:
1112
"""Get empty args."""
1213

tests/test_progress.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""All tests for mac_cleanup_py.progress."""
2+
23
from typing import Callable
34

45
import pytest

tests/test_utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""All tests for mac_cleanup_py.utils."""
2+
23
from pathlib import Path
34
from typing import Optional
45

@@ -28,7 +29,7 @@ def test_cmd(command: str | int, ignore_errors: bool, output: str):
2829

2930
if isinstance(command, int):
3031
with pytest.raises(BeartypeCallHintParamViolation):
31-
cmd(command=command, ignore_errors=ignore_errors) # pyright: ignore [reportGeneralTypeIssues] # noqa
32+
cmd(command=command, ignore_errors=ignore_errors) # pyright: ignore [reportArgumentType] # noqa
3233
return
3334

3435
assert cmd(command=command, ignore_errors=ignore_errors) == output
@@ -52,7 +53,7 @@ def test_expanduser(str_path: str | int, output: Optional[str]):
5253

5354
if isinstance(str_path, int):
5455
with pytest.raises(BeartypeCallHintParamViolation):
55-
expanduser(str_path=str_path) # pyright: ignore [reportGeneralTypeIssues] # noqa
56+
expanduser(str_path=str_path) # pyright: ignore [reportArgumentType] # noqa
5657
return
5758

5859
if output is None:
@@ -94,7 +95,7 @@ def test_check_exists(path: Path | str | int, output: bool, expand_path: bool):
9495

9596
if isinstance(path, int):
9697
with pytest.raises(BeartypeCallHintParamViolation):
97-
check_exists(path=path, expand_user=expand_path) # pyright: ignore [reportGeneralTypeIssues] # noqa
98+
check_exists(path=path, expand_user=expand_path) # pyright: ignore [reportArgumentType] # noqa
9899
return
99100

100101
assert check_exists(path=path, expand_user=expand_path) is output
@@ -134,7 +135,7 @@ def test_check_deletable(path: Path | str | int, output: bool):
134135

135136
if isinstance(path, int):
136137
with pytest.raises(BeartypeCallHintParamViolation):
137-
check_deletable(path=path) # pyright: ignore [reportGeneralTypeIssues] # noqa
138+
check_deletable(path=path) # pyright: ignore [reportArgumentType] # noqa
138139
return
139140

140141
assert check_deletable(path=path) is output
@@ -166,7 +167,7 @@ def test_bytes_to_human(byte: int | str, in_power: int, output: str):
166167

167168
if isinstance(byte, str):
168169
with pytest.raises(BeartypeCallHintParamViolation):
169-
bytes_to_human(size_bytes=byte) # pyright: ignore [reportGeneralTypeIssues] # noqa
170+
bytes_to_human(size_bytes=byte) # pyright: ignore [reportArgumentType] # noqa
170171
return
171172

172173
assert bytes_to_human(size_bytes=byte**in_power) == output

0 commit comments

Comments
 (0)