Skip to content

Commit

Permalink
Fix formatting after linter updates
Browse files Browse the repository at this point in the history
  • Loading branch information
fsouza committed Nov 10, 2023
1 parent 782b53d commit efbd56c
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 73 deletions.
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ def get_version_data() -> dict:
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
]
+ [
("Programming Language :: Python :: %s" % x)
for x in "3.8 3.9 3.10 3.11 3.12".split()
],
+ [("Programming Language :: Python :: %s" % x) for x in "3.8 3.9 3.10 3.11 3.12".split()],
project_urls={
"Documentation": "https://splinter.readthedocs.io/",
"Changelog": "https://github.com/cobrateam/splinter/tree/master/docs/news",
Expand Down
48 changes: 16 additions & 32 deletions splinter/driver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ def is_text_present(self, text: str, wait_time: Optional[int] = None) -> bool:
bool: True if finds a match for the ``text`` and False if not.
"""
raise NotImplementedError(
"%s doesn't support checking if some text is present in the html. "
% self.driver_name,
"%s doesn't support checking if some text is present in the html. " % self.driver_name,
)

def type(self, name: str, value: str, slowly: bool = False) -> str: # NOQA: A003
Expand Down Expand Up @@ -385,8 +384,7 @@ def select(self, name: str, value: str) -> None:
>>> browser.select("state", "NY")
"""
raise NotImplementedError(
"%s doesn't support selecting options in 'select' element."
% self.driver_name,
"%s doesn't support selecting options in 'select' element." % self.driver_name,
)

def quit(self) -> None: # NOQA: A003
Expand All @@ -408,8 +406,7 @@ def is_element_present_by_css(
bool: True if the element is present and False if is not present.
"""
raise NotImplementedError(
"%s doesn't support verifying if element is present by css"
% self.driver_name,
"%s doesn't support verifying if element is present by css" % self.driver_name,
)

def is_element_not_present_by_css(
Expand All @@ -427,8 +424,7 @@ def is_element_not_present_by_css(
bool: True if the element is not present and False if is present.
"""
raise NotImplementedError(
"%s doesn't support verifying if element is not present by css"
% self.driver_name,
"%s doesn't support verifying if element is not present by css" % self.driver_name,
)

def is_element_present_by_xpath(
Expand All @@ -446,8 +442,7 @@ def is_element_present_by_xpath(
bool: True if the element is present and False if is not present.
"""
raise NotImplementedError(
"%s doesn't support verifying if element is present by xpath"
% self.driver_name,
"%s doesn't support verifying if element is present by xpath" % self.driver_name,
)

def is_element_not_present_by_xpath(
Expand All @@ -465,8 +460,7 @@ def is_element_not_present_by_xpath(
bool: True if the element is not present and False if is present.
"""
raise NotImplementedError(
"%s doesn't support verifying if element is not present by xpath"
% self.driver_name,
"%s doesn't support verifying if element is not present by xpath" % self.driver_name,
)

def is_element_present_by_tag(
Expand All @@ -484,8 +478,7 @@ def is_element_present_by_tag(
bool: True if the element is present and False if is not present.
"""
raise NotImplementedError(
"%s doesn't support verifying if element is present by tag"
% self.driver_name,
"%s doesn't support verifying if element is present by tag" % self.driver_name,
)

def is_element_not_present_by_tag(
Expand All @@ -503,8 +496,7 @@ def is_element_not_present_by_tag(
bool: True if the element is not present and False if is present.
"""
raise NotImplementedError(
"%s doesn't support verifying if element is not present by tag"
% self.driver_name,
"%s doesn't support verifying if element is not present by tag" % self.driver_name,
)

def is_element_present_by_name(
Expand All @@ -522,8 +514,7 @@ def is_element_present_by_name(
bool: True if the element is present and False if is not present.
"""
raise NotImplementedError(
"%s doesn't support verifying if element is present by name"
% self.driver_name,
"%s doesn't support verifying if element is present by name" % self.driver_name,
)

def is_element_not_present_by_name(
Expand All @@ -541,8 +532,7 @@ def is_element_not_present_by_name(
bool: True if the element is not present and False if is present.
"""
raise NotImplementedError(
"%s doesn't support verifying if element is not present by name"
% self.driver_name,
"%s doesn't support verifying if element is not present by name" % self.driver_name,
)

def is_element_present_by_value(
Expand All @@ -560,8 +550,7 @@ def is_element_present_by_value(
bool: True if the element is present and False if is not present.
"""
raise NotImplementedError(
"%s doesn't support verifying if element is present by value"
% self.driver_name,
"%s doesn't support verifying if element is present by value" % self.driver_name,
)

def is_element_not_present_by_value(
Expand All @@ -579,8 +568,7 @@ def is_element_not_present_by_value(
bool: True if the element is not present and False if is present.
"""
raise NotImplementedError(
"%s doesn't support verifying if element is not present by value"
% self.driver_name,
"%s doesn't support verifying if element is not present by value" % self.driver_name,
)

def is_element_present_by_text(
Expand All @@ -598,8 +586,7 @@ def is_element_present_by_text(
bool: True if the element is present and False if is not present.
"""
raise NotImplementedError(
"%s doesn't support verifying if element is present by text"
% self.driver_name,
"%s doesn't support verifying if element is present by text" % self.driver_name,
)

def is_element_not_present_by_text(
Expand All @@ -617,8 +604,7 @@ def is_element_not_present_by_text(
bool: True if the element is not present and False if is present.
"""
raise NotImplementedError(
"%s doesn't support verifying if element is not present by text"
% self.driver_name,
"%s doesn't support verifying if element is not present by text" % self.driver_name,
)

def is_element_present_by_id(
Expand All @@ -636,8 +622,7 @@ def is_element_present_by_id(
bool: True if the element is present and False if is not present.
"""
raise NotImplementedError(
"%s doesn't support verifying if element is present by id"
% self.driver_name,
"%s doesn't support verifying if element is present by id" % self.driver_name,
)

def is_element_not_present_by_id(
Expand All @@ -655,8 +640,7 @@ def is_element_not_present_by_id(
bool: True if the element is not present and False if is present.
"""
raise NotImplementedError(
"%s doesn't support verifying if element is not present by id"
% self.driver_name,
"%s doesn't support verifying if element is not present by id" % self.driver_name,
)

def screenshot(
Expand Down
4 changes: 1 addition & 3 deletions splinter/driver/djangoclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ def __contains__(self, key):

def __eq__(self, other_object):
if isinstance(other_object, dict):
cookies_dict = {
key: morsel.value for key, morsel in self.driver.cookies.items()
}
cookies_dict = {key: morsel.value for key, morsel in self.driver.cookies.items()}
return cookies_dict == other_object
return False

Expand Down
4 changes: 1 addition & 3 deletions splinter/driver/lxmldriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ def back(self):
)

def forward(self):
if (self._last_url_index >= 0) and (
self._last_url_index < len(self._last_urls) - 1
):
if (self._last_url_index >= 0) and (self._last_url_index < len(self._last_urls) - 1):
self._last_url_index += 1
self._do_method(
"get",
Expand Down
14 changes: 3 additions & 11 deletions splinter/driver/webdriver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,7 @@ def fset(self, value):

def __repr__(self):
return str(
[
Window(self._browser, handle)
for handle in self._browser.driver.window_handles
],
[Window(self._browser, handle) for handle in self._browser.driver.window_handles],
)


Expand Down Expand Up @@ -237,9 +234,7 @@ def _find(self, finder, finder_kwargs=None):
pass

if elements:
elem_list = [
self.element_class(element, self, finder_kwargs) for element in elements
]
elem_list = [self.element_class(element, self, finder_kwargs) for element in elements]

return elem_list

Expand Down Expand Up @@ -552,10 +547,7 @@ def fill_form(self, field_values, form_id=None, name=None, ignore_missing=False)
else:
elements = self.find_by_name(name)
element = elements.first
if (
element["type"] in ["text", "password", "tel"]
or element.tag_name == "textarea"
):
if element["type"] in ["text", "password", "tel"] or element.tag_name == "textarea":
element.value = value
elif element["type"] == "checkbox":
if value:
Expand Down
4 changes: 1 addition & 3 deletions splinter/driver/zopetestbrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,7 @@ def fill_form(self, field_values, form_id=None, name=None, ignore_missing=False)
else:
control.value = []
elif control.type == "radio":
control.value = [
option for option in control.options if option == value
]
control.value = [option for option in control.options if option == value]
elif control.type == "select":
control.value = [value]
else:
Expand Down
4 changes: 1 addition & 3 deletions splinter/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ def __new__(
dict: dict,
) -> type: # NOQA: N804, A002
"""Metaclass that forces inheritance of docstrings."""
items_to_patch = [
(k, v) for k, v in dict.items() if not k.startswith("__") and not v.__doc__
]
items_to_patch = [(k, v) for k, v in dict.items() if not k.startswith("__") and not v.__doc__]
for name, obj in items_to_patch:
doc = None
for base in bases:
Expand Down
8 changes: 2 additions & 6 deletions tests/element_does_not_exist.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ def test_element_list_contains_right_information_and_raises_right_exception(self
self.assertEqual(".element-that-dont-exists", element_list.query)
element_list.first

expected_message = (
'no elements could be found with css ".element-that-dont-exists"'
)
expected_message = 'no elements could be found with css ".element-that-dont-exists"'

e = cm.exception
self.assertEqual(expected_message, e.args[0])
Expand All @@ -48,9 +46,7 @@ def test_element_list_raises_when_element_first_doesnt_exists_in_element_context
self.assertEqual(".inner-element-that-dont-exists", element_list.query)
element_list.first

expected_message = (
'no elements could be found with css ".inner-element-that-dont-exists"'
)
expected_message = 'no elements could be found with css ".inner-element-that-dont-exists"'

e = cm.exception
self.assertEqual(expected_message, e.args[0])
3 changes: 1 addition & 2 deletions tests/fake_webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ def check_auth(username, password):
def authenticate():
"""Sends a 401 response that enables basic auth"""
return Response(
"Could not verify your access level for that URL.\n"
"You have to login with proper credentials",
"Could not verify your access level for that URL.\n" "You have to login with proper credentials",
401,
{"WWW-Authenticate": 'Basic realm="Login Required"'},
)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_djangoclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ def test_links_with_nested_tags_xpath(self):
self.assertEqual(
len(links),
1,
'Found not exactly one link with a span with text "BAR ONE". %s'
% [item.outer_html for item in links],
'Found not exactly one link with a span with text "BAR ONE". %s' % [item.outer_html for item in links],
)

def test_finding_all_links_by_non_ascii_text(self):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_flaskclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ def test_links_with_nested_tags_xpath(self):
self.assertEqual(
len(links),
1,
'Found not exactly one link with a span with text "BAR ONE". %s'
% [item.outer_html for item in links],
'Found not exactly one link with a span with text "BAR ONE". %s' % [item.outer_html for item in links],
)

def test_finding_all_links_by_non_ascii_text(self):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_zopetestbrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ def test_links_with_nested_tags_xpath(self):
self.assertEqual(
len(links),
1,
'Found not exactly one link with a span with text "BAR ONE". %s'
% [item.outer_html for item in links],
'Found not exactly one link with a span with text "BAR ONE". %s' % [item.outer_html for item in links],
)

def test_finding_all_links_by_non_ascii_text(self):
Expand Down

0 comments on commit efbd56c

Please sign in to comment.