Skip to content

Commit 3ee2be9

Browse files
committed
Restor importing style
1 parent a104b75 commit 3ee2be9

3 files changed

Lines changed: 38 additions & 15 deletions

File tree

src/widgetastic/browser.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@
2121
import inspect
2222
from logging import Logger
2323
from textwrap import dedent
24-
from typing import Any, cast, Dict, List, NamedTuple, Optional, Set, Type, TYPE_CHECKING, Union
24+
from typing import Any
25+
from typing import cast
26+
from typing import Dict
27+
from typing import List
28+
from typing import NamedTuple
29+
from typing import Optional
30+
from typing import Set
31+
from typing import Type
32+
from typing import TYPE_CHECKING
33+
from typing import Union
2534
import warnings
2635

2736
from cached_property import cached_property
@@ -33,14 +42,16 @@
3342
from .locator import SmartLocator
3443
from wait_for import TimedOutError
3544

36-
from .exceptions import (
37-
LocatorNotImplemented,
38-
NoSuchElementException,
39-
WidgetOperationFailed,
40-
)
45+
from .exceptions import LocatorNotImplemented
46+
from .exceptions import NoSuchElementException
47+
from .exceptions import WidgetOperationFailed
4148

42-
from .log import create_widget_logger, null_logger
43-
from .types import ElementParent, LocatorAlias, LocatorProtocol
49+
50+
from .log import create_widget_logger
51+
from .log import null_logger
52+
from .types import ElementParent
53+
from .types import LocatorAlias
54+
from .types import LocatorProtocol
4455
from .xpath import normalize_space
4556

4657

src/widgetastic/locator.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ def __locator__(self):
6363

6464
import re
6565
from collections import namedtuple
66-
from typing import Any, Optional, Tuple, TYPE_CHECKING
66+
from typing import Any
67+
from typing import Optional
68+
from typing import Tuple
69+
from typing import TYPE_CHECKING
6770

6871
if TYPE_CHECKING:
6972
from typing import Type

src/widgetastic/widget/base.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,6 @@ def __init__(self, parent, arg1, arg2, logger=None):
307307

308308
#: Default value for parent_descriptor
309309
parent_descriptor = None
310-
#: Set of HTML tags for elements that can have a 'disabled' state.
311-
DISABLEABLE_TAGS = {"button", "input", "select", "textarea", "option", "optgroup", "fieldset"}
312310

313311
# Helper methods
314312
@staticmethod
@@ -509,6 +507,8 @@ def parent_view(self):
509507
def is_displayed(self):
510508
"""Check whether the widget is displayed.
511509
510+
If the logic behind is_displayed is more complex, you can always override this.
511+
512512
Returns:
513513
:py:class:`bool`
514514
"""
@@ -529,13 +529,22 @@ def is_enabled(self):
529529
Returns:
530530
:py:class:`bool`
531531
"""
532+
#: Set of HTML tags for elements that can have a 'disabled' state.
533+
DISABLEABLE_TAGS = {
534+
"button",
535+
"input",
536+
"select",
537+
"textarea",
538+
"option",
539+
"optgroup",
540+
"fieldset",
541+
}
542+
532543
tag = self.browser.tag(self)
533-
if tag in self.DISABLEABLE_TAGS:
544+
if tag in DISABLEABLE_TAGS:
534545
return self.browser.is_enabled(self)
535546
else:
536-
self.logger.warning(
537-
f"`is_enabled` only applicable for these tags: {self.DISABLEABLE_TAGS}"
538-
)
547+
self.logger.warning(f"`is_enabled` only applicable for these tags: {DISABLEABLE_TAGS}")
539548
return True
540549

541550
@logged()

0 commit comments

Comments
 (0)