Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#19: Fix typing for aliases. #20

Merged
merged 6 commits into from
May 13, 2022
Merged

#19: Fix typing for aliases. #20

merged 6 commits into from
May 13, 2022

Conversation

perrygoy
Copy link
Member

In #19, @langgaibo reported that mypy did not like MakeNote's of_the method. After investigating, of was OK, but of_the was causing a complaint. This seems to be a bug, or a shortcoming, or something in MyPy itself, see MyPy#6700.

This PR takes the workaround suggested in the above MyPy issue, by defining the aliases as other methods. Technically only the classmethods had this problem, but i felt it was weird to only do it for those. Doing it for all the aliases allows the documentation to be more explicit about what methods are aliases of which other methods!

@@ -13,6 +13,8 @@
from .protocols import Forgettable, Performable
from .speech_tools import get_additive_description

# pylint: disable=too-many-public-methods
Copy link
Member Author

@perrygoy perrygoy May 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why pylint was OK with all the aliases when they were created using = but complains now. This sure shut it up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The aliases within _TimeframeBuilder should get converted also.
millisecond = milliseconds

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't convert them because they aren't surfaced for documentation (currently) and also do not have the problems that the classmethods did.

... Unless they do?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you're right. They are just aliases. AFAICT they don't have the same problem as the classmethods.

Copy link
Member

@langgaibo langgaibo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope i'm not missing anything crucial.
I've commented on one set of aliases I think should be either streamlined or expanded to the logical conclusion they're going for.

Comment on lines +106 to +108
def with_ordered_cleanup_tasks(self, *tasks: Performable) -> "Actor":
"""Alias for :meth:`~screenpy.actor.Actor.has_ordered_cleanup_tasks`."""
return self.has_ordered_cleanup_tasks(*tasks)
Copy link
Member

@langgaibo langgaibo May 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose we simply drop the singular variants of these methods because it's purely an English detail.
That would render a total of 6 aliases comprising both types of cleanup tasks.

(or even better, 4 total if we just drop the ordered aliases and rely on independent cleanup tasks to already be distinguishing themselves from the implied ordered ones... but that's a separate discussion.)

If we do want to explicitly alias singular and plural forms as you have here then we should also include all the options by adding with_cleanup_tasks, has_ordered_cleanup_task, with_ordered_cleanup_task, has_independent_cleanup_task, and with_independent_cleanup_task.
This would bring us to a total of 11 12 methods spanning both types of cleanup task!

Personally I'd rather just accept a format in which has_{type}_cleanup_tasks() may contain one or more tasks, but you know my position is that English readability doesn't have to mean native speaker english readability in terms of precise tense agreement

the_actor.has_ordered_cleanup_tasks(ClickButton())
the_actor.has_independent_cleanup_tasks(
    ClearTextField(),
    LogOut(),
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TL:DR -

A) (my preference) Dropping the singulars would leave us with:

has_cleanup_tasks()
has_ordered_cleanup_tasks()
with_cleanup_tasks()
with_ordered_cleanup_tasks()

has_independent_cleanup_tasks()
with_independent_cleanup_tasks()

B) (something to consider) Also dropping the ordered variants and relying on the existing distinction already evident by the independent methods would leave us with

has_cleanup_tasks()
with_cleanup_tasks()

has_independent_cleanup_tasks()
with_independent_cleanup_tasks()

C) (english stickler) And going the other direction with all singular and plural options would leave us with

has_cleanup_task()
has_cleanup_tasks()
with_cleanup_task()
with_cleanup_tasks()
has_ordered_cleanup_task()
has_ordered_cleanup_tasks()
with_ordered_cleanup_task()
with_ordered_cleanup_tasks()

has_independent_cleanup_task()
has_independent_cleanup_tasks()
with_independent_cleanup_task()
with_independent_cleanup_tasks()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we could go a different way with option (B) by dropping the less explicit form of the ordered variants and just stick with only the plurals of each e.g.

has_ordered_cleanup_tasks()
with_ordered_cleanup_tasks()

has_independent_cleanup_tasks()
with_independent_cleanup_tasks()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, this is a great point. I think i agree with the streamline.

Comment on lines +217 to +227
def exit_stage_left(self) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.exit`."""
return self.exit()

def exit_stage_right(self) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.exit`."""
return self.exit()

def exit_through_vomitorium(self) -> None:
"""Alias for :meth:`~screenpy.actor.Actor.exit`."""
return self.exit()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course these aliases are strictly essential and must be preserved at all costs

Copy link
Member

@langgaibo langgaibo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@perrygoy perrygoy merged commit 7dd81e1 into trunk May 13, 2022
@perrygoy perrygoy deleted the 19/fix-typing-for-aliases branch May 13, 2022 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants