Skip to content

Commit

Permalink
chore: Remove closure factory
Browse files Browse the repository at this point in the history
This is not needed to do, since there is `staticmethod`.
  • Loading branch information
rumpelsepp committed Dec 18, 2024
1 parent b6f57ee commit 5983016
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/gallia/cli/gallia.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,11 @@ def parse_and_run(

parser = create_parser(commands)

def make_f(c: Callable[[], None]) -> Callable[[Any], None]:
def f(_: Any) -> None:
c()

return f

if top_level_options is not None:
for name, (func, help_) in top_level_options.items():

class Action(argparse.Action):
f = make_f(func)
cmd = staticmethod(func)

def __call__(
self,
Expand All @@ -164,7 +158,7 @@ def __call__(
values: str | Sequence[Any] | None,
option_string: str | None = None,
) -> None:
self.f()
self.cmd()
sys.exit(exitcodes.OK)

parser.add_argument(
Expand Down

0 comments on commit 5983016

Please sign in to comment.