Skip to content

Commit bc19742

Browse files
committed
[py] Fix flake8 issues and run flake8 on Travis
1 parent fa51776 commit bc19742

9 files changed

Lines changed: 31 additions & 15 deletions

File tree

.travis.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ matrix:
9292
- language: java
9393
jdk: oraclejdk8
9494
env: TASK=javadocs
95+
- language: python
96+
python: 2.7
97+
env: TOXENV=flake8
98+
- language: python
99+
python: 2.7
100+
env: TOXENV=docs
95101
- language: python
96102
python: 2.7
97103
env: CHROME=1 TOXENV=py27-chrome
@@ -114,7 +120,10 @@ matrix:
114120
addons:
115121
firefox: latest
116122
- language: python
117-
python: 2.7
123+
python: 3.5
124+
env: TOXENV=flake8
125+
- language: python
126+
python: 3.5
118127
env: TOXENV=docs
119128
- language: python
120129
python: 3.5
@@ -137,9 +146,6 @@ matrix:
137146
env: TOXENV=py35-remote
138147
addons:
139148
firefox: latest
140-
- language: python
141-
python: 3.5
142-
env: TOXENV=docs
143149
- language: ruby
144150
rvm: 2.2.3
145151
jdk: oraclejdk8

py/selenium/webdriver/firefox/firefox_binary.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,13 @@ def __init__(self, firefox_path=None, log_file=None):
4646
if self._start_cmd is None:
4747
self._start_cmd = self._get_firefox_start_cmd()
4848
if not self._start_cmd.strip():
49-
raise WebDriverException("Failed to find firefox binary. You can set it by specifying the path to 'firefox_binary':\n\nfrom selenium.webdriver.firefox.firefox_binary import FirefoxBinary\n\n" +
50-
"binary = FirefoxBinary('/path/to/binary')\ndriver = webdriver.Firefox(firefox_binary=binary)")
49+
raise WebDriverException(
50+
"Failed to find firefox binary. You can set it by specifying "
51+
"the path to 'firefox_binary':\n\nfrom "
52+
"selenium.webdriver.firefox.firefox_binary import "
53+
"FirefoxBinary\n\nbinary = "
54+
"FirefoxBinary('/path/to/binary')\ndriver = "
55+
"webdriver.Firefox(firefox_binary=binary)")
5156
# Rather than modifying the environment of the calling Python process
5257
# copy it and modify as needed.
5358
self._firefox_env = os.environ.copy()

py/selenium/webdriver/firefox/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def binary(self, new_binary):
5757
def binary_location(self):
5858
return self.binary
5959

60-
@binary.setter
60+
@binary.setter # noqa
6161
def binary_location(self, value):
6262
self.binary = value
6363

py/selenium/webdriver/firefox/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Service(service.Service):
2323
GeckoDriver."""
2424

2525
def __init__(self, executable_path, port=0, service_args=None,
26-
log_path="geckodriver.log", env=None):
26+
log_path="geckodriver.log", env=None):
2727
"""Creates a new instance of the GeckoDriver remote service proxy.
2828
2929
GeckoDriver provides a HTTP interface speaking the W3C WebDriver

py/selenium/webdriver/firefox/webdriver.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import shutil
2929
import socket
3030
import sys
31-
import types
3231

3332
from .extension_connection import ExtensionConnection
3433
from contextlib import contextmanager

py/selenium/webdriver/firefox/webelement.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def anonymous_children(self):
3030
on MDN for more information.
3131
3232
"""
33-
return self._execute("ELEMENT_GET_ANONYMOUS_CHILDREN",
33+
return self._execute(
34+
"ELEMENT_GET_ANONYMOUS_CHILDREN",
3435
{"value": None})
3536

3637
def find_anonymous_element_by_attribute(self, name, value):
@@ -43,5 +44,6 @@ def find_anonymous_element_by_attribute(self, name, value):
4344
on MDN for more information.
4445
4546
"""
46-
return self._execute("ELEMENT_FIND_ANONYMOUS_ELEMENTS_BY_ATTRIBUTE",
47+
return self._execute(
48+
"ELEMENT_FIND_ANONYMOUS_ELEMENTS_BY_ATTRIBUTE",
4749
{"name": name, "value": value})["value"]

py/selenium/webdriver/safari/webdriver.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
except ImportError:
2121
import httplib as http_client
2222

23-
import os
2423
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
2524
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
2625
from .service import Service

py/test/selenium/webdriver/common/network.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
def get_interface_ip(ifname):
2727
def _bytes(value, encoding):
2828
try:
29-
return bytes(value, encoding) # Python 3
29+
return bytes(value, encoding) # Python 3
3030
except TypeError:
31-
return value # Python 2
31+
return value # Python 2
3232

3333
sckt = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
3434
return socket.inet_ntoa(fcntl.ioctl(

tox.ini

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py{27,35}-{chrome,edge,firefox,ie,phantomjs,remote,safari}, docs
2+
envlist = py{27,35}-{chrome,edge,firefox,ie,phantomjs,remote,safari}, docs, flake8
33

44
[testenv]
55
passenv = DISPLAY PYTEST_ADDOPTS
@@ -27,3 +27,8 @@ deps =
2727
Pygments==1.6
2828
Sphinx==1.2b1
2929
commands = sphinx-build -W -b html -d build/doctrees py/docs/source build/docs/api/py {posargs}
30+
31+
[testenv:flake8]
32+
skip_install = true
33+
deps = flake8
34+
commands = flake8 {posargs:py}

0 commit comments

Comments
 (0)