Skip to content

Commit

Permalink
fix typing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tfeldmann committed Nov 25, 2024
1 parent 54d757e commit e0984e0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
6 changes: 5 additions & 1 deletion organize/actions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from typing import Tuple, Type

from organize.action import Action

from .confirm import Confirm
from .copy import Copy
from .delete import Delete
Expand All @@ -12,7 +16,7 @@
from .trash import Trash
from .write import Write

ALL = (
ALL: Tuple[Type[Action], ...] = (
Confirm,
Copy,
Delete,
Expand Down
18 changes: 8 additions & 10 deletions organize/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
ConfigDict,
Field,
ValidationError,
field_validator,
model_validator,
)
from pydantic.functional_validators import BeforeValidator
Expand Down Expand Up @@ -234,20 +233,19 @@ class CliArgs(BaseModel):
version: bool = Field(..., alias="--version")
help: bool = Field(..., alias="--help")

@field_validator("tags", "skip_tags", mode="after")
@classmethod
def split_tags(cls, val) -> Set[str]:
if val is None:
return set()
return set(val.split(","))

@model_validator(mode="after")
def either_stdin_or_config(self):
if self.stdin and self.config is not None:
raise ValueError("Either set a config file or --stdin.")
return self


def _split_tags(val: Optional[str]) -> Tags:
if val is None:
return set()
return set(val.split(","))


def cli(argv: Union[list[str], str, None] = None) -> None:
enable_logfile()
assert __doc__ is not None
Expand All @@ -272,8 +270,8 @@ def _config_with_path():
config=_config_with_path(),
working_dir=args.working_dir,
format=args.format,
tags=args.tags,
skip_tags=args.skip_tags,
tags=_split_tags(args.tags),
skip_tags=_split_tags(args.skip_tags),
)
if args.run:
_execute(simulate=False)
Expand Down
8 changes: 4 additions & 4 deletions organize/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def action_by_name(name: str) -> Type[Action]:


# Register filters and actions
for x in filters.ALL:
register_filter(x)
for x in actions.ALL:
register_action(x)
for _filter in filters.ALL:
register_filter(_filter) # type: ignore
for _action in actions.ALL:
register_action(_action)

0 comments on commit e0984e0

Please sign in to comment.