Skip to content

Commit

Permalink
[py] Fix Flake8 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomatedTester committed Mar 10, 2020
1 parent a6cd46e commit 53761e3
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion py/selenium/webdriver/common/actions/action_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_device_with(self, name):
try:
idx = self.devices.index(name)
return self.devices[idx]
except:
except Exception:
pass

@property
Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/common/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def service_url(self):
return "http://%s" % utils.join_host_port('localhost', self.port)

def command_line_args(self):
raise NotImplemented("This method needs to be implemented in a sub class")
raise NotImplementedError("This method needs to be implemented in a sub class")

def start(self):
"""
Expand Down
11 changes: 6 additions & 5 deletions py/selenium/webdriver/common/timeouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@
# specific language governing permissions and limitations
# under the License.


class Timeouts(object):

def __init__(self, implicit_wait=None, page_load=None, script=None):
"""
Create a new Timeout object.
:Args:
- implicit_wait - Either an int or a float. The number passed in needs to how many
- implicit_wait - Either an int or a float. The number passed in needs to how many
seconds the driver will wait.
- page_load - Either an int or a float. The number passed in needs to how many
- page_load - Either an int or a float. The number passed in needs to how many
seconds the driver will wait.
- script - Either an int or a float. The number passed in needs to how many
- script - Either an int or a float. The number passed in needs to how many
seconds the driver will wait.
"""
self._implicit_wait = self._convert(implicit_wait)
Expand Down Expand Up @@ -90,5 +91,5 @@ def _to_json(self):
timeouts["pageLoad"] = self._page_load
if self._script is not None:
timeouts["script"] = self._script

return timeouts
2 changes: 1 addition & 1 deletion py/selenium/webdriver/firefox/firefox_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def _get_firefox_start_cmd(self):
else:
# couldn't find firefox on the system path
raise RuntimeError(
"Could not find firefox in your system PATH." +
"Could not find firefox in your system PATH."
" Please specify the firefox binary location or install firefox")
return start_cmd

Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/firefox/firefox_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def _read_existing_userjs(self, userjs):
try:
self.default_preferences[matches.group(1)] = json.loads(matches.group(2))
except Exception:
warnings.warn("(skipping) failed to json.loads existing preference: " +
warnings.warn("(skipping) failed to json.loads existing preference: %s" %
matches.group(1) + matches.group(2))
except Exception:
# The profile given hasn't had any changes made, i.e no users.js
Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/remote/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ def timeouts(self):
@timeouts.setter
def timeouts(self, timeouts):
"""
Set all timeouts for the session. This will override any previously
Set all timeouts for the session. This will override any previously
set timeouts.
:Usage:
Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/remote/webelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ def find_element(self, by=By.ID, value=None):
if by == By.ID:
by = By.CSS_SELECTOR
value = '[id="%s"]' % value
elif by == By.TAG_NAME:
elif by == By.TAG_NAME:
by = By.CSS_SELECTOR
elif by == By.CLASS_NAME:
by = By.CSS_SELECTOR
Expand Down
6 changes: 3 additions & 3 deletions py/selenium/webdriver/support/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ def groups(self):
def _from_hsl(h, s, l, a=1):
h = float(h) / 360
s = float(s) / 100
l = float(l) / 100
_l = float(l) / 100

if s == 0:
r = l
r = _l
g = r
b = r
else:
luminocity2 = l * (1 + s) if l < 0.5 else l + s - l * s
luminocity2 = _l * (1 + s) if _l < 0.5 else _l + s - _l * s
luminocity1 = 2 * l - luminocity2

def hue_to_rgb(lum1, lum2, hue):
Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/support/expected_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def __call__(self, driver):
else:
return False
except StaleElementReferenceException:
return False
return False


class frame_to_be_available_and_switch_to_it(object):
Expand Down
23 changes: 11 additions & 12 deletions py/selenium/webdriver/support/relative_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# specific language governing permissions and limitations
# under the License.

import json
import pkgutil

from selenium.common.exceptions import WebDriverException

Expand All @@ -26,27 +24,28 @@ def with_tag_name(tag_name):
raise WebDriverException("tag_name can not be null")
return RelativeBy({"css selector": tag_name})


class RelativeBy(object):

def __init__(self, root = None, filters = []):
def __init__(self, root=None, filters=[]):
self.root = root
self.filters = filters

def above(self, element_or_locator = None):
def above(self, element_or_locator=None):
if element_or_locator is None:
raise WebDriverException("Element or locator must be given when calling above method")

self.filters.append({"kind": "above", "args": [element_or_locator]})
return self

def below(self, element_or_locator = None):
def below(self, element_or_locator=None):
if element_or_locator is None:
raise WebDriverException("Element or locator must be given when calling above method")

self.filters.append({"kind": "below", "args": [element_or_locator]})
return self

def to_left_of(self, element_or_locator = None):
def to_left_of(self, element_or_locator=None):
if element_or_locator is None:
raise WebDriverException("Element or locator must be given when calling above method")

Expand All @@ -60,17 +59,17 @@ def to_right_of(self, element_or_locator):
self.filters.append({"kind": "right", "args": [element_or_locator]})
return self

def near(self, element_or_locator_distance = None):
if element_or_locator is None:
def near(self, element_or_locator_distance=None):
if element_or_locator_distance is None:
raise WebDriverException("Element or locator or distance must be given when calling above method")

self.filters.append({"kind": "near", "args": [element_or_locator]})
self.filters.append({"kind": "near", "args": [element_or_locator_distance]})
return self

def to_dict(self):
return {
'relative': {
'root': self.root,
'filters': self.filters
}
'filters': self.filters,
}
}

0 comments on commit 53761e3

Please sign in to comment.