Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dwreeves committed Dec 11, 2023
1 parent 059e4f2 commit 9c19935
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions src/rich_click/rich_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,16 @@ def format_options(self, ctx: RichContext, formatter: RichHelpFormatter) -> None
def format_epilog(self, ctx: RichContext, formatter: RichHelpFormatter) -> None: # type: ignore[override]
get_rich_epilog(self, ctx, formatter)

if CLICK_IS_BEFORE_VERSION_8X:

def make_context(
self,
info_name: Optional[str],
args: List[str],
parent: Optional[click.Context] = None,
**extra: Any,
) -> RichContext:
def make_context(
self,
info_name: Optional[str],
args: List[str],
parent: Optional[click.Context] = None,
**extra: Any,
) -> RichContext:
if CLICK_IS_BEFORE_VERSION_8X:
# Reimplement Click 8.x logic.

for key, value in self.context_settings.items():
if key not in extra:
extra[key] = value
Expand All @@ -205,15 +206,7 @@ def make_context(
self.parse_args(ctx, args)
return ctx

else:

def make_context(
self,
info_name: Optional[str],
args: List[str],
parent: Optional[click.Context] = None,
**extra: Any,
) -> RichContext:
else:
return super().make_context(info_name, args, parent, **extra) # type: ignore[return-value]


Expand Down Expand Up @@ -245,7 +238,7 @@ def command(self, *args: Any, **kwargs: Any) -> Callable[[Callable[..., Any]], R
def command(self, *args: Any, **kwargs: Any) -> Union[Callable[[Callable[..., Any]], RichCommand], RichCommand]:
# This method override is required for Click 7.x compatibility.
# (The command_class ClassVar was not added until 8.0.)
if self.command_class is not None:
if CLICK_IS_BEFORE_VERSION_8X:
kwargs.setdefault("cls", self.command_class)
return super().command(*args, **kwargs) # type: ignore[no-any-return]

Expand All @@ -260,10 +253,11 @@ def group(self, *args: Any, **kwargs: Any) -> Callable[[Callable[..., Any]], "Ri
def group(self, *args: Any, **kwargs: Any) -> Union[Callable[[Callable[..., Any]], "RichGroup"], "RichGroup"]:
# This method override is required for Click 7.x compatibility.
# (The group_class ClassVar was not added until 8.0.)
if self.group_class is type:
kwargs.setdefault("cls", self.__class__)
elif self.group_class is not None:
kwargs.setdefault("cls", self.group_class)
if CLICK_IS_BEFORE_VERSION_8X:
if self.group_class is type:
kwargs.setdefault("cls", self.__class__)
else:
kwargs.setdefault("cls", self.group_class)
return super().group(*args, **kwargs) # type: ignore[no-any-return]


Expand Down

0 comments on commit 9c19935

Please sign in to comment.