Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions chromedriver_binary/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
__author__ = 'Daniel Kaiser <[email protected]>'


def get_chromedriver_filename():
def get_chromedriver_filename() -> str:
"""
Returns the filename of the binary for the current platform.
:return: Binary filename
Expand All @@ -30,7 +30,7 @@ def get_chromedriver_filename():
return 'chromedriver'


def get_variable_separator():
def get_variable_separator() -> str:
"""
Returns the environment variable separator for the current platform.
:return: Environment variable separator
Expand All @@ -40,7 +40,7 @@ def get_variable_separator():
return ':'


def get_legacy_chromedriver_url(version):
def get_legacy_chromedriver_url(version: int):
"""
Generates the download URL for legacy releases
:param version: chromedriver version string
Expand All @@ -66,7 +66,7 @@ def get_legacy_chromedriver_url(version):
return base_url + version + '/chromedriver_' + _platform + architecture + '.zip'


def get_chromedriver_url(version):
def get_chromedriver_url(version: int):
"""
Generates the download URL for current platform, architecture and the given version.
Supports Linux, macOS and Windows.
Expand Down Expand Up @@ -94,7 +94,7 @@ def get_chromedriver_url(version):
raise RuntimeError('Could not determine chromedriver download URL for this platform.')


def find_binary_in_path(filename):
def find_binary_in_path(filename: str) -> None:
"""
Searches for a binary named `filename` in the current PATH. If an executable is found, its absolute path is returned
else None.
Expand All @@ -110,7 +110,7 @@ def find_binary_in_path(filename):
return None


def get_latest_legacy_release_for_version(version):
def get_latest_legacy_release_for_version(version: int):
"""
Searches for the latest release (complete version string) for a given major `version` in the legacy storage.
:param version: Major version number or None
Expand All @@ -128,7 +128,7 @@ def get_latest_legacy_release_for_version(version):
raise RuntimeError('Failed to find release information: {}'.format(release_url))


def get_latest_release_for_version(version=None):
def get_latest_release_for_version(version: int=None):
"""
Searches for the latest release (complete version string) for a given major `version`. If `version` is None
the latest Stable release is returned.
Expand Down Expand Up @@ -164,7 +164,7 @@ def get_chrome_major_version():
pass


def check_version(binary, required_version):
def check_version(binary, required_version) -> bool:
try:
version = subprocess.check_output([binary, '-v'])
version = re.match(r'.*?([\d.]+).*?', version.decode('utf-8'))[1]
Expand All @@ -182,7 +182,7 @@ def get_chromedriver_path():
return os.path.abspath(os.path.dirname(__file__))


def print_chromedriver_path():
def print_chromedriver_path() -> None:
"""
Print the path of the chromedriver binary.
"""
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
__author__ = 'Daniel Kaiser <[email protected]>'


with open('README.md') as readme_file:
with open('README.md', encoding="utf-8") as readme_file:
long_description = readme_file.read()


class DownloadChromedriver(build_py):
def run(self):
def run(self) -> None:
"""
Downloads, unzips and installs chromedriver.
If a chromedriver binary is found in PATH it will be copied, otherwise downloaded.
Expand Down