From 3652eb882612ce57a960f235777fe0c4fc4de50a Mon Sep 17 00:00:00 2001 From: yashaka Date: Tue, 13 Feb 2024 11:04:52 +0200 Subject: [PATCH] STYLE: update black & reformat --- .github/workflows/linters.yml | 2 +- .run/lint_pycodestyle.sh | 2 +- poetry.lock | 65 ++++--- pyproject.toml | 2 +- selene/common/predicate.py | 16 +- selene/core/_actions.py | 6 +- selene/core/configuration.py | 220 ++++++++++++----------- selene/core/query.py | 8 +- selene/support/_logging.py | 3 +- tests/integration/error_messages_test.py | 14 +- 10 files changed, 169 insertions(+), 169 deletions(-) diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index ee64afdfb..44d074572 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -44,7 +44,7 @@ jobs: with: python-version: '3.8' - run: | - pip install black + pip install black==24.2.0 .run/lint_black.sh Pycodestyle: diff --git a/.run/lint_pycodestyle.sh b/.run/lint_pycodestyle.sh index 25a22d774..5da1f3f56 100755 --- a/.run/lint_pycodestyle.sh +++ b/.run/lint_pycodestyle.sh @@ -1,3 +1,3 @@ #!/bin/bash -pycodestyle $(pwd) --ignore=E501,W503,E402,E731,E203 --exclude=.venv +pycodestyle $(pwd) --ignore=E501,W503,E402,E731,E203,E704 --exclude=.venv diff --git a/poetry.lock b/poetry.lock index 19d7de564..e9843c826 100644 --- a/poetry.lock +++ b/poetry.lock @@ -64,36 +64,33 @@ pytz = {version = ">=2015.7", markers = "python_version < \"3.9\""} [[package]] name = "black" -version = "23.3.0" +version = "24.2.0" description = "The uncompromising code formatter." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "black-23.3.0-cp310-cp310-macosx_10_16_arm64.whl", hash = "sha256:0945e13506be58bf7db93ee5853243eb368ace1c08a24c65ce108986eac65915"}, - {file = "black-23.3.0-cp310-cp310-macosx_10_16_universal2.whl", hash = "sha256:67de8d0c209eb5b330cce2469503de11bca4085880d62f1628bd9972cc3366b9"}, - {file = "black-23.3.0-cp310-cp310-macosx_10_16_x86_64.whl", hash = "sha256:7c3eb7cea23904399866c55826b31c1f55bbcd3890ce22ff70466b907b6775c2"}, - {file = "black-23.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:32daa9783106c28815d05b724238e30718f34155653d4d6e125dc7daec8e260c"}, - {file = "black-23.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:35d1381d7a22cc5b2be2f72c7dfdae4072a3336060635718cc7e1ede24221d6c"}, - {file = "black-23.3.0-cp311-cp311-macosx_10_16_arm64.whl", hash = "sha256:a8a968125d0a6a404842fa1bf0b349a568634f856aa08ffaff40ae0dfa52e7c6"}, - {file = "black-23.3.0-cp311-cp311-macosx_10_16_universal2.whl", hash = "sha256:c7ab5790333c448903c4b721b59c0d80b11fe5e9803d8703e84dcb8da56fec1b"}, - {file = "black-23.3.0-cp311-cp311-macosx_10_16_x86_64.whl", hash = "sha256:a6f6886c9869d4daae2d1715ce34a19bbc4b95006d20ed785ca00fa03cba312d"}, - {file = "black-23.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6f3c333ea1dd6771b2d3777482429864f8e258899f6ff05826c3a4fcc5ce3f70"}, - {file = "black-23.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:11c410f71b876f961d1de77b9699ad19f939094c3a677323f43d7a29855fe326"}, - {file = "black-23.3.0-cp37-cp37m-macosx_10_16_x86_64.whl", hash = "sha256:1d06691f1eb8de91cd1b322f21e3bfc9efe0c7ca1f0e1eb1db44ea367dff656b"}, - {file = "black-23.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:50cb33cac881766a5cd9913e10ff75b1e8eb71babf4c7104f2e9c52da1fb7de2"}, - {file = "black-23.3.0-cp37-cp37m-win_amd64.whl", hash = "sha256:e114420bf26b90d4b9daa597351337762b63039752bdf72bf361364c1aa05925"}, - {file = "black-23.3.0-cp38-cp38-macosx_10_16_arm64.whl", hash = "sha256:48f9d345675bb7fbc3dd85821b12487e1b9a75242028adad0333ce36ed2a6d27"}, - {file = "black-23.3.0-cp38-cp38-macosx_10_16_universal2.whl", hash = "sha256:714290490c18fb0126baa0fca0a54ee795f7502b44177e1ce7624ba1c00f2331"}, - {file = "black-23.3.0-cp38-cp38-macosx_10_16_x86_64.whl", hash = "sha256:064101748afa12ad2291c2b91c960be28b817c0c7eaa35bec09cc63aa56493c5"}, - {file = "black-23.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:562bd3a70495facf56814293149e51aa1be9931567474993c7942ff7d3533961"}, - {file = "black-23.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:e198cf27888ad6f4ff331ca1c48ffc038848ea9f031a3b40ba36aced7e22f2c8"}, - {file = "black-23.3.0-cp39-cp39-macosx_10_16_arm64.whl", hash = "sha256:3238f2aacf827d18d26db07524e44741233ae09a584273aa059066d644ca7b30"}, - {file = "black-23.3.0-cp39-cp39-macosx_10_16_universal2.whl", hash = "sha256:f0bd2f4a58d6666500542b26354978218a9babcdc972722f4bf90779524515f3"}, - {file = "black-23.3.0-cp39-cp39-macosx_10_16_x86_64.whl", hash = "sha256:92c543f6854c28a3c7f39f4d9b7694f9a6eb9d3c5e2ece488c327b6e7ea9b266"}, - {file = "black-23.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a150542a204124ed00683f0db1f5cf1c2aaaa9cc3495b7a3b5976fb136090ab"}, - {file = "black-23.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:6b39abdfb402002b8a7d030ccc85cf5afff64ee90fa4c5aebc531e3ad0175ddb"}, - {file = "black-23.3.0-py3-none-any.whl", hash = "sha256:ec751418022185b0c1bb7d7736e6933d40bbb14c14a0abcf9123d1b159f98dd4"}, - {file = "black-23.3.0.tar.gz", hash = "sha256:1c7b8d606e728a41ea1ccbd7264677e494e87cf630e399262ced92d4a8dac940"}, + {file = "black-24.2.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6981eae48b3b33399c8757036c7f5d48a535b962a7c2310d19361edeef64ce29"}, + {file = "black-24.2.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d533d5e3259720fdbc1b37444491b024003e012c5173f7d06825a77508085430"}, + {file = "black-24.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61a0391772490ddfb8a693c067df1ef5227257e72b0e4108482b8d41b5aee13f"}, + {file = "black-24.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:992e451b04667116680cb88f63449267c13e1ad134f30087dec8527242e9862a"}, + {file = "black-24.2.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:163baf4ef40e6897a2a9b83890e59141cc8c2a98f2dda5080dc15c00ee1e62cd"}, + {file = "black-24.2.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e37c99f89929af50ffaf912454b3e3b47fd64109659026b678c091a4cd450fb2"}, + {file = "black-24.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4f9de21bafcba9683853f6c96c2d515e364aee631b178eaa5145fc1c61a3cc92"}, + {file = "black-24.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:9db528bccb9e8e20c08e716b3b09c6bdd64da0dd129b11e160bf082d4642ac23"}, + {file = "black-24.2.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:d84f29eb3ee44859052073b7636533ec995bd0f64e2fb43aeceefc70090e752b"}, + {file = "black-24.2.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1e08fb9a15c914b81dd734ddd7fb10513016e5ce7e6704bdd5e1251ceee51ac9"}, + {file = "black-24.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:810d445ae6069ce64030c78ff6127cd9cd178a9ac3361435708b907d8a04c693"}, + {file = "black-24.2.0-cp312-cp312-win_amd64.whl", hash = "sha256:ba15742a13de85e9b8f3239c8f807723991fbfae24bad92d34a2b12e81904982"}, + {file = "black-24.2.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:7e53a8c630f71db01b28cd9602a1ada68c937cbf2c333e6ed041390d6968faf4"}, + {file = "black-24.2.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:93601c2deb321b4bad8f95df408e3fb3943d85012dddb6121336b8e24a0d1218"}, + {file = "black-24.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a0057f800de6acc4407fe75bb147b0c2b5cbb7c3ed110d3e5999cd01184d53b0"}, + {file = "black-24.2.0-cp38-cp38-win_amd64.whl", hash = "sha256:faf2ee02e6612577ba0181f4347bcbcf591eb122f7841ae5ba233d12c39dcb4d"}, + {file = "black-24.2.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:057c3dc602eaa6fdc451069bd027a1b2635028b575a6c3acfd63193ced20d9c8"}, + {file = "black-24.2.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:08654d0797e65f2423f850fc8e16a0ce50925f9337fb4a4a176a7aa4026e63f8"}, + {file = "black-24.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ca610d29415ee1a30a3f30fab7a8f4144e9d34c89a235d81292a1edb2b55f540"}, + {file = "black-24.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:4dd76e9468d5536abd40ffbc7a247f83b2324f0c050556d9c371c2b9a9a95e31"}, + {file = "black-24.2.0-py3-none-any.whl", hash = "sha256:e8a6ae970537e67830776488bca52000eaa37fa63b9988e8c487458d9cd5ace6"}, + {file = "black-24.2.0.tar.gz", hash = "sha256:bce4f25c27c3435e4dace4815bcb2008b87e167e3bf4ee47ccdc5ce906eb4894"}, ] [package.dependencies] @@ -103,11 +100,11 @@ packaging = ">=22.0" pathspec = ">=0.9.0" platformdirs = ">=2" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""} +typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} [package.extras] colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)"] +d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"] jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] uvloop = ["uvloop (>=0.15.2)"] @@ -988,13 +985,13 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pycodestyle" -version = "2.10.0" +version = "2.11.1" description = "Python style guide checker" optional = false -python-versions = ">=3.6" +python-versions = ">=3.8" files = [ - {file = "pycodestyle-2.10.0-py2.py3-none-any.whl", hash = "sha256:8a4eaf0d0495c7395bdab3589ac2db602797d76207242c17d470186815706610"}, - {file = "pycodestyle-2.10.0.tar.gz", hash = "sha256:347187bdb476329d98f695c213d7295a846d1152ff4fe9bacb8a9590b8ee7053"}, + {file = "pycodestyle-2.11.1-py2.py3-none-any.whl", hash = "sha256:44fe31000b2d866f2e41841b18528a505fbd7fef9017b04eff4e2648a0fadc67"}, + {file = "pycodestyle-2.11.1.tar.gz", hash = "sha256:41ba0e7afc9752dfb53ced5489e89f8186be00e599e712660695b7a75ff2663f"}, ] [[package]] @@ -1696,4 +1693,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "d9dc8827e4e9fed7817dcd0744b21d669a0ec38839f8cf001164c953d47c93a7" +content-hash = "c96722b21bd6f6d03ff247efc537c86abbe1755b0acda034050913667b6bb5e7" diff --git a/pyproject.toml b/pyproject.toml index ea9032b3b..357a66520 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,7 +52,7 @@ future = "*" typing-extensions = ">=4.9.0" [tool.poetry.dev-dependencies] -black = "^23.3.0" +black = "^24.2.0" pycodestyle = "*" pylint = "^2.7.2" pytest = "*" diff --git a/selene/common/predicate.py b/selene/common/predicate.py index c932de110..ff25dfa28 100644 --- a/selene/common/predicate.py +++ b/selene/common/predicate.py @@ -32,10 +32,8 @@ def equals_ignoring_case(expected): def equals(expected, ignore_case=False): - return ( - lambda actual: expected == actual - if not ignore_case - else equals_ignoring_case(expected) + return lambda actual: ( + expected == actual if not ignore_case else equals_ignoring_case(expected) ) @@ -78,8 +76,8 @@ def includes_word_ignoring_case(expected): def includes_word(expected, ignore_case=False): - return ( - lambda actual: expected in re.split(r'\s+', actual) + return lambda actual: ( + expected in re.split(r'\s+', actual) if not ignore_case else includes_ignoring_case(expected) ) @@ -87,10 +85,8 @@ def includes_word(expected, ignore_case=False): # will not work with empty seqs :( TODO: fix # currently we use it only for non-empty seqs taking this into account -seq_compare_by = ( - lambda f: lambda x=None, *xs: lambda y=None, *ys: True - if x is None and y is None - else bool(f(x)(y)) and seq_compare_by(f)(*xs)(*ys) # type: ignore +seq_compare_by = lambda f: lambda x=None, *xs: lambda y=None, *ys: ( + True if x is None and y is None else bool(f(x)(y)) and seq_compare_by(f)(*xs)(*ys) # type: ignore ) diff --git a/selene/core/_actions.py b/selene/core/_actions.py index 59e48a2b4..4cb4c3ba6 100644 --- a/selene/core/_actions.py +++ b/selene/core/_actions.py @@ -36,13 +36,11 @@ @overload -def _ensure_located(element: Element | WebElement) -> WebElement: - ... +def _ensure_located(element: Element | WebElement) -> WebElement: ... @overload -def _ensure_located(element: Element | WebElement | None) -> WebElement | None: - ... +def _ensure_located(element: Element | WebElement | None) -> WebElement | None: ... def _ensure_located(element): diff --git a/selene/core/configuration.py b/selene/core/configuration.py index badd7313c..8dadd7bc8 100644 --- a/selene/core/configuration.py +++ b/selene/core/configuration.py @@ -143,18 +143,22 @@ def build_appium_driver(): in ['android', 'ios'] ) ) - else 'remote' - if (config.driver_remote_url or config.driver_name == 'remote') - # TODO: consider automatically detect installed browser if driver_name not set else ( - config.driver_name - if config.driver_name - else config.driver_options.capabilities['browserName'] - if ( - config.driver_options - and 'browserName' in config.driver_options.capabilities + 'remote' + if (config.driver_remote_url or config.driver_name == 'remote') + # TODO: consider automatically detect installed browser if driver_name not set + else ( + config.driver_name + if config.driver_name + else ( + config.driver_options.capabilities['browserName'] + if ( + config.driver_options + and 'browserName' in config.driver_options.capabilities + ) + else 'chrome' + ) ) - else 'chrome' ) )() @@ -633,9 +637,9 @@ class Config: # [Config], Callable[[], WebDriver] # ] # for consistency with some other options... - build_driver_strategy: Callable[ - [Config], WebDriver - ] = _build_local_driver_by_name_or_remote_by_url_and_options + build_driver_strategy: Callable[[Config], WebDriver] = ( + _build_local_driver_by_name_or_remote_by_url_and_options + ) """ A factory to build a driver instance based on this config instance. The driver built with this factory will be available via `config.driver`. @@ -673,14 +677,14 @@ class Config: """ # TODO: since it's curried, shouldn't we rename it driver_teardown_strategy? - _teardown_driver_strategy: Callable[ - [Config], Callable[[WebDriver], None] - ] = lambda config: lambda driver: ( - driver.quit() - if not config.hold_driver_at_exit - and config._is_driver_set_strategy(driver) - and config._is_driver_alive_strategy(driver) - else None + _teardown_driver_strategy: Callable[[Config], Callable[[WebDriver], None]] = ( + lambda config: lambda driver: ( + driver.quit() + if not config.hold_driver_at_exit + and config._is_driver_set_strategy(driver) + and config._is_driver_alive_strategy(driver) + else None + ) ) """ Defines how driver will be teardown. @@ -1230,46 +1234,46 @@ def _executor(self): # TODO: is a _strategy suffix a good naming convention in this context? # maybe yes, because we yet accept config in it... # so we expect it to be a Strategy of some bigger Context - _save_screenshot_strategy: Callable[ - [Config, Optional[str]], Any - ] = lambda config, path=None: fp.thread( - path, - lambda path: ( - config._generate_filename(suffix='.png') if path is None else path - ), - lambda path: ( - os.path.join(path, f'{next(config._counter)}.png') - if path and not path.lower().endswith('.png') - else path - ), - fp.do( - fp.pipe( - os.path.dirname, - lambda folder: ( - os.makedirs(folder) - if folder and not os.path.exists(folder) - else ... - ), - ) - ), - fp.do( + _save_screenshot_strategy: Callable[[Config, Optional[str]], Any] = ( + lambda config, path=None: fp.thread( + path, lambda path: ( - warnings.warn( - 'name used for saved screenshot does not match file ' - 'type. It should end with an `.png` extension', - UserWarning, + config._generate_filename(suffix='.png') if path is None else path + ), + lambda path: ( + os.path.join(path, f'{next(config._counter)}.png') + if path and not path.lower().endswith('.png') + else path + ), + fp.do( + fp.pipe( + os.path.dirname, + lambda folder: ( + os.makedirs(folder) + if folder and not os.path.exists(folder) + else ... + ), ) - if not path.lower().endswith('.png') - else ... - ) - ), - lambda path: (path if config.driver.get_screenshot_as_file(path) else None), - fp.do( - lambda path: setattr(config, 'last_screenshot', path) - ), # On refactor>rename, we may miss it here :( better would be like: - # setattr(config, config.__class__.last_screenshot.name, path) - # but currently .name will return '__boxed_last_screenshot' :( - # think on how we can resolve this... + ), + fp.do( + lambda path: ( + warnings.warn( + 'name used for saved screenshot does not match file ' + 'type. It should end with an `.png` extension', + UserWarning, + ) + if not path.lower().endswith('.png') + else ... + ) + ), + lambda path: (path if config.driver.get_screenshot_as_file(path) else None), + fp.do( + lambda path: setattr(config, 'last_screenshot', path) + ), # On refactor>rename, we may miss it here :( better would be like: + # setattr(config, config.__class__.last_screenshot.name, path) + # but currently .name will return '__boxed_last_screenshot' :( + # think on how we can resolve this... + ) ) """ Defines a strategy for saving a screenshot. @@ -1278,48 +1282,48 @@ def _executor(self): and stores the path to `config.last_screenshot`. """ - _save_page_source_strategy: Callable[ - [Config, Optional[str]], Any - ] = lambda config, path=None: fp.thread( - path, - lambda path: ( - config._generate_filename(suffix='.html') if path is None else path - ), - lambda path: ( - os.path.join(path, f'{next(config._counter)}.html') - if path and not path.lower().endswith('.html') - else path - ), - fp.do( - fp.pipe( - os.path.dirname, - lambda folder: ( - os.makedirs(folder) - if folder and not os.path.exists(folder) - else ... - ), - ) - ), - fp.do( + _save_page_source_strategy: Callable[[Config, Optional[str]], Any] = ( + lambda config, path=None: fp.thread( + path, lambda path: ( - warnings.warn( - 'name used for saved page source does not match file ' - 'type. It should end with an `.html` extension', - UserWarning, + config._generate_filename(suffix='.html') if path is None else path + ), + lambda path: ( + os.path.join(path, f'{next(config._counter)}.html') + if path and not path.lower().endswith('.html') + else path + ), + fp.do( + fp.pipe( + os.path.dirname, + lambda folder: ( + os.makedirs(folder) + if folder and not os.path.exists(folder) + else ... + ), ) - if not path.lower().endswith('.html') - else ... - ) - ), - lambda path: (path, config.driver.page_source), - fp.do(lambda path_and_source: fp.write_silently(*path_and_source)), - lambda path_and_source: path_and_source[0], - fp.do( - lambda path: setattr(config, 'last_page_source', path) - ), # On refactor>rename, we may miss it here :( better would be like: - # setattr(config, config.__class__.last_screenshot.name, path) - # but currently .name will return '__boxed_last_screenshot' :( - # think on how we can resolve this... + ), + fp.do( + lambda path: ( + warnings.warn( + 'name used for saved page source does not match file ' + 'type. It should end with an `.html` extension', + UserWarning, + ) + if not path.lower().endswith('.html') + else ... + ) + ), + lambda path: (path, config.driver.page_source), + fp.do(lambda path_and_source: fp.write_silently(*path_and_source)), + lambda path_and_source: path_and_source[0], + fp.do( + lambda path: setattr(config, 'last_page_source', path) + ), # On refactor>rename, we may miss it here :( better would be like: + # setattr(config, config.__class__.last_screenshot.name, path) + # but currently .name will return '__boxed_last_screenshot' :( + # think on how we can resolve this... + ) ) """ Defines a strategy for saving a page source on failure. @@ -1432,15 +1436,15 @@ def save_and_log_page_source(error: TimeoutException) -> Exception: # TODO: maybe here wait_factory would be better name? # yes, it's also a strategy, but completely not connected with other # driver lifecycle strategies - _build_wait_strategy: Callable[ - [Config], Callable[[E], Wait[E]] - ] = lambda config: lambda entity: Wait( - entity, - at_most=config.timeout, - or_fail_with=config._inject_screenshot_and_page_source_pre_hooks( - config.hook_wait_failure - ), - _decorator=config._wait_decorator, + _build_wait_strategy: Callable[[Config], Callable[[E], Wait[E]]] = ( + lambda config: lambda entity: Wait( + entity, + at_most=config.timeout, + or_fail_with=config._inject_screenshot_and_page_source_pre_hooks( + config.hook_wait_failure + ), + _decorator=config._wait_decorator, + ) ) """ A strategy for building a Wait object based on other config options diff --git a/selene/core/query.py b/selene/core/query.py index b333b5179..bd7ed35c5 100644 --- a/selene/core/query.py +++ b/selene/core/query.py @@ -69,9 +69,11 @@ def fn(element: Element) -> str: lambda entity: ( entity().size if isinstance(entity, Element) - else len(entity()) - if isinstance(entity, Collection) - else typing.cast(Browser, entity).driver.get_window_size() + else ( + len(entity()) + if isinstance(entity, Collection) + else typing.cast(Browser, entity).driver.get_window_size() + ) ), ) diff --git a/selene/support/_logging.py b/selene/support/_logging.py index f5dbd4718..e9481ed6a 100644 --- a/selene/support/_logging.py +++ b/selene/support/_logging.py @@ -8,8 +8,7 @@ class _ContextManagerFactory(Protocol): def __call__( self, *, title: str, params: Dict[str, Any], **kwargs - ) -> ContextManager: - ... + ) -> ContextManager: ... class _default_translations: diff --git a/tests/integration/error_messages_test.py b/tests/integration/error_messages_test.py index 750d64ee0..988e3f7c9 100644 --- a/tests/integration/error_messages_test.py +++ b/tests/integration/error_messages_test.py @@ -42,11 +42,15 @@ def exception_message(ex): msg_simplified = and_simplified_stacktrace return [ - 'Screenshot: *.png' - if re.search(r'Screenshot: file:///.*\.png', line) - else 'PageSource: *.html' - if re.search(r'PageSource: file:///.*\.html', line) - else line.strip() + ( + 'Screenshot: *.png' + if re.search(r'Screenshot: file:///.*\.png', line) + else ( + 'PageSource: *.html' + if re.search(r'PageSource: file:///.*\.html', line) + else line.strip() + ) + ) for line in msg_simplified.strip().splitlines() ]