From b0a6013e5f68ae3a122b56b2c4c974754dedd218 Mon Sep 17 00:00:00 2001 From: Marcel Wilson Date: Wed, 7 Feb 2024 15:38:02 -0600 Subject: [PATCH] proof of concept that Self works in 3.8+ --- screenpy_selenium/actions/open.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/screenpy_selenium/actions/open.py b/screenpy_selenium/actions/open.py index 5980d0b..8f0d017 100644 --- a/screenpy_selenium/actions/open.py +++ b/screenpy_selenium/actions/open.py @@ -3,17 +3,16 @@ from __future__ import annotations import os -from typing import TYPE_CHECKING, TypeVar +from typing import TYPE_CHECKING from screenpy.pacing import beat +from typing_extensions import Self from ..abilities import BrowseTheWeb if TYPE_CHECKING: from screenpy import Actor -SelfOpen = TypeVar("SelfOpen", bound="Open") - class Open: """Go to a specific URL! @@ -42,7 +41,7 @@ class Open: """ @classmethod - def their_browser_on(cls: type[SelfOpen], location: str | object) -> SelfOpen: + def their_browser_on(cls, location: str | object) -> Self: """ Provide a URL to visit. @@ -52,21 +51,21 @@ def their_browser_on(cls: type[SelfOpen], location: str | object) -> SelfOpen: return cls(location=location) @classmethod - def browser_on(cls: type[SelfOpen], location: str | object) -> SelfOpen: + def browser_on(cls, location: str | object) -> Self: """Alias for :meth:`~screenpy_selenium.actions.Open.their_browser_on`.""" return cls.their_browser_on(location=location) - def describe(self: SelfOpen) -> str: + def describe(self) -> str: """Describe the Action in present tense.""" return f"Visit {self.url}." @beat("{} visits {url}") - def perform_as(self: SelfOpen, the_actor: Actor) -> None: + def perform_as(self, the_actor: Actor) -> None: """Direct the Actor to visit the specified URL.""" browser = the_actor.ability_to(BrowseTheWeb).browser browser.get(self.url) - def __init__(self: SelfOpen, location: str | object) -> None: + def __init__(self, location: str | object) -> None: url = getattr(location, "url", location) url = f'{os.getenv("BASE_URL", "")}{url}' self.url = url