Skip to content

Commit b147269

Browse files
[py] Fix Flake 8 Errors
1 parent a42e53c commit b147269

File tree

8 files changed

+24
-6
lines changed

8 files changed

+24
-6
lines changed

py/generate.py

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
# This is a copy of https://github.com/HyperionGray/python-chrome-devtools-protocol/blob/master/generator/generate.py
2424
# The license above is theirs and MUST be preserved.
2525

26+
# flake8: noqa
27+
2628
import builtins
2729
from dataclasses import dataclass
2830
from enum import Enum

py/selenium/webdriver/firefox/options.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def headless(self, value):
132132
Args:
133133
value: boolean value indicating to set the headless option
134134
"""
135-
if value: # is True or == True can be written as bool(variablename), so
135+
if value:
136136
self._arguments.append('-headless')
137137
elif '-headless' in self._arguments:
138138
self._arguments.remove('-headless')

py/selenium/webdriver/firefox/service.py

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def __init__(self, executable_path, port=0, service_args=None,
4141
in the services' environment.
4242
4343
"""
44-
#the condition will fail on both "" and on None, so no need of `log_path is not None and log_path != ""`
4544
log_file = open(log_path, "a+") if log_path else None
4645

4746
service.Service.__init__(

py/selenium/webdriver/remote/errorhandler.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class ErrorHandler(object):
9999
"""
100100
Handles errors returned by the WebDriver server.
101101
"""
102+
102103
def check_response(self, response):
103104
"""
104105
Checks that a JSON response from the WebDriver does not have an error.
@@ -198,7 +199,7 @@ def check_response(self, response):
198199
exception_class = UnknownMethodException
199200
else:
200201
exception_class = WebDriverException
201-
if not value: #if value == '' or value == None, the condition will be executed
202+
if not value:
202203
value = response['value']
203204
if isinstance(value, basestring):
204205
raise exception_class(value)

py/selenium/webdriver/support/expected_conditions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def url_matches(pattern):
8080
pattern is the expected pattern, which must be an exact match
8181
returns True if the url matches, false otherwise."""
8282
def _predicate(driver):
83-
return bool(re.search(pattern, driver.current_url)) #note bool is necessary
83+
return bool(re.search(pattern, driver.current_url))
8484

8585
return _predicate
8686

py/selenium/webdriver/webkitgtk/service.py

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def __init__(self, executable_path, port=0, log_path=None):
3232
- port : Port the service is running on
3333
- log_path : Path for the WebKitGTKDriver service to log to
3434
"""
35-
#the condition will fail on both "" and on None, so no need of `log_path is not None and log_path != ""`
3635
log_file = open(log_path, "wb") if log_path else None
3736
service.Service.__init__(self, executable_path, port, log_file)
3837

py/selenium/webdriver/wpewebkit/service.py

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def __init__(self, executable_path, port=0, log_path=None):
3232
- port : Port the service is running on
3333
- log_path : Path for the WPEWebKitDriver service to log to
3434
"""
35-
#the condition will fail on both "" and on None, so no need of `log_path is not None and log_path != ""`
3635
log_file = open(log_path, "wb") if log_path else None
3736
service.Service.__init__(self, executable_path, port, log_file)
3837

py/test/unit/selenium/webdriver/common/print_page_options_tests.py

+18
Original file line numberDiff line numberDiff line change
@@ -19,73 +19,91 @@
1919

2020
from selenium.webdriver.common.print_page_options import PrintOptions
2121

22+
2223
@pytest.fixture
2324
def print_options():
2425
return PrintOptions()
2526

27+
2628
def test_set_orientation(print_options):
2729
print_options.orientation = 'portrait'
2830
assert print_options.orientation == 'portrait'
2931

32+
3033
def test_raises_exception_if_orientation_is_invalid(print_options):
3134
with pytest.raises(ValueError):
3235
print_options.orientation = 'foobar'
3336

37+
3438
def test_set_scale(print_options):
3539
print_options.scale = 1
3640
assert print_options.scale == 1
3741

42+
3843
def test_raises_exception_if_scale_is_outside_range(print_options):
3944
with pytest.raises(ValueError):
4045
print_options.scale = 3
4146

47+
4248
def test_raises_exception_if_scale_is_not_an_integer(print_options):
4349
with pytest.raises(ValueError):
4450
print_options.scale = "1"
4551

52+
4653
def test_set_background(print_options):
4754
print_options.background = True
4855
assert print_options.background is True
4956

57+
5058
def test_unset_value_to_be_none(print_options):
5159
assert print_options.page_width is None
5260

61+
5362
def test_set_width(print_options):
5463
print_options.page_width = 3
5564
assert print_options.page_width == 3
5665

66+
5767
def test_raises_exception_if_set_invalid_width(print_options):
5868
with pytest.raises(ValueError):
5969
print_options.page_width = -1
6070

71+
6172
def test_raises_exception_if_set_with_not_int(print_options):
6273
with pytest.raises(ValueError):
6374
print_options.page_width = "2"
6475

76+
6577
def test_set_height(print_options):
6678
print_options.page_height = 2
6779
assert print_options.page_height == 2
6880

81+
6982
def test_set_shrink_to_fit(print_options):
7083
print_options.shrink_to_fit = True
7184
assert print_options.shrink_to_fit is True
7285

86+
7387
def test_raises_exception_if_set_shrink_to_fit_non_bool(print_options):
7488
with pytest.raises(ValueError):
7589
print_options.shrink_to_fit = 'True'
7690

91+
7792
def test_set_page_ranges(print_options):
7893
print_options.page_ranges = ['1-2']
7994
assert print_options.page_ranges == ['1-2']
8095

96+
8197
def test_raises_exception_if_page_ranges_not_list(print_options):
8298
with pytest.raises(ValueError):
8399
print_options.page_ranges = 'foobar'
84100

101+
85102
def test_margin_height(print_options):
86103
print_options.margin_top = 2
87104
assert print_options.margin_top == 2
88105

106+
89107
def test_raises_exception_if_margin_is_invalid(print_options):
90108
with pytest.raises(ValueError):
91109
print_options.margin_top = -1

0 commit comments

Comments
 (0)