Skip to content

Commit

Permalink
REFACTOR: for mypy compliance + ...
Browse files Browse the repository at this point in the history
... tune some todos...
  • Loading branch information
yashaka committed Jul 17, 2024
1 parent 1f26eb2 commit 9c724b0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Then we have to consider rething condition.__call__ aliases... And corresponding

`Test` might be also a good candidate over `Match` ... But `Test` does not correlate in `entity.should(Test(actual=..., by=...))

### TODO: Ensure type errors on element.should(collection_condition), etc.
### TODO: Ensure no type errors on element.should(collection_condition), etc.

check vscode pylance, mypy, jetbrains qodana...

Expand Down
7 changes: 4 additions & 3 deletions selene/core/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,20 +833,21 @@ def __init__(
# where three are (prefix, core, suffix),
# where each can be substituted with ... (Ellipsis)
# signifying that the "default" should be used
# TODO: should we make the name type as Callable[[Condition], str]
# todo: should we make the name type as Callable[[Condition], str]
# instead of Callable[[], str]...
# to be able to pass condition itself...
# when we pass in child classes we pass self.__str__
# that doesn't need to receive self, it already has it
# but what if we want to pass some crazy lambda for name from outside
# to kind of providing a "name self-based strategy" for condition?
# maybe at least we can define it as varagrs? like Callable[..., str]
# TODO: consider accepting actual and by as Tuples
# – we don't need it anymore, case we made it based on entity ;)
# todo: consider accepting actual and by as Tuples
# where first is name for query and second is query fn
def __init__(
self,
name: str | Callable[[E | None], str], # TODO: consider Callable[[...], str]
/,
/, # TODO: what if we move it after test? :) and not bother about naming:)
test: Lambda[E, None] | None = None,
*,
actual: Lambda[E, R] | None = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
from typing import Optional
from __future__ import annotations
from typing_extensions import Optional, cast

from selenium.webdriver.remote.webdriver import WebDriver

Expand All @@ -32,8 +33,8 @@


class Settings:
driver: Optional[WebDriver] = None
reset_driver: bool = False
driver: Optional[WebDriver] = None


@pytest.fixture(scope='module')
Expand Down Expand Up @@ -70,7 +71,7 @@ def create_chrome():
):
Settings.driver = create_chrome()

return Settings.driver
return cast(WebDriver, Settings.driver)

browser = Browser(Config(driver=customly_managed_driver))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from future.utils import iteritems

from selene import browser, be, have, Element


Expand Down Expand Up @@ -78,7 +75,7 @@ def fill_with(self, opts=None, *other_opts, **opts_as_kwargs):
opts = {} if not opts else opts
list_of_opts = [merge(opts, opts_as_kwargs)] + list(other_opts)
for options in list_of_opts:
for field, value in iteritems(options):
for field, value in options.items():
getattr(self._element, field).set_value(value)
return self

Expand Down

0 comments on commit 9c724b0

Please sign in to comment.