Skip to content

Commit 5d7f3e1

Browse files
author
dmy.berezovskyi
committed
added lint configuration
1 parent 2ad149b commit 5d7f3e1

21 files changed

+188
-79
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/simple-python-selenium-framework.iml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.ruff.toml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Ruff Configuration
2+
line-length = 88
3+
indent-width = 4
4+
output-format = "grouped"
5+
respect-gitignore = true
6+
target-version = "py312"
7+
8+
[lint]
9+
select = [
10+
"E", # Error codes
11+
"F", # Pyflakes
12+
"W", # Warnings
13+
"C", # Complexity
14+
"N", # Naming conventions
15+
"I", # Ignored errors
16+
"E501", # Line too long
17+
"N805", # First argument should be 'self'
18+
]
19+
fixable = ["ALL"] # All fixable errors will be automatically corrected
20+
21+
# Ignored Errors
22+
ignore = [
23+
"E731", # Do not assign a lambda expression, use a def instead
24+
"N801", # Function name should be lowercase
25+
"I001", # Import convention violation
26+
"F631", # Assert should not be used with a literal
27+
]
28+
29+
# Regular expression for dummy variables
30+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
31+
32+
# Excluded Directories and Files
33+
exclude = [
34+
".pytest_cache",
35+
"poetry.lock",
36+
"__pypackages__",
37+
".git",
38+
".env",
39+
".ruff_cache"
40+
]
41+
42+
[format]
43+
exclude = ["__init__.py"] # Exclude __init__.py from formatting
44+
skip-magic-trailing-comma = true # Skip the trailing comma for magic trailing commas

conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pytest
22
from core import CustomEventListener
33
from dotenv import load_dotenv
4-
from selenium import webdriver
54
from selenium.webdriver.support.event_firing_webdriver import EventFiringWebDriver
65

76
from src.utils.driver_factory import WebDriverFactory

pytest.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[pytest]
2-
#run tests in a row local
3-
#addopts = -rA -v --html=test_results.html --browser-type=local --env=stag --driver=mac
2+
#run tests in a row locallocal
3+
#addopts = -rA -v --html=test_results.html --browser-type= --env=stag --driver=mac
44
#run tests parallel with xdist
55
#addopts = -rA -v --html=test_results.html --browser-type=firefox --env=stag -n 2
66
#run tests in CI

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ pytest-xdist~=3.3.1
1212
cryptography~=43.0.1
1313
beautifulsoup4==4.12.2
1414
requests~=2.31.0
15-
setuptools~=68.2.2
15+
setuptools~=68.2.2
16+
ruff~=0.6.8

scraper/chrome_scraper.py

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88

99

1010
class ChromePageScraper:
11-
URL_LATEST = 'https://googlechromelabs.github.io/chrome-for-testing/#stable'
12-
URL_ALL = "https://googlechromelabs.github.io/chrome-for-testing/latest-versions-per-milestone-with-downloads.json"
11+
URL_LATEST = (
12+
"https://googlechromelabs.github.io/chrome-for-testing/#stable"
13+
)
14+
URL_ALL = "https://googlechromelabs.github.io/chrome-for-testing/latest-versions-per-milestone-with-downloads.json" # noqa
1315

1416
@staticmethod
1517
def __fetch(url: str) -> requests.Response:
1618
response = requests.get(url)
17-
response.raise_for_status() # Raises an exception if status code is not 200
19+
response.raise_for_status() # Raises an exception if status code is not 200 # noqa
1820
return response
1921

2022
@staticmethod
@@ -24,18 +26,20 @@ def parse_latest() -> Dict[str, str]:
2426
drivers = {}
2527
page = ChromePageScraper.__fetch(ChromePageScraper.URL_LATEST)
2628

27-
soup = BeautifulSoup(page.text, 'html.parser')
28-
element = soup.select_one('section#stable.status-not-ok div.table-wrapper table tbody tr.status-ok')
29+
soup = BeautifulSoup(page.text, "html.parser")
30+
element = soup.select_one(
31+
"section#stable.status-not-ok div.table-wrapper table tbody tr.status-ok" # noqa
32+
)
2933

3034
if not element:
3135
raise Exception("Element not found in the HTML.")
3236

33-
code_elements = element.find_all('code')
37+
code_elements = element.find_all("code")
3438

3539
for el in code_elements:
3640
text = el.text.strip()
3741

38-
if text not in ['200', 'chrome', 'chromedriver']:
42+
if text not in ["200", "chrome", "chromedriver"]:
3943
elements_list.append(text)
4044

4145
for i in range(0, len(elements_list), 2):
@@ -56,28 +60,37 @@ def get_chromedriver(platform=None, version=None, milestone=None):
5660
5761
:param platform: os_name and architecture
5862
:param version: your chrome browser version
59-
:param milestone: first 3 digit of browser version: 116 or 115
63+
:param milestone: first 3 digits of a browser version: 129 or etc
6064
:return:
6165
"""
6266
if version is None and milestone is None:
63-
raise ValueError(f"You must specify version or milestone: version {version}, milestone {milestone}")
67+
raise ValueError(
68+
f"You must specify version or milestone: version {version},"
69+
f" milestone {milestone}"
70+
)
6471
if platform is None:
6572
platform = OSChecker.check_os()
6673

6774
# Parse the JSON data
68-
parsed_data = json.loads(ChromePageScraper.__fetch(ChromePageScraper.URL_ALL).text)
75+
parsed_data = json.loads(
76+
ChromePageScraper.__fetch(ChromePageScraper.URL_ALL).text
77+
)
6978
milestones_data = parsed_data["milestones"]
7079

7180
for milestone_key, milestone_data in milestones_data.items():
72-
if (
73-
(milestone is None or milestone_key == milestone)
74-
and (version is None or milestone_data["version"] == version)
81+
if (milestone is None or milestone_key == milestone) and (
82+
version is None or milestone_data["version"] == version
7583
):
7684
if "chromedriver" in milestone_data["downloads"]:
77-
for chromedriver_info in milestone_data["downloads"]["chromedriver"]:
78-
if platform is None or chromedriver_info["platform"] == platform:
85+
for chromedriver_info in milestone_data["downloads"][
86+
"chromedriver"
87+
]:
88+
if (
89+
platform is None
90+
or chromedriver_info["platform"] == platform
91+
):
7992
return chromedriver_info
8093

8194

82-
if __name__ == '__main__':
83-
print(ChromePageScraper.get_chromedriver(milestone='116'))
95+
if __name__ == "__main__":
96+
print(ChromePageScraper.get_chromedriver(milestone="129"))

scraper/os_checker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ def check_os():
1212
if os_name == "Darwin":
1313
os_name = "mac"
1414
if os_name == "mac":
15-
return '-'.join([os_name, arch])
15+
return "-".join([os_name, arch])
1616
else:
17-
return ''.join([os_name, arch])
17+
return "".join([os_name, arch])
1818

1919
def print_os_info(self):
2020
os_name, arch = self.check_os()
2121
print(f"Operating System: {os_name}, arch={arch}")
2222

23-
def _get_driver_type(dr_type=None):
23+
def _get_driver_type(self=None):
2424
os_arch_mapping = {
2525
"arm64": "chrome_arm64",
2626
"x86_64": "chrome_x86_64",
2727
"ubuntu": "ubuntu", # Add additional mappings as needed
2828
}
2929

30-
default_driver_type = dr_type
30+
default_driver_type = self
3131
os_arch = platform.machine()
3232
os_name = platform.system().lower()
3333

0 commit comments

Comments
 (0)