From dd6b4ae628e29e3c7f7e6a5459ad6587d806e8c0 Mon Sep 17 00:00:00 2001 From: Perry Goy Date: Wed, 21 Feb 2024 10:47:30 -0600 Subject: [PATCH] remove unnecessary paths from Sphinx directives. --- screenpy/actions/either.py | 48 +++++++++++------------ screenpy/actions/eventually.py | 20 +++++----- screenpy/actions/make_note.py | 4 +- screenpy/actions/pause.py | 4 +- screenpy/actor.py | 70 +++++++++++++++++----------------- 5 files changed, 73 insertions(+), 73 deletions(-) diff --git a/screenpy/actions/either.py b/screenpy/actions/either.py index b6f556b..c977a0e 100644 --- a/screenpy/actions/either.py +++ b/screenpy/actions/either.py @@ -25,7 +25,7 @@ class Either: By default, ``Either`` catches AssertionErrors, so you can use :class:`~screenpy.actions.See` to decide which path to follow. Use the - :meth:`~screenpy.actions.Either.ignoring` method to ignore other exceptions. + :meth:`ignoring` method to ignore other exceptions. Examples:: @@ -46,33 +46,15 @@ class Either: except_performables: tuple[Performable, ...] ignore_exceptions: tuple[type[BaseException], ...] - def perform_as(self, the_actor: Actor) -> None: - """Direct the Actor to perform one of two performances.""" - # kinking the cable before the attempt - # avoids explaning what the actor tries to do. - # logs the first attempt only if it succeeds - # or if UNABRIDGED_NARRATION is enabled - with the_narrator.mic_cable_kinked(): - try: - the_actor.will(*self.try_performables) - except self.ignore_exceptions: - if not settings.UNABRIDGED_NARRATION: - the_narrator.clear_backup() - else: - return - - the_actor.will(*self.except_performables) - return - def or_(self, *except_performables: Performable) -> Self: """Provide the alternative routine to perform. Aliases: - * :meth:`~screenpy.actions.Either.except_` - * :meth:`~screenpy.actions.Either.else_` - * :meth:`~screenpy.actions.Either.otherwise` - * :meth:`~screenpy.actions.Either.alternatively` - * :meth:`~screenpy.actions.Either.failing_that` + * :meth:`except_` + * :meth:`else_` + * :meth:`otherwise` + * :meth:`alternatively` + * :meth:`failing_that` """ self.except_performables = except_performables return self @@ -95,6 +77,24 @@ def describe(self) -> str: return f"Either {try_summary} or {except_summary}" + def perform_as(self, the_actor: Actor) -> None: + """Direct the Actor to perform one of two performances.""" + # kinking the cable before the attempt + # avoids explaning what the actor tries to do. + # logs the first attempt only if it succeeds + # or if UNABRIDGED_NARRATION is enabled + with the_narrator.mic_cable_kinked(): + try: + the_actor.will(*self.try_performables) + except self.ignore_exceptions: + if not settings.UNABRIDGED_NARRATION: + the_narrator.clear_backup() + else: + return + + the_actor.will(*self.except_performables) + return + def __init__(self, *first: Performable) -> None: self.try_performables: tuple[Performable, ...] = first self.ignore_exceptions = (AssertionError,) diff --git a/screenpy/actions/eventually.py b/screenpy/actions/eventually.py index 4a44a91..9c332f8 100644 --- a/screenpy/actions/eventually.py +++ b/screenpy/actions/eventually.py @@ -81,40 +81,40 @@ def for_(self, amount: float) -> _TimeframeBuilder: """Set for how long the actor should continue trying. Aliases: - * :meth:`~screenpy.actions.Eventually.trying_for_no_longer_than` - * :meth:`~screenpy.actions.Eventually.trying_for` - * :meth:`~screenpy.actions.Eventually.waiting_for` + * :meth:`trying_for_no_longer_than` + * :meth:`trying_for` + * :meth:`waiting_for` """ return self._TimeframeBuilder(self, amount, "timeout") def trying_for_no_longer_than(self, amount: float) -> _TimeframeBuilder: - """Alias for :meth:`~screenpy.actions.Eventually.for_`.""" + """Alias for :meth:`for_`.""" return self.for_(amount) def trying_for(self, amount: float) -> _TimeframeBuilder: - """Alias for :meth:`~screenpy.actions.Eventually.for_`.""" + """Alias for :meth:`for_`.""" return self.for_(amount) def waiting_for(self, amount: float) -> _TimeframeBuilder: - """Alias for :meth:`~screenpy.actions.Eventually.for_`.""" + """Alias for :meth:`for_`.""" return self.for_(amount) def polling(self, amount: float) -> _TimeframeBuilder: """Adjust the polling frequency. Aliases: - * :meth:`~screenpy.actions.Eventually.polling_every` - * :meth:`~screenpy.actions.Eventually.trying_every` + * :meth:`polling_every` + * :meth:`trying_every` """ self.poll = amount return self._TimeframeBuilder(self, amount, "poll") def polling_every(self, amount: float) -> _TimeframeBuilder: - """Alias for :meth:`~screenpy.actions.Eventually.polling`.""" + """Alias for :meth:`polling`.""" return self.polling(amount) def trying_every(self, amount: float) -> _TimeframeBuilder: - """Alias for :meth:`~screenpy.actions.Eventually.polling`.""" + """Alias for :meth:`polling`.""" return self.polling(amount) def describe(self) -> str: diff --git a/screenpy/actions/make_note.py b/screenpy/actions/make_note.py index 10ecc2f..a3cea65 100644 --- a/screenpy/actions/make_note.py +++ b/screenpy/actions/make_note.py @@ -45,13 +45,13 @@ def of(cls, question: T_Q) -> Self: """Supply the Question to answer and its arguments. Aliases: - * :meth:`~screenpy.actions.MakeNote.of_the` + * :meth:`of_the` """ return cls(question) @classmethod def of_the(cls, question: T_Q) -> Self: - """Alias for :meth:`~screenpy.actions.MakeNote.of`.""" + """Alias for :meth:`of`.""" return cls.of(question) def as_(self, key: str) -> Self: diff --git a/screenpy/actions/pause.py b/screenpy/actions/pause.py index 421b37e..efbd863 100644 --- a/screenpy/actions/pause.py +++ b/screenpy/actions/pause.py @@ -50,14 +50,14 @@ def seconds_because(self, reason: str) -> Self: """Use seconds and provide a reason for the pause. Aliases: - * :meth:`~screenpy.actions.Pause.second_because` + * :meth:`second_because` """ self.unit = f"second{'s' if self.number != 1 else ''}" self.reason = self._massage_reason(reason) return self def second_because(self, reason: str) -> Self: - """Alias for :meth:`~screenpy.actions.Pause.seconds_because`.""" + """Alias for :meth:`seconds_because`.""" return self.seconds_because(reason) def milliseconds_because(self, reason: str) -> Self: diff --git a/screenpy/actor.py b/screenpy/actor.py index 83133cb..897c4ff 100644 --- a/screenpy/actor.py +++ b/screenpy/actor.py @@ -68,13 +68,13 @@ def who_can(self, *abilities: T_Ability) -> Self: """Add one or more Abilities to this Actor. Aliases: - * :meth:`~screenpy.actor.Actor.can` + * :meth:`can` """ self.abilities.extend(abilities) return self def can(self, *abilities: T_Ability) -> Self: - """Alias for :meth:`~screenpy.actor.Actor.who_can`.""" + """Alias for :meth:`who_can`.""" return self.who_can(*abilities) def has_ordered_cleanup_tasks(self, *tasks: Performable) -> Self: @@ -85,13 +85,13 @@ def has_ordered_cleanup_tasks(self, *tasks: Performable) -> Self: and will be discarded. Aliases: - * :meth:`~screenpy.actor.Actor.with_ordered_cleanup_tasks` + * :meth:`with_ordered_cleanup_tasks` """ self.ordered_cleanup_tasks.extend(tasks) return self def with_ordered_cleanup_tasks(self, *tasks: Performable) -> Self: - """Alias for :meth:`~screenpy.actor.Actor.has_ordered_cleanup_tasks`.""" + """Alias for :meth:`has_ordered_cleanup_tasks`.""" return self.has_ordered_cleanup_tasks(*tasks) def has_independent_cleanup_tasks(self, *tasks: Performable) -> Self: @@ -102,13 +102,13 @@ def has_independent_cleanup_tasks(self, *tasks: Performable) -> Self: previous ones were successful. Aliases: - * :meth:`~screenpy.actor.Actor.with_independent_cleanup_tasks` + * :meth:`with_independent_cleanup_tasks` """ self.independent_cleanup_tasks.extend(tasks) return self def with_independent_cleanup_tasks(self, *tasks: Performable) -> Self: - """Alias for :meth:`~screenpy.actor.Actor.has_independent_cleanup_tasks`.""" + """Alias for :meth:`has_independent_cleanup_tasks`.""" return self.has_independent_cleanup_tasks(*tasks) def uses_ability_to(self, ability: type[T_Ability]) -> T_Ability: @@ -118,7 +118,7 @@ def uses_ability_to(self, ability: type[T_Ability]) -> T_Ability: UnableToPerform: the Actor doesn't possess the Ability. Aliases: - * :meth:`~screenpy.actor.Actor.ability_to` + * :meth:`ability_to` """ for a in self.abilities: if isinstance(a, ability): @@ -128,7 +128,7 @@ def uses_ability_to(self, ability: type[T_Ability]) -> T_Ability: raise UnableToPerform(msg) def ability_to(self, ability: type[T_Ability]) -> T_Ability: - """Alias for :meth:`~screenpy.actor.Actor.uses_ability_to`.""" + """Alias for :meth:`uses_ability_to`.""" return self.uses_ability_to(ability) def has_ability_to(self, ability: type[T_Ability]) -> bool: @@ -144,58 +144,58 @@ def attempts_to(self, *actions: Performable) -> None: """Perform a list of Actions, one after the other. Aliases: - * :meth:`~screenpy.actor.Actor.was_able_to` - * :meth:`~screenpy.actor.Actor.should` - * :meth:`~screenpy.actor.Actor.shall` - * :meth:`~screenpy.actor.Actor.will` - * :meth:`~screenpy.actor.Actor.tries_to` - * :meth:`~screenpy.actor.Actor.tried_to` - * :meth:`~screenpy.actor.Actor.tries` - * :meth:`~screenpy.actor.Actor.tried` - * :meth:`~screenpy.actor.Actor.does` - * :meth:`~screenpy.actor.Actor.did` + * :meth:`was_able_to` + * :meth:`did` + * :meth:`will` + * :meth:`tries_to` + * :meth:`tried_to` + * :meth:`tries` + * :meth:`tried` + * :meth:`does` + * :meth:`should` + * :meth:`shall` """ for action in actions: self.perform(action) def was_able_to(self, *actions: Performable) -> None: - """Alias for :meth:`~screenpy.actor.Actor.attempts_to`.""" + """Alias for :meth:`attempts_to`.""" return self.attempts_to(*actions) def tries_to(self, *actions: Performable) -> None: - """Alias for :meth:`~screenpy.actor.Actor.attempts_to`.""" + """Alias for :meth:`attempts_to`.""" return self.attempts_to(*actions) def tried_to(self, *actions: Performable) -> None: - """Alias for :meth:`~screenpy.actor.Actor.attempts_to`.""" + """Alias for :meth:`attempts_to`.""" return self.attempts_to(*actions) def tries(self, *actions: Performable) -> None: - """Alias for :meth:`~screenpy.actor.Actor.attempts_to`.""" + """Alias for :meth:`attempts_to`.""" return self.attempts_to(*actions) def tried(self, *actions: Performable) -> None: - """Alias for :meth:`~screenpy.actor.Actor.attempts_to`.""" + """Alias for :meth:`attempts_to`.""" return self.attempts_to(*actions) def does(self, *actions: Performable) -> None: - """Alias for :meth:`~screenpy.actor.Actor.attempts_to`.""" + """Alias for :meth:`attempts_to`.""" return self.attempts_to(*actions) def did(self, *actions: Performable) -> None: - """Alias for :meth:`~screenpy.actor.Actor.attempts_to`.""" + """Alias for :meth:`attempts_to`.""" return self.attempts_to(*actions) def will(self, *actions: Performable) -> None: - """Alias for :meth:`~screenpy.actor.Actor.attempts_to`.""" + """Alias for :meth:`attempts_to`.""" return self.attempts_to(*actions) def shall(self, *actions: Performable) -> None: - """Alias for :meth:`~screenpy.actor.Actor.attempts_to`.""" + """Alias for :meth:`attempts_to`.""" return self.attempts_to(*actions) def should(self, *actions: Performable) -> None: - """Alias for :meth:`~screenpy.actor.Actor.attempts_to`.""" + """Alias for :meth:`attempts_to`.""" return self.attempts_to(*actions) def perform(self, action: Performable) -> None: @@ -234,9 +234,9 @@ def exit(self) -> None: """Direct the Actor to forget all their Abilities. Aliases: - * :meth:`~screenpy.actor.Actor.exit_stage_left` - * :meth:`~screenpy.actor.Actor.exit_stage_right` - * :meth:`~screenpy.actor.Actor.exit_through_vomitorium` + * :meth:`exit_stage_left` + * :meth:`exit_stage_right` + * :meth:`exit_through_vomitorium` """ self.cleans_up() for ability in self.abilities: @@ -244,19 +244,19 @@ def exit(self) -> None: self.abilities = [] def exit_stage_left(self) -> None: - """Alias for :meth:`~screenpy.actor.Actor.exit`.""" + """Alias for :meth:`exit`.""" return self.exit() def exit_stage_right(self) -> None: - """Alias for :meth:`~screenpy.actor.Actor.exit`.""" + """Alias for :meth:`exit`.""" return self.exit() def exit_through_vomitorium(self) -> None: - """Alias for :meth:`~screenpy.actor.Actor.exit`.""" + """Alias for :meth:`exit`.""" return self.exit() def __call__(self, *actions: Performable) -> None: - """Alias for :meth:`~screenpy.actor.Actor.attempts_to`.""" + """Alias for :meth:`attempts_to`.""" return self.attempts_to(*actions) def __repr__(self) -> str: